Compare commits
235 Commits
molistar_1
...
molistar_r
Author | SHA1 | Date | |
---|---|---|---|
![]() |
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 | ||
![]() |
b4f26d324c | ||
![]() |
4a2618a76b | ||
![]() |
1b56fd075b | ||
![]() |
f1586fb0ac | ||
![]() |
66aa5a5671 | ||
![]() |
52bfc9636b | ||
![]() |
7c0665b9ce | ||
![]() |
ecb3c46407 | ||
![]() |
6ce3a64ea3 | ||
![]() |
408ec37ff2 | ||
![]() |
ecdbf9e9c3 | ||
![]() |
d8ae8a559d | ||
![]() |
2f8511ca16 |
@@ -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,8 @@ 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',
|
||||
|
||||
]
|
||||
|
||||
@@ -127,6 +129,8 @@ 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',
|
||||
|
||||
]
|
||||
|
||||
@@ -135,7 +139,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 {
|
||||
@@ -268,13 +272,15 @@ dependencies {
|
||||
if (!isolationMode && file("../modules/module_google/build.gradle").exists()) {
|
||||
implementation project(':modules:module_google')
|
||||
}
|
||||
|
||||
implementation 'tech.sud.mgp:SudMGP-static:1.3.3.1158'
|
||||
}
|
||||
|
||||
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 +293,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 +324,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 +337,43 @@ xmlClassGuard {
|
||||
"com.chwl.core": "com.hhchu.core",
|
||||
"com.chwl.library": "com.hhchu.library"]
|
||||
moveDir = [
|
||||
"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.**
|
||||
|
@@ -86,8 +86,8 @@
|
||||
<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 +127,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 +241,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 +265,9 @@
|
||||
android:name=".avroom.activity.RoomSettingActivity"
|
||||
android:label="@string/main_androidmanifest_07"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".avroom.activity.RoomBgSettingActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".avroom.activity.RoomManagerListActivity"
|
||||
android:label="@string/main_androidmanifest_08"
|
||||
@@ -448,6 +469,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 +669,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" />
|
||||
@@ -846,6 +885,43 @@
|
||||
|
||||
<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" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
File diff suppressed because one or more lines are too long
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.
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: 20 KiB |
@@ -23,8 +23,11 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.chwl.app.base.GlobalViewModelOwner;
|
||||
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.netease.nim.uikit.StatusBarUtil;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
@@ -230,11 +233,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();
|
||||
@@ -255,7 +257,6 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void otherModelInit() {
|
||||
PwdCodeMgr.get().onCreateInit();
|
||||
//初始化线程池
|
||||
@@ -263,6 +264,14 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
IMBroadcastManager.get().onCreate();
|
||||
ImageLoadUtilsV2.init(context);
|
||||
SettingsModel.get().checkSysAccount();
|
||||
initPreloadResource();
|
||||
}
|
||||
|
||||
private void initPreloadResource(){
|
||||
PreloadResourceViewModel viewModel = new ViewModelProvider(
|
||||
GlobalViewModelOwner.Companion.getInstance()
|
||||
).get(PreloadResourceViewModel.class);
|
||||
viewModel.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -600,16 +609,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;
|
||||
@@ -416,9 +420,9 @@ public class App extends BaseApp {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -478,6 +483,7 @@ public class App extends BaseApp {
|
||||
ChannelModel.get();
|
||||
MarketVerifyModel.get();
|
||||
GiftModel.get();
|
||||
GiftModel.get().tryLoadGiftList();
|
||||
// 模厅
|
||||
HallDataManager.get().application();
|
||||
//全局处理
|
||||
@@ -522,6 +528,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 +558,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,8 @@ public abstract class BottomViewListenerWrapper {
|
||||
|
||||
}
|
||||
|
||||
public void onRoomGameplayClick(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,17 +1,10 @@
|
||||
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;
|
||||
|
||||
@@ -44,7 +37,12 @@ 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.core.monsterhunting.bean.MonsterDataBean;
|
||||
import com.chwl.core.room.game.bean.BaiShunGameConfig;
|
||||
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 +55,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 +76,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 +88,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 +106,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 +130,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 +147,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;
|
||||
|
||||
|
||||
/**
|
||||
@@ -227,6 +215,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 +497,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
|
||||
@@ -914,7 +917,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 +1175,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 +1262,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);
|
||||
@@ -1363,6 +1368,12 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public RoomWidget findWidget(@NonNull String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class GiftBroadcastObserver implements Observer<BroadcastMessage> {
|
||||
private WeakReference<AVRoomActivity> mReference;
|
||||
|
||||
@@ -1382,14 +1393,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 +1443,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);
|
||||
}
|
||||
}
|
||||
|
@@ -139,8 +139,6 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
@Nullable
|
||||
ImageView ivHeadWear;
|
||||
@Nullable
|
||||
TextView tvNumber;
|
||||
@Nullable
|
||||
ImageView ivCharmLevelTag;
|
||||
|
||||
@Nullable
|
||||
@@ -158,7 +156,6 @@ 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);
|
||||
|
||||
@@ -277,31 +274,12 @@ 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("NO."+ (index + 1));
|
||||
}
|
||||
|
||||
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里面的头饰
|
||||
@@ -586,6 +564,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 +572,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())) {
|
||||
|
@@ -146,6 +146,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 +223,6 @@ class DatingMicroViewAdapter(context: Context?) : BaseMicroViewAdapter(context)
|
||||
super.bind(info, position)
|
||||
ivVipWear.isVisible = true
|
||||
ivHeadWear?.isVisible = false
|
||||
tvNumber?.isVisible = false
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -91,27 +91,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,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,17 @@
|
||||
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
|
||||
|
||||
class RoomGameplayAdapter :
|
||||
BaseQuickAdapter<RoomIcon, BaseViewHolder>(R.layout.room_gameplay_item2) {
|
||||
override fun convert(helper: BaseViewHolder, item: RoomIcon?) {
|
||||
helper.setText(R.id.tv_name, item?.name)
|
||||
val iconView = helper.getView<ImageView>(R.id.iv_icon)
|
||||
iconView.load(item?.icon)
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -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 = ""
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -54,7 +54,9 @@ class RoomPkFinishDialog : BaseDialog<DialogRoomPkFinishBinding>() {
|
||||
|
||||
roomPkBean.csRank.getOrNull(0)?.let {
|
||||
binding?.tvNickContribute?.text = it.nick.subAndReplaceDot(7)
|
||||
binding?.tvValueContribute?.text = "神豪值:${it.amount}"
|
||||
binding?.tvValueContribute?.text =
|
||||
context?.getString(R.string.layout_dialog_room_pk_finish_07, it.amount.toString())
|
||||
?: ""
|
||||
ImageLoadUtils.loadImage(
|
||||
context,
|
||||
it.avatar,
|
||||
@@ -65,7 +67,8 @@ class RoomPkFinishDialog : BaseDialog<DialogRoomPkFinishBinding>() {
|
||||
|
||||
roomPkBean.crRank.getOrNull(0)?.let {
|
||||
binding?.tvNickCharm?.text = it.nick.subAndReplaceDot(7)
|
||||
binding?.tvValueCharm?.text = "魅力值:${it.amount}"
|
||||
binding?.tvValueCharm?.text =
|
||||
context?.getString(R.string.layout_activity_jewel_09, it.amount?.toString()) ?: ""
|
||||
ImageLoadUtils.loadImage(
|
||||
context,
|
||||
it.avatar,
|
||||
|
@@ -3,6 +3,7 @@ package com.chwl.app.avroom.anotherroompk
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import androidx.core.view.isVisible
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.databinding.DialogRoomPkReceivedBinding
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean
|
||||
@@ -37,7 +38,7 @@ class RoomPkReceivedDialog : BaseDialog<DialogRoomPkReceivedBinding>() {
|
||||
@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
|
||||
|
@@ -4,6 +4,8 @@ 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
|
||||
@@ -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()
|
||||
|
@@ -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 {
|
||||
|
@@ -207,13 +207,13 @@ public class PKResultDialog extends BaseDialog {
|
||||
|
||||
private void refreshBgByStatus() {
|
||||
if (pkResult == PK_RESULT_VICTORY) {
|
||||
ivResultTop.setImageResource(R.mipmap.pk_result_victory_top);
|
||||
ivResultTop.setImageResource(R.drawable.pk_result_victory_top);
|
||||
ivResultBottom.setImageResource(R.mipmap.pk_result_victory_bottom);
|
||||
} else if (pkResult == PK_RESULT_FAIL) {
|
||||
ivResultTop.setImageResource(R.mipmap.pk_result_fail_top);
|
||||
ivResultTop.setImageResource(R.drawable.pk_result_fail_top);
|
||||
ivResultBottom.setImageResource(R.mipmap.pk_result_fail_bottom);
|
||||
} else if (pkResult == PK_RESULT_TIE) {
|
||||
ivResultTop.setImageResource(R.mipmap.pk_result_tie_top);
|
||||
ivResultTop.setImageResource(R.drawable.pk_result_tie_top);
|
||||
ivResultBottom.setImageResource(R.mipmap.pk_result_tie_bottom);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,200 @@
|
||||
package com.chwl.app.avroom.dialog
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.view.isVisible
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.adapter.RoomGameplayAdapter
|
||||
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.baishun.BaiShunGameWebActivity
|
||||
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.core.RoomDataService
|
||||
import com.chwl.core.room.game.bean.BaiShunGameConfig
|
||||
import com.chwl.core.room.model.AvRoomModel
|
||||
import com.chwl.core.support.room.RoomContext
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.google.gson.Gson
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
|
||||
class RoomGameplayDialog :
|
||||
BottomSheetDialogFragment() {
|
||||
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()
|
||||
switchStatus(0)
|
||||
requestData()
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
adapter.setOnItemClickListener { _, view, position ->
|
||||
val item = adapter.getItem(position) as RoomIcon
|
||||
jump(item)
|
||||
}
|
||||
binding?.recyclerView?.adapter = adapter
|
||||
}
|
||||
|
||||
private fun requestData() {
|
||||
val dataService =
|
||||
RoomContext.get()?.findAbility<RoomDataService>(RoomDataService::class.java.simpleName)
|
||||
val cacheKey = "gameplay_list#${parentFragment.hashCode()}"
|
||||
val list = dataService?.getData(cacheKey) as? List<RoomIcon>
|
||||
if (!list.isNullOrEmpty()) {
|
||||
loadData(list)
|
||||
return
|
||||
}
|
||||
val disposable = AvRoomModel.get().roomGamePlayList
|
||||
.doOnError {
|
||||
SingleToastUtil.showToast(it.message)
|
||||
switchStatus(-2)
|
||||
}
|
||||
.subscribe { it: List<RoomIcon> ->
|
||||
dataService?.putData(cacheKey, it)
|
||||
loadData(it)
|
||||
}
|
||||
getCompositeDisposable().add(disposable)
|
||||
}
|
||||
|
||||
private fun loadData(list: List<RoomIcon>?) {
|
||||
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 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()
|
||||
}
|
||||
}
|
||||
|
||||
interface GameplayDialogListener {
|
||||
fun onShowBaiShunGame(url: String, config: BaiShunGameConfig)
|
||||
}
|
||||
}
|
@@ -121,14 +121,14 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
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);
|
||||
rvOPtList.setAdapter(optAdapter);
|
||||
|
@@ -14,34 +14,38 @@ 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.activityViewModels
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
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.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 +56,28 @@ 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.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
|
||||
@@ -88,6 +99,7 @@ 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
|
||||
@@ -99,13 +111,23 @@ 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.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 +141,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 +195,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 +212,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 +232,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 +369,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")
|
||||
@@ -560,10 +696,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,6 +778,10 @@ 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
|
||||
@@ -652,11 +789,57 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
R.id.input_send -> {
|
||||
sendMsg()
|
||||
}
|
||||
R.id.input_headline_send -> {
|
||||
sendHeadline()
|
||||
}
|
||||
R.id.layout_room_rank -> {
|
||||
DialogWebViewActivity.start(mContext, UriProvider.getRoomRanking())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 +862,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 +911,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 +1015,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 +1187,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 +1213,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 +1222,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 +1292,9 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
}
|
||||
|
||||
override fun onFollowFail(msg: String?) {
|
||||
toast("關註失敗,請稍後重試")
|
||||
msg?.let {
|
||||
toast(msg)
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateMicView() {
|
||||
@@ -1099,8 +1319,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 +1424,16 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
override fun onRoomMessageClick() {
|
||||
RoomMsgActivity.start(mContext)
|
||||
}
|
||||
|
||||
override fun onRoomGameplayClick() {
|
||||
val dialog = RoomGameplayDialog()
|
||||
dialog.listener = object : RoomGameplayDialog.GameplayDialogListener {
|
||||
override fun onShowBaiShunGame(url: String, config: BaiShunGameConfig) {
|
||||
(activity as? AVRoomActivity)?.showBaiShunGame(url, config)
|
||||
}
|
||||
}
|
||||
dialog.show(childFragmentManager, "ROOM_GAME_PLAY")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1228,8 +1458,14 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
return this
|
||||
}
|
||||
|
||||
open fun initWidget() {
|
||||
override fun findWidget(name: String): RoomWidget? {
|
||||
return widgets[name]
|
||||
}
|
||||
|
||||
open fun initWidget() {
|
||||
publicChatMessageWidget?.let {
|
||||
registerWidget(PublicChatRoomMessageWidget::class.java.simpleName, it)
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
@@ -1247,6 +1483,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,215 @@
|
||||
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.online.RoomOnlineWidget
|
||||
import com.chwl.app.avroom.presenter.GameRoomPresenter
|
||||
import com.chwl.app.avroom.view.IGameRoomView
|
||||
import com.chwl.app.databinding.FragmentGameRoomBinding
|
||||
import com.chwl.app.ui.widget.GiftDialog.OnGiftDialogBtnClickListener
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.music.model.PlayerModel
|
||||
import com.chwl.core.room.event.FinishAvRoomEvent
|
||||
import com.chwl.library.base.factory.CreatePresenter
|
||||
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))
|
||||
super.initiate()
|
||||
//游戏模式暂时不需要这个
|
||||
PlayerModel.get().stop()
|
||||
gameBinding.roomInfo = AvRoomDataManager.get().mCurrentRoomInfo
|
||||
gameBinding.tvShowMiniMic.setOnClickListener { showMiniMic() }
|
||||
gameBinding.ivShowMic.setOnClickListener { showMic() }
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun initMessageView() {
|
||||
super.initMessageView()
|
||||
messageView.messageListView?.let {
|
||||
setMessagePagerAutoHeight(it)
|
||||
}
|
||||
publicChatMessageWidget?.getMessageView()?.messageListView?.let {
|
||||
setMessagePagerAutoHeight(it)
|
||||
}
|
||||
}
|
||||
|
||||
@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
|
||||
) {
|
||||
val layoutParams: ViewGroup.LayoutParams = messagePager.layoutParams
|
||||
val bigHeight = ScreenUtil.dip2px(200f)
|
||||
val littleHeight = ScreenUtil.dip2px(80f)
|
||||
layoutParams.height =
|
||||
if (layoutParams.height == littleHeight) bigHeight else littleHeight
|
||||
messagePager.layoutParams = layoutParams
|
||||
}
|
||||
false
|
||||
})
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
@@ -16,7 +16,19 @@ import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.chwl.app.avroom.adapter.SelectGameAdapter;
|
||||
import com.chwl.app.home.helper.OpenRoomHelper;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2;
|
||||
import com.chwl.app.ui.widget.GiftDialog;
|
||||
import com.chwl.app.ui.widget.UserInfoDialog;
|
||||
import com.chwl.core.room.bean.RoomModeType;
|
||||
import com.chwl.core.room.game.GameModel;
|
||||
import com.chwl.core.room.game.bean.GameInfo;
|
||||
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 +37,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;
|
||||
@@ -94,6 +105,7 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
|
||||
//收藏房间
|
||||
private String FOLLOW_ROOM_TYPE = "";
|
||||
private SelectGameAdapter gameAdapter;
|
||||
|
||||
public static HomePartyFragment newInstance() {
|
||||
HomePartyFragment homePartyFragment = new HomePartyFragment();
|
||||
@@ -107,6 +119,7 @@ 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) {
|
||||
@@ -191,7 +204,6 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
roomMore.setOnClickListener(this);
|
||||
ivFollowRoom.setOnClickListener(this);
|
||||
// ivRoomShare.setOnClickListener(this);
|
||||
gameMainBinding.llRoomInfo.setOnClickListener(this);
|
||||
gameMainBinding.ivBack.setOnClickListener(this);
|
||||
|
||||
mRoomEffectView.setOnPlayAnimCallback(new Function0<Boolean>() {
|
||||
@@ -212,9 +224,75 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
}
|
||||
}
|
||||
|
||||
private void initRvGame() {
|
||||
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (roomInfo == null || gameAdapter != null) return;
|
||||
gameMainBinding.rvGame.setLayoutManager(new LinearLayoutManager(mContext));
|
||||
gameMainBinding.rvGame.setAdapter(gameAdapter = new SelectGameAdapter());
|
||||
gameMainBinding.llSelectGame.setOnClickListener(v -> {
|
||||
if (gameMainBinding.rvGame.getVisibility() == View.VISIBLE) {
|
||||
gameMainBinding.rvGame.setVisibility(View.GONE);
|
||||
gameMainBinding.ivChangeGameArrow.setImageResource(R.drawable.ic_room_arrow_type_below);
|
||||
} else {
|
||||
if (!isShowChangeGame()) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_fragment_homepartyfragment_01));
|
||||
return;
|
||||
}
|
||||
if (AvRoomDataManager.get().isGamePlaying()) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_fragment_homepartyfragment_02));
|
||||
} else {
|
||||
gameMainBinding.rvGame.setVisibility(View.VISIBLE);
|
||||
gameMainBinding.ivChangeGameArrow.setImageResource(R.drawable.ic_room_arrow_type);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
gameAdapter.setOnItemClickListener((adapter, view, position) -> {
|
||||
if (AvRoomDataManager.get().isGamePlaying()) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_fragment_homepartyfragment_03));
|
||||
}
|
||||
if (!isShowChangeGame()) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_fragment_homepartyfragment_04));
|
||||
return;
|
||||
}
|
||||
|
||||
GameInfo gameInfo = gameAdapter.getItem(position);
|
||||
if (gameInfo != null) {
|
||||
gameMainBinding.rvGame.setVisibility(View.GONE);
|
||||
gameMainBinding.ivChangeGameArrow.setImageResource(R.drawable.ic_room_arrow_type_below);
|
||||
if (gameInfo.isStandardRoom()) {
|
||||
OpenRoomHelper.updateRoomInfo(
|
||||
getBaseActivity(),
|
||||
AvRoomDataManager.get().mCurrentRoomInfo,
|
||||
RoomInfo.ROOMTYPE_HOME_PARTY,
|
||||
0,
|
||||
false);
|
||||
} else {
|
||||
OpenRoomHelper.updateRoomInfo(
|
||||
getBaseActivity(),
|
||||
AvRoomDataManager.get().mCurrentRoomInfo,
|
||||
RoomInfo.ROOMTYPE_GAME,
|
||||
JavaUtil.str2long(gameInfo.getMgId()),
|
||||
false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//这里的2和4是服务端定义的错误状态 关闭排麦模式和关闭PK模式!
|
||||
private boolean isShowChangeGame() {
|
||||
RoomInfo currentRoomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
return currentRoomInfo != null &&
|
||||
AvRoomDataManager.get().isRoomOwner() &&
|
||||
currentRoomInfo.getIsPermitRoom() != 1 &&
|
||||
currentRoomInfo.getType() != RoomInfo.ROOM_TYPE_SINGLE &&
|
||||
(currentRoomInfo.getRoomModeType() == RoomModeType.NORMAL_MODE ||
|
||||
currentRoomInfo.getRoomModeType() == 2 ||
|
||||
currentRoomInfo.getRoomModeType() == 4);
|
||||
}
|
||||
|
||||
public void setRoomBg(RoomInfo roomInfo) {
|
||||
if (svgaRoomBg == null) return;
|
||||
updateView(roomInfo);
|
||||
AVRoomActivity.setBackBg(mContext, roomInfo, svgaRoomBg, bgPicture);
|
||||
}
|
||||
|
||||
@@ -237,7 +315,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,16 +424,16 @@ 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;
|
||||
default:
|
||||
if (!(tempFragment instanceof HomePartyRoomFragment)) {
|
||||
tempFragment = HomePartyRoomFragment.newInstance();
|
||||
@@ -370,10 +447,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 +465,36 @@ 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 (isShowChangeGame()) {
|
||||
initRvGame();
|
||||
gameMainBinding.llChangeGame.setVisibility(View.VISIBLE);
|
||||
if (AvRoomDataManager.get().isOpenGame()) {
|
||||
gameMainBinding.tvCurrGame.setText(currentRoomInfo.getMgName());
|
||||
} else {
|
||||
gameMainBinding.tvCurrGame.setText(ResUtil.getString(R.string.avroom_fragment_homepartyfragment_08));
|
||||
}
|
||||
GameModel.INSTANCE.getGameList()
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(gameInfos -> {
|
||||
if (AvRoomDataManager.get().isOpenGame()) {
|
||||
for (int i = 0; i < gameInfos.size(); i++) {
|
||||
GameInfo gameInfo = gameInfos.get(i);
|
||||
if (JavaUtil.str2long(gameInfo.getMgId()) == currentRoomInfo.getMgId()) {
|
||||
gameInfos.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
GameInfo gameInfo = new GameInfo();
|
||||
gameInfo.asStandardRoom();
|
||||
gameInfo.setName(ResUtil.getString(R.string.avroom_fragment_homepartyfragment_09));
|
||||
gameInfos.add(gameInfo);
|
||||
}
|
||||
gameAdapter.setNewData(gameInfos);
|
||||
});
|
||||
} else {
|
||||
gameMainBinding.llChangeGame.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -409,11 +517,12 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
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.END, 0, 0);
|
||||
break;
|
||||
case R.id.ll_room_info:
|
||||
RoomOnlineUserActivity.start(getActivity());
|
||||
.showAtLocation(gameMainBinding.getRoot(), gravity, 0, 0);
|
||||
break;
|
||||
case R.id.iv_follow_room:
|
||||
followRoom();
|
||||
@@ -549,7 +658,23 @@ 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
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -8,7 +8,9 @@ import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.chwl.app.avroom.online.RoomOnlineWidget;
|
||||
import com.chwl.app.music.widget.MusicPlayerView;
|
||||
import com.chwl.app.ui.webview.DialogWebViewActivity;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.trello.rxlifecycle3.android.FragmentEvent;
|
||||
import com.chwl.app.R;
|
||||
@@ -131,6 +133,7 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
@Override
|
||||
public void initWidget() {
|
||||
super.initWidget();
|
||||
registerWidget(RoomOnlineWidget.class.getSimpleName(), gameBinding.onlineWidget);
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@@ -584,6 +587,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;
|
||||
}
|
||||
@@ -772,6 +781,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();
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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,245 @@
|
||||
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.online.RoomOnlineWidget
|
||||
import com.chwl.app.avroom.presenter.SingleRoomPresenter
|
||||
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)
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
protected static final String APP_ID = "1578948593831571457";
|
||||
protected static final String APP_KEY = "J9lHOXvFWkAZiTfl4SK7IGt0wDnW3fWd";
|
||||
protected static boolean isTestEnv = BuildConfig.DEBUG;
|
||||
|
||||
}
|
695
app/src/main/java/com/chwl/app/avroom/game/GameDelegate.kt
Normal file
695
app/src/main/java/com/chwl/app/avroom/game/GameDelegate.kt
Normal file
@@ -0,0 +1,695 @@
|
||||
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.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.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
|
||||
|
||||
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()
|
||||
viewGameRect.put("left", 0)
|
||||
viewGameRect.put("top", container.context.resources.getDimensionPixelOffset(R.dimen.dp_180))
|
||||
viewGameRect.put("right", 0)
|
||||
viewGameRect.put("bottom", container.context.resources.getDimensionPixelOffset(R.dimen.dp_150))
|
||||
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.APP_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.APP_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("當前遊戲人數已滿!")
|
||||
} 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,61 @@
|
||||
/*
|
||||
Copyright © Sud.Tech
|
||||
https://sud.tech
|
||||
*/
|
||||
package com.chwl.app.avroom.game;
|
||||
|
||||
/**
|
||||
* Time:2021/10/19
|
||||
* Description: APP to MG 的状态定义
|
||||
*/
|
||||
public class SudMGPAPPState {
|
||||
|
||||
// region 通用状态
|
||||
|
||||
/**
|
||||
* 加入状态
|
||||
* 最低版本: v1.1.30.xx
|
||||
*/
|
||||
public static final String APP_COMMON_SELF_IN = "app_common_self_in";
|
||||
|
||||
/**
|
||||
* 准备状态
|
||||
* 最低版本: v1.1.30.xx
|
||||
*/
|
||||
public static final String APP_COMMON_SELF_READY = "app_common_self_ready";
|
||||
|
||||
/**
|
||||
* 游戏状态
|
||||
* 最低版本: v1.1.30.xx
|
||||
*/
|
||||
public static final String APP_COMMON_SELF_PLAYING = "app_common_self_playing";
|
||||
|
||||
/**
|
||||
* 队长状态
|
||||
* 最低版本: v1.1.30.xx
|
||||
*/
|
||||
public static final String APP_COMMON_SELF_CAPTAIN = "app_common_self_captain";
|
||||
|
||||
/**
|
||||
* 踢人
|
||||
* v1.1.30.xx
|
||||
*/
|
||||
public static final String APP_COMMON_SELF_KICK = "app_common_self_kick";
|
||||
|
||||
/**
|
||||
* 结束游戏
|
||||
* v1.1.30.xx
|
||||
*/
|
||||
public static final String APP_COMMON_SELF_END = "app_common_self_end";
|
||||
|
||||
/**
|
||||
* 麦克风状态
|
||||
*/
|
||||
public static final String APP_COMMON_SELF_MICROPHONE = "app_common_self_microphone";
|
||||
|
||||
/**
|
||||
* 文字命中状态
|
||||
*/
|
||||
public static final String APP_COMMON_SELF_TEXT_HIT = "app_common_self_text_hit";
|
||||
|
||||
}
|
125
app/src/main/java/com/chwl/app/avroom/game/SudMGPMGState.java
Normal file
125
app/src/main/java/com/chwl/app/avroom/game/SudMGPMGState.java
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
Copyright © Sud.Tech
|
||||
https://sud.tech
|
||||
*/
|
||||
package com.chwl.app.avroom.game;
|
||||
|
||||
/**
|
||||
* Time:2021/10/19
|
||||
* Description: MG to APP 的状态定义
|
||||
*/
|
||||
public class SudMGPMGState {
|
||||
|
||||
// region 通用状态-游戏
|
||||
|
||||
/**
|
||||
* 公屏消息 (已修改)
|
||||
* 最低版本: v1.1.30.xx
|
||||
*/
|
||||
public static final String MG_COMMON_PUBLIC_MESSAGE = "mg_common_public_message";
|
||||
|
||||
/**
|
||||
* 关键词状态
|
||||
*/
|
||||
public static final String MG_COMMON_KEY_WORD_TO_HIT = "mg_common_key_word_to_hit";
|
||||
|
||||
// endregion 通用状态-游戏
|
||||
|
||||
|
||||
// region 通用状态-玩家
|
||||
|
||||
/**
|
||||
* 加入状态 (已修改)
|
||||
* 最低版本: v1.1.30.xx
|
||||
*/
|
||||
public static final String MG_COMMON_PLAYER_IN = "mg_common_player_in";
|
||||
|
||||
/**
|
||||
* 准备状态 (已修改)
|
||||
* 最低版本: v1.1.30.xx
|
||||
*/
|
||||
public static final String MG_COMMON_PLAYER_READY = "mg_common_player_ready";
|
||||
|
||||
/**
|
||||
* 队长状态 (已修改)
|
||||
* 最低版本: v1.1.30.xx
|
||||
*/
|
||||
public static final String MG_COMMON_PLAYER_CAPTAIN = "mg_common_player_captain";
|
||||
|
||||
/**
|
||||
* 游戏状态 (已修改)
|
||||
* 最低版本: v1.1.30.xx
|
||||
*/
|
||||
public static final String MG_COMMON_PLAYER_PLAYING = "mg_common_player_playing";
|
||||
|
||||
/**
|
||||
* 游戏状态(已修改)
|
||||
* 最低版本: v1.1.30.xx
|
||||
*/
|
||||
public static final String MG_COMMON_GAME_STATE = "mg_common_game_state";
|
||||
|
||||
// endregion 通用状态-玩家
|
||||
|
||||
|
||||
// region 碰碰我最强
|
||||
// endregion 碰碰我最强
|
||||
|
||||
// region 飞刀达人
|
||||
// endregion 飞刀达人
|
||||
|
||||
// region 你画我猜
|
||||
|
||||
/**
|
||||
* 选词中
|
||||
*/
|
||||
public static final String MG_DG_SELECTING = "mg_dg_selecting";
|
||||
|
||||
/**
|
||||
* 作画中
|
||||
*/
|
||||
public static final String MG_DG_PAINTING = "mg_dg_painting";
|
||||
|
||||
/**
|
||||
* 错误答案
|
||||
*/
|
||||
public static final String MG_DG_ERRORANSWER = "mg_dg_erroranswer";
|
||||
|
||||
/**
|
||||
* 总积分
|
||||
*/
|
||||
public static final String MG_DG_TOTALSCORE = "mg_dg_totalscore";
|
||||
|
||||
/**
|
||||
* 本次积分
|
||||
*/
|
||||
public static final String MG_DG_SCORE = "mg_dg_score";
|
||||
|
||||
// endregion 你画我猜
|
||||
|
||||
|
||||
/**
|
||||
* 加入游戏按钮点击状态
|
||||
*/
|
||||
public static final String APP_COMMON_SELF_CLICK_JOIN_BTN = "mg_common_self_click_join_btn";
|
||||
/**
|
||||
* 取消加入游戏按钮点击状态
|
||||
*/
|
||||
public static final String APP_COMMON_SELF_CLICK_CANCEL_JOIN_BTN = "mg_common_self_click_cancel_join_btn";
|
||||
/**
|
||||
* 准备按钮点击状态
|
||||
*/
|
||||
public static final String APP_COMMON_SELF_CLICK_READY_BTN = "mg_common_self_click_ready_btn";
|
||||
/**
|
||||
* 取消准备按钮点击状态
|
||||
*/
|
||||
public static final String APP_COMMON_SELF_CLICK_CANCEL_READY_BTN = "mg_common_self_click_cancel_ready_btn";
|
||||
/**
|
||||
* 开始游戏按钮点击状态
|
||||
*/
|
||||
public static final String APP_COMMON_SELF_CLICK_START_BTN = "mg_common_self_click_start_btn";
|
||||
/**
|
||||
* 分享按钮点击状态
|
||||
*/
|
||||
public static final String APP_COMMON_SELF_CLICK_SHARE_BTN = "mg_common_self_click_share_btn";
|
||||
|
||||
}
|
@@ -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,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)
|
||||
}
|
||||
}
|
218
app/src/main/java/com/chwl/app/avroom/online/RoomOnlineWidget.kt
Normal file
218
app/src/main/java/com/chwl/app/avroom/online/RoomOnlineWidget.kt
Normal file
@@ -0,0 +1,218 @@
|
||||
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 {
|
||||
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, 10, 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()
|
||||
}
|
||||
}
|
||||
}
|
@@ -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());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -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,25 @@ public class BaseRoomPresenter<V extends IBaseRoomView> extends BaseMvpPresenter
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public void sendPublicChatTextMessage(String message) {
|
||||
if (TextUtils.isEmpty(message)) return;
|
||||
String sessionId = InitialModel.get().getPublicChatSessionId();
|
||||
if (sessionId == null) {
|
||||
SingleToastUtil.showToast(R.string.public_chat_not_found);
|
||||
return;
|
||||
}
|
||||
ChatRoomClient client = ChatRoomClientManager.INSTANCE.getClient(sessionId);
|
||||
ChatRoomMessage textMessage = ChatRoomMessageBuilder.createChatRoomTextMessage(sessionId, 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,880 @@
|
||||
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.PKResultDialog;
|
||||
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.XConstants;
|
||||
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.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;
|
||||
}
|
||||
if (mMessageAdapter.getItemCount() > 0) {
|
||||
messageListView.smoothScrollToPosition(mMessageAdapter.getItemCount() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
} catch (UnsupportedOperationException e) {
|
||||
e.printStackTrace();
|
||||
clearBackground(tvContent);
|
||||
tvContent.setTextColor(Color.WHITE);
|
||||
tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip));
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
PKResultDialog pkResultDialog = new PKResultDialog(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,153 @@
|
||||
package com.chwl.app.avroom.public_chat
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.databinding.RoomPublicChatMessageWidgetBinding
|
||||
import com.chwl.app.public_chat.core.ChatRoomClient
|
||||
import com.chwl.app.public_chat.core.ChatRoomClientManager
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment
|
||||
import com.chwl.core.im.custom.bean.HeadlineChangedAttachment
|
||||
import com.chwl.core.initial.InitialModel
|
||||
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.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 binding: RoomPublicChatMessageWidgetBinding =
|
||||
DataBindingUtil.inflate(
|
||||
LayoutInflater.from(
|
||||
context
|
||||
), R.layout.room_public_chat_message_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)
|
||||
|
||||
override fun onStart(roomView: RoomView) {
|
||||
super.onStart(roomView)
|
||||
val sessionId = InitialModel.get().publicChatSessionId
|
||||
if (sessionId != null) {
|
||||
chatRoomClient = ChatRoomClientManager.getClient(sessionId);
|
||||
} else {
|
||||
SingleToastUtil.showToast(R.string.public_chat_not_found)
|
||||
}
|
||||
chatRoomClient?.let {
|
||||
initChatRoom(it)
|
||||
}
|
||||
requestCurrentHeadline()
|
||||
}
|
||||
|
||||
private fun onReceiveMessage(message: ChatRoomMessage) {
|
||||
if (!filterMessageForMessageList(message)) {
|
||||
binding.messageView.addMessages(message)
|
||||
}
|
||||
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) {
|
||||
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({
|
||||
binding.messageView.addHistoryMessages(it.reversed())
|
||||
}, {
|
||||
it.printStackTrace()
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
private fun requestCurrentHeadline() {
|
||||
safeLaunch {
|
||||
val data = PublicChatModel.getCurrentHeadline()
|
||||
updateHeadline(data)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateHeadline(data: HeadlineBean?) {
|
||||
val content = data?.content
|
||||
if (data?.isValid() == true && !content.isNullOrEmpty()) {
|
||||
binding.tvHeadlineContent.text = content
|
||||
binding.tvHeadlineContent.isVisible = true
|
||||
} else {
|
||||
binding.tvHeadlineContent.isVisible = false
|
||||
}
|
||||
}
|
||||
|
||||
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() = binding.messageView
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
chatRoomClient = null
|
||||
}
|
||||
}
|
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());
|
||||
|
@@ -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)
|
||||
|
@@ -3,6 +3,7 @@ package com.chwl.app.avroom.singleroompk
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import androidx.core.view.isVisible
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.base.BaseDialog
|
||||
import com.chwl.app.databinding.DialogSingleRoomPkReceivedBinding
|
||||
import com.chwl.core.im.custom.bean.RoomPkBean
|
||||
@@ -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
|
||||
|
@@ -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)
|
||||
|
||||
/**
|
||||
* 上麦请求
|
||||
|
@@ -2,7 +2,7 @@ package com.chwl.app.avroom.view;
|
||||
|
||||
|
||||
|
||||
import com.chwl.core.room.bean.OnlineChatMember;
|
||||
import com.chwl.core.room.bean.RoomOnlineUserBean;
|
||||
import com.chwl.library.base.IMvpBaseView;
|
||||
|
||||
import java.util.List;
|
||||
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
* @date 2017/12/8
|
||||
*/
|
||||
public interface IHomePartyUserListView extends IMvpBaseView {
|
||||
void onRequestChatMemberByPageSuccess(List<OnlineChatMember> memberList, int page);
|
||||
void onRequestRoomOnlineListSuccess(List<RoomOnlineUserBean> memberList);
|
||||
|
||||
void onRequestChatMemberByPageFail(String errorStr, int page);
|
||||
|
||||
|
@@ -12,7 +12,6 @@ import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
@@ -21,6 +20,7 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.chwl.app.avroom.dialog.RoomGameplayDialog;
|
||||
import com.chwl.core.utils.extension.StringExtensionKt;
|
||||
import com.netease.nim.uikit.api.NimUIKit;
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
@@ -38,9 +38,7 @@ import com.chwl.core.pay.event.FirstChargeEvent;
|
||||
import com.chwl.core.room.bean.RoomInfo;
|
||||
import com.chwl.core.room.bean.RoomModeType;
|
||||
import com.chwl.core.super_admin.util.SuperAdminUtil;
|
||||
import com.chwl.core.user.UserModel;
|
||||
import com.chwl.core.utils.SharedPreferenceUtils;
|
||||
import com.chwl.core.utils.net.RxHelper;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
@@ -54,7 +52,7 @@ import java.util.List;
|
||||
* @date 2017/7/26
|
||||
*/
|
||||
|
||||
public class BottomView extends FrameLayout implements View.OnClickListener {
|
||||
public class BottomView extends LinearLayout implements View.OnClickListener {
|
||||
|
||||
/**
|
||||
* 有新功能,加1
|
||||
@@ -74,7 +72,6 @@ public class BottomView extends FrameLayout implements View.OnClickListener {
|
||||
private LinearLayout micLayout;
|
||||
private ImageView iconMicQueue;
|
||||
private ImageView iconRoomMsg;
|
||||
private ImageView iconVip;
|
||||
|
||||
@Nullable
|
||||
private PopupWindow msgTipPopupWindow;
|
||||
@@ -111,7 +108,7 @@ public class BottomView extends FrameLayout implements View.OnClickListener {
|
||||
iconMicQueue = (ImageView) findViewById(R.id.icon_mic_queue);
|
||||
|
||||
iconRoomMsg = findViewById(R.id.iv_room_message);
|
||||
iconVip = findViewById(R.id.icon_room_vip);
|
||||
ImageView gameView = findViewById(R.id.icon_room_game);
|
||||
openMic.setOnClickListener(this);
|
||||
sendMsgInput.setOnClickListener(this);
|
||||
sendFace.setOnClickListener(this);
|
||||
@@ -120,7 +117,7 @@ public class BottomView extends FrameLayout implements View.OnClickListener {
|
||||
sendMagic.setOnClickListener(this);
|
||||
iconMicQueue.setOnClickListener(this);
|
||||
iconRoomMsg.setOnClickListener(this);
|
||||
iconVip.setOnClickListener(this);
|
||||
gameView.setOnClickListener(this);
|
||||
|
||||
setMicBtnEnable(false);
|
||||
setMicBtnOpen(false);
|
||||
@@ -158,9 +155,9 @@ public class BottomView extends FrameLayout implements View.OnClickListener {
|
||||
int newOption = (int) SharedPreferenceUtils.get(SH_NEW_OPTION, 0);
|
||||
|
||||
if (newOption == NEW_OPTION) {
|
||||
sendMagic.setImageResource(R.drawable.icon_send_magic);
|
||||
sendMagic.setImageResource(R.drawable.room_menu_ic_more);
|
||||
} else {
|
||||
sendMagic.setImageResource(R.drawable.icon_send_magic);
|
||||
sendMagic.setImageResource(R.drawable.room_menu_ic_more);
|
||||
}
|
||||
sendMagic.setClickable(true);
|
||||
sendMagic.setOnClickListener(this);
|
||||
@@ -181,11 +178,11 @@ public class BottomView extends FrameLayout implements View.OnClickListener {
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onFirstRechargeEvent(FirstChargeEvent event) {
|
||||
sendGift.setImageResource(R.drawable.icon_room_send_gift);
|
||||
// sendGift.setImageResource(R.drawable.icon_room_send_gift);
|
||||
}
|
||||
|
||||
public void setRoomMessageUnread(int count) {
|
||||
iconRoomMsg.setImageResource(count > 0 ? R.drawable.icon_room_send_msg_point : R.drawable.icon_room_send_msg);
|
||||
iconRoomMsg.setImageResource(count > 0 ? R.drawable.room_menu_ic_message_new : R.drawable.room_menu_ic_message);
|
||||
}
|
||||
|
||||
public void setBottomViewListener(BottomViewListenerWrapper wrapper) {
|
||||
@@ -204,17 +201,17 @@ public class BottomView extends FrameLayout implements View.OnClickListener {
|
||||
|
||||
public void setMicBtnOpen(boolean isOpen) {
|
||||
if (isOpen) {
|
||||
openMic.setImageResource(R.drawable.icon_room_open_mic);
|
||||
openMic.setImageResource(R.drawable.room_menu_ic_mic_open);
|
||||
} else {
|
||||
openMic.setImageResource(R.drawable.icon_room_close_mic);
|
||||
openMic.setImageResource(R.drawable.room_menu_ic_mic_close);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRemoteMuteOpen(boolean isOpen) {
|
||||
if (isOpen) {
|
||||
remoteMute.setImageResource(R.drawable.icon_remote_mute_close);
|
||||
remoteMute.setImageResource(R.drawable.room_menu_ic_vocality_open);
|
||||
} else {
|
||||
remoteMute.setImageResource(R.drawable.icon_remote_mute_open);
|
||||
remoteMute.setImageResource(R.drawable.room_menu_ic_vocality_close);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,8 +254,8 @@ public class BottomView extends FrameLayout implements View.OnClickListener {
|
||||
}
|
||||
|
||||
public void setQueuingMicButtonBackground(boolean isEmpty) {
|
||||
iconMicQueue.setImageResource(isEmpty ? R.drawable.icon_room_mic_queue :
|
||||
R.drawable.icon_room_mic_queue_not_empty);
|
||||
iconMicQueue.setImageResource(isEmpty ? R.drawable.room_menu_ic_mic_queue :
|
||||
R.drawable.room_menu_ic_mic_queue_new);
|
||||
}
|
||||
|
||||
|
||||
@@ -320,8 +317,10 @@ public class BottomView extends FrameLayout implements View.OnClickListener {
|
||||
wrapper.onRoomMessageClick();
|
||||
}
|
||||
break;
|
||||
case R.id.icon_room_vip:
|
||||
VipMainActivity.start(getContext());
|
||||
case R.id.icon_room_game:
|
||||
if (wrapper != null) {
|
||||
wrapper.onRoomGameplayClick();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@@ -1,30 +1,35 @@
|
||||
package com.chwl.app.avroom.widget;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.chwl.core.helper.PathHelper;
|
||||
import com.chwl.library.download.DownloadException;
|
||||
import com.chwl.library.download.DownloadManager;
|
||||
import com.chwl.library.download.DownloadRequest;
|
||||
import com.chwl.library.download.DownloadTask;
|
||||
import com.chwl.library.download.FileDownloadListener;
|
||||
import com.example.lib_utils.log.LogUtil;
|
||||
import com.netease.nim.uikit.common.util.string.StringUtil;
|
||||
import com.opensource.svgaplayer.SVGACallback;
|
||||
import com.opensource.svgaplayer.SVGADrawable;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
import com.opensource.svgaplayer.SVGAVideoEntity;
|
||||
import com.tencent.qgame.animplayer.AnimConfig;
|
||||
import com.tencent.qgame.animplayer.AnimView;
|
||||
import com.chwl.app.R;
|
||||
import com.chwl.app.common.widget.CircleImageView;
|
||||
import com.chwl.app.ui.utils.ImageLoadKt;
|
||||
import com.chwl.core.gift.GiftModel;
|
||||
import com.chwl.core.gift.bean.GiftEffectInfo;
|
||||
import com.chwl.core.gift.bean.GiftInfo;
|
||||
@@ -33,39 +38,33 @@ import com.chwl.core.initial.bean.InitInfo;
|
||||
import com.chwl.core.manager.AvRoomDataManager;
|
||||
import com.chwl.core.manager.IMNetEaseManager;
|
||||
import com.chwl.core.manager.RoomEvent;
|
||||
import com.chwl.library.utils.ResolutionUtils;
|
||||
import com.tencent.qgame.animplayer.inter.IAnimListener;
|
||||
import com.tencent.qgame.animplayer.util.ScaleType;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* @author chenran
|
||||
* @date 2017/10/8
|
||||
*/
|
||||
|
||||
public class GiftEffectView extends RelativeLayout implements SVGACallback {
|
||||
private RelativeLayout container;
|
||||
public class GiftEffectView extends RelativeLayout {
|
||||
private SVGAImageView svgaImageView;
|
||||
private AnimView vapAnimView;
|
||||
private View svgaBg;
|
||||
private ImageView giftLightBg;
|
||||
private CircleImageView giftImg;
|
||||
private ImageView imgBg;
|
||||
private CircleImageView benefactorAvatar;
|
||||
private CircleImageView receiverAvatar;
|
||||
private TextView benefactorNick;
|
||||
private TextView receiverNick;
|
||||
private TextView giftNumber;
|
||||
private TextView giftName;
|
||||
private GiftEffectListener giftEffectListener;
|
||||
private EffectHandler effectHandler;
|
||||
private boolean isAnim;
|
||||
private boolean isPlayAnim;
|
||||
private boolean isHideCarEffect;
|
||||
|
||||
private String DOWNLOAD_TAG = "gift_effect_download";
|
||||
|
||||
private SVGAParser.ParseCompletion parseCompletion;
|
||||
|
||||
public GiftEffectView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
@@ -96,22 +95,85 @@ public class GiftEffectView extends RelativeLayout implements SVGACallback {
|
||||
private void init() {
|
||||
LayoutInflater.from(getContext()).inflate(R.layout.layout_gift_effect, this, true);
|
||||
effectHandler = new EffectHandler(this);
|
||||
container = findViewById(R.id.container);
|
||||
imgBg = findViewById(R.id.img_bg);
|
||||
giftLightBg = findViewById(R.id.gift_light_bg);
|
||||
giftImg = findViewById(R.id.gift_img);
|
||||
benefactorAvatar = findViewById(R.id.benefactor_avatar);
|
||||
receiverAvatar = findViewById(R.id.receiver_avatar);
|
||||
benefactorNick = findViewById(R.id.benefactor_nick);
|
||||
receiverNick = findViewById(R.id.receiver_nick);
|
||||
giftNumber = findViewById(R.id.gift_number);
|
||||
giftName = findViewById(R.id.gift_name);
|
||||
svgaImageView = findViewById(R.id.svga_imageview);
|
||||
svgaImageView.setCallback(this);
|
||||
svgaImageView.setClearsAfterStop(true);
|
||||
svgaImageView.setLoops(1);
|
||||
svgaBg = findViewById(R.id.svga_imageview_bg);
|
||||
vapAnimView = findViewById(R.id.vap_anim_view);
|
||||
parseCompletion = new SVGAParser.ParseCompletion() {
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
log("onError");
|
||||
effectHandler.sendEmptyMessage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete(@NonNull SVGAVideoEntity svgaVideoEntity) {
|
||||
log("onComplete");
|
||||
SVGADrawable drawable = new SVGADrawable(svgaVideoEntity);
|
||||
svgaImageView.setImageDrawable(drawable);
|
||||
svgaImageView.startAnimation();
|
||||
svgaBg.setVisibility(VISIBLE);
|
||||
ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(svgaBg, "alpha", 0.0F, 2.0F).setDuration(1250);
|
||||
objectAnimator1.setInterpolator(new AccelerateDecelerateInterpolator());
|
||||
objectAnimator1.start();
|
||||
}
|
||||
};
|
||||
svgaImageView.setCallback(new SVGACallback() {
|
||||
@Override
|
||||
public void onPause() {
|
||||
log("onPause");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinished() {
|
||||
log("onFinished");
|
||||
effectHandler.sendEmptyMessage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRepeat() {
|
||||
log("onRepeat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStep(int i, double v) {
|
||||
|
||||
}
|
||||
});
|
||||
vapAnimView.setScaleType(ScaleType.CENTER_CROP);
|
||||
vapAnimView.setAnimListener(new IAnimListener() {
|
||||
@Override
|
||||
public boolean onVideoConfigReady(@NonNull AnimConfig animConfig) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVideoStart() {
|
||||
log("onVideoStart");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVideoRender(int i, @androidx.annotation.Nullable AnimConfig animConfig) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVideoComplete() {
|
||||
log("onVideoComplete");
|
||||
effectHandler.sendEmptyMessage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVideoDestroy() {
|
||||
log("onVideoDestroy");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(int i, @androidx.annotation.Nullable String s) {
|
||||
log("onFailed i:" + i + " s:" + s);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void startGiftEffect(GiftEffectInfo giftEffectInfo) {
|
||||
@@ -121,107 +183,98 @@ public class GiftEffectView extends RelativeLayout implements SVGACallback {
|
||||
giftInfo = giftEffectInfo.getGift();
|
||||
}
|
||||
if (giftInfo != null) {
|
||||
isPlayAnim = false;
|
||||
container.setVisibility(INVISIBLE);
|
||||
effectHandler.sendEmptyMessageDelayed(0, 4000);
|
||||
if (giftInfo.getOtherViewType() == 1 && !TextUtils.isEmpty(giftInfo.getViewUrl())) {
|
||||
drawVAPEffect(giftInfo.getViewUrl());
|
||||
} else if (giftInfo.isHasVggPic() && !StringUtil.isEmpty(giftInfo.getVggUrl())) {
|
||||
try {
|
||||
drawSvgaEffect(giftInfo.getVggUrl());
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
InitInfo initInfo = InitialModel.get().getCacheInitInfo();
|
||||
if (!isHideCarEffect && initInfo != null && giftInfo.getGoldPrice() >= initInfo.getHideCarEffectGiftPrice()) {
|
||||
isHideCarEffect = true;
|
||||
IMNetEaseManager.get().noticeRoomEvent(null, RoomEvent.ROOM_CAR_EFFECT_HIDE);
|
||||
}
|
||||
if (!AvRoomDataManager.get().mIsNeedGiftEffect || AvRoomDataManager.get().isSelfGamePlaying()) {
|
||||
effectHandler.sendEmptyMessage(0);
|
||||
return;
|
||||
}
|
||||
if (giftInfo.getOtherViewType() == 1 && !TextUtils.isEmpty(giftInfo.getViewUrl())) {
|
||||
drawVAPEffect(giftInfo.getViewUrl());
|
||||
} else if (giftInfo.isHasVggPic() && !StringUtil.isEmpty(giftInfo.getVggUrl())) {
|
||||
drawSvgaEffect(giftInfo.getVggUrl());
|
||||
} else {
|
||||
effectHandler.sendEmptyMessage(0);
|
||||
}
|
||||
} else {
|
||||
effectHandler.sendEmptyMessage(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawSvgaEffect(String url) throws MalformedURLException {
|
||||
if (!AvRoomDataManager.get().mIsNeedGiftEffect ||
|
||||
AvRoomDataManager.get().isSelfGamePlaying()) {
|
||||
return;
|
||||
private void drawSvgaEffect(String url) {
|
||||
log("drawSvgaEffect url:" + url);
|
||||
String filePath = PathHelper.INSTANCE.generateResourcesFilePath(url);
|
||||
DownloadRequest request = DownloadRequest.Companion.build(url, filePath, DOWNLOAD_TAG, null, 60000L);
|
||||
DownloadManager.INSTANCE.download(request, new FileDownloadListener() {
|
||||
@Override
|
||||
public void onDownloadCompleted(@NonNull DownloadTask task) {
|
||||
String path = task.getRequest().getPath();
|
||||
log("drawSvgaEffect onDownloadCompleted url:" + url + " path:" + path);
|
||||
drawSvgaEffectFile(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadError(@NonNull DownloadException exception) {
|
||||
log("drawSvgaEffect onDownloadError url:" + url);
|
||||
effectHandler.sendEmptyMessage(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void drawSvgaEffectFile(String path) {
|
||||
try {
|
||||
log("drawSvgaEffectFile path:" + path);
|
||||
BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(path));
|
||||
SVGAParser.Companion.shareParser().decodeFromInputStream(inputStream, path, parseCompletion, true, null, null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
effectHandler.sendEmptyMessage(0);
|
||||
}
|
||||
SVGAParser.Companion.shareParser().decodeFromURL(new URL(url), new SVGAParser.ParseCompletion() {
|
||||
@Override
|
||||
public void onComplete(@Nullable SVGAVideoEntity videoItem) {
|
||||
SVGADrawable drawable = new SVGADrawable(videoItem);
|
||||
svgaImageView.setImageDrawable(drawable);
|
||||
svgaImageView.startAnimation();
|
||||
svgaBg.setVisibility(VISIBLE);
|
||||
ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(svgaBg, "alpha", 0.0F, 2.0F).setDuration(1250);
|
||||
objectAnimator1.setInterpolator(new AccelerateDecelerateInterpolator());
|
||||
objectAnimator1.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
|
||||
}
|
||||
}, null);
|
||||
|
||||
}
|
||||
|
||||
private void drawVAPEffect(String url) {
|
||||
if (!AvRoomDataManager.get().mIsNeedGiftEffect || AvRoomDataManager.get().isSelfGamePlaying()) {
|
||||
return;
|
||||
}
|
||||
ImageLoadKt.loadAnim(vapAnimView, url);
|
||||
log("drawVAPEffect url:" + url);
|
||||
String filePath = PathHelper.INSTANCE.generateResourcesFilePath(url);
|
||||
DownloadRequest request = DownloadRequest.Companion.build(url, filePath, DOWNLOAD_TAG, null, 60000L);
|
||||
DownloadManager.INSTANCE.download(request, new FileDownloadListener() {
|
||||
@Override
|
||||
public void onDownloadCompleted(@NonNull DownloadTask task) {
|
||||
String path = task.getRequest().getPath();
|
||||
log("drawVAPEffect onDownloadCompleted url:" + url + " path:" + path);
|
||||
vapAnimView.startPlay(new File(path));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadError(@NonNull DownloadException exception) {
|
||||
log("drawVAPEffect onDownloadError url:" + url);
|
||||
exception.printStackTrace();
|
||||
effectHandler.sendEmptyMessageDelayed(0, 4000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void deleteAnim() {
|
||||
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(container, "translationX", container.getX(), ResolutionUtils.getScreenWidth(getContext())).setDuration(1250);
|
||||
objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
|
||||
objectAnimator.start();
|
||||
|
||||
ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(container, "alpha", 1.0F, 0.0F).setDuration(1250);
|
||||
objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
|
||||
objectAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
super.onAnimationEnd(animation);
|
||||
if (isHideCarEffect) {
|
||||
isHideCarEffect = false;
|
||||
IMNetEaseManager.get().noticeRoomEvent(null, RoomEvent.ROOM_CAR_EFFECT_SHOW);
|
||||
}
|
||||
if (giftEffectListener != null) {
|
||||
isAnim = false;
|
||||
isPlayAnim = false;
|
||||
giftEffectListener.onGiftEffectEnd();
|
||||
}
|
||||
}
|
||||
});
|
||||
objectAnimator1.start();
|
||||
if (isHideCarEffect) {
|
||||
isHideCarEffect = false;
|
||||
IMNetEaseManager.get().noticeRoomEvent(null, RoomEvent.ROOM_CAR_EFFECT_SHOW);
|
||||
}
|
||||
svgaBg.setVisibility(GONE);
|
||||
isAnim = false;
|
||||
isPlayAnim = false;
|
||||
if (giftEffectListener != null) {
|
||||
giftEffectListener.onGiftEffectEnd();
|
||||
}
|
||||
}
|
||||
|
||||
public void release() {
|
||||
log("release");
|
||||
DownloadManager.INSTANCE.stopTag(DOWNLOAD_TAG);
|
||||
effectHandler.removeMessages(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinished() {
|
||||
svgaBg.setVisibility(GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRepeat() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStep(int i, double v) {
|
||||
|
||||
}
|
||||
|
||||
public interface GiftEffectListener {
|
||||
void onGiftEffectEnd();
|
||||
}
|
||||
@@ -246,4 +299,8 @@ public class GiftEffectView extends RelativeLayout implements SVGACallback {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void log(String message) {
|
||||
LogUtil.INSTANCE.d("GiftEffectView", message, false);
|
||||
}
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.example.lib_utils.UiUtils;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
import com.opensource.svgaplayer.SVGACallback;
|
||||
@@ -91,6 +92,8 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
private Keyframe[] keyTrans;
|
||||
private SvgaObjectPool mMagicViewPool;
|
||||
|
||||
private boolean isRTL = false;
|
||||
|
||||
public GiftV2View(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
@@ -106,6 +109,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
|
||||
private void init(Context context) {
|
||||
this.context = context;
|
||||
isRTL = UiUtils.INSTANCE.isRtl(context);
|
||||
mSVGAParser = new SVGAParser(context);
|
||||
mSVGAVideoEntityMap = new HashMap<>(20);
|
||||
LayoutInflater.from(getContext()).inflate(R.layout.layout_gift_v2_view, this, true);
|
||||
@@ -249,7 +253,6 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
LogUtil.print("gift micViewPoint is null");
|
||||
continue;
|
||||
}
|
||||
|
||||
Point senderPoint = micViewPoint.get(senderPosition);
|
||||
Point receivePoint = micViewPoint.get(receivePosition);
|
||||
//设置动画结束的位置
|
||||
@@ -272,7 +275,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
}
|
||||
GiftReceiveInfo giftReceiveInfo = giftReceiveInfos.get(0);
|
||||
GiftInfo giftInfo = giftReceiveInfo.getGift();
|
||||
if (totalCoin >= 520 || (giftInfo != null && giftInfo.isHasEffect())) {
|
||||
if (giftInfo != null && giftInfo.isEffectGift()) {
|
||||
Message msg = Message.obtain();
|
||||
msg.what = 0;
|
||||
GiftEffectInfo giftEffectInfo = new GiftEffectInfo();
|
||||
@@ -361,7 +364,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
targetUsers.add(giftReceiver);
|
||||
if (!isShowAnimation) return;
|
||||
giftInfo = giftReceiveInfo.getDisplayGift().get(pos);
|
||||
if (giftInfo != null && giftInfo.isHasEffect()) {
|
||||
if (giftInfo != null && giftInfo.isEffectGift()) {
|
||||
Message msg = Message.obtain();
|
||||
msg.what = 0;
|
||||
GiftEffectInfo giftEffectInfo = new GiftEffectInfo();
|
||||
@@ -651,6 +654,11 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
Keyframe keyTransX3 = (Keyframe.ofFloat(0.5f, center.x - senderPoint.x - giftWidth / 2));
|
||||
Keyframe keyTransX4 = (Keyframe.ofFloat(0.8f, center.x - senderPoint.x - giftWidth / 2));
|
||||
Keyframe keyTransX5 = (Keyframe.ofFloat(1f, receivePoint.x - senderPoint.x));
|
||||
if (isRTL) {
|
||||
keyTransX3 = (Keyframe.ofFloat(0.5f, senderPoint.x - center.x + giftWidth / 2));
|
||||
keyTransX4 = (Keyframe.ofFloat(0.8f, senderPoint.x - center.x + giftWidth / 2));
|
||||
keyTransX5 = (Keyframe.ofFloat(1f, senderPoint.x - receivePoint.x));
|
||||
}
|
||||
|
||||
Keyframe keyTransY3 = (Keyframe.ofFloat(0.5f, center.y - senderPoint.y - giftHeight / 2));
|
||||
Keyframe keyTransY4 = (Keyframe.ofFloat(0.8f, center.y - senderPoint.y - giftHeight / 2));
|
||||
@@ -842,10 +850,12 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
|
||||
private static class SvgaObjectPool extends ObjectPool<SVGAImageView> {
|
||||
private WeakReference<GiftV2View> mReference;
|
||||
private boolean isRTL = false;
|
||||
|
||||
SvgaObjectPool(GiftV2View giftV2View) {
|
||||
super();
|
||||
mReference = new WeakReference<>(giftV2View);
|
||||
isRTL = UiUtils.INSTANCE.isRtl(giftV2View.getContext());
|
||||
}
|
||||
|
||||
private SVGAImageView cleanView(SVGAImageView imageView) {
|
||||
@@ -875,7 +885,11 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
SVGAImageView imageView = cleanView(super.borrowObject());
|
||||
LayoutParams params = new LayoutParams(parent.giftWidth, parent.giftHeight);
|
||||
imageView.setLayoutParams(params);
|
||||
params.leftMargin = senderPoint.x;
|
||||
if (isRTL) {
|
||||
params.rightMargin = senderPoint.x;
|
||||
}else{
|
||||
params.leftMargin = senderPoint.x;
|
||||
}
|
||||
params.topMargin = senderPoint.y;
|
||||
imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
if (parent.indexOfChild(imageView) == -1)
|
||||
@@ -896,7 +910,11 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
SVGAImageView imageView = cleanView(super.borrowObject());
|
||||
LayoutParams params = new LayoutParams(parent.giftWidth, parent.giftHeight);
|
||||
imageView.setLayoutParams(params);
|
||||
params.leftMargin = senderPoint.x;
|
||||
if (isRTL) {
|
||||
params.rightMargin = senderPoint.x;
|
||||
}else{
|
||||
params.leftMargin = senderPoint.x;
|
||||
}
|
||||
params.topMargin = senderPoint.y;
|
||||
imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
imageView.setScaleX(1.5F);
|
||||
|
@@ -4,6 +4,7 @@ import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAIRY;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GIFT_COMPOUND;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_RED_PACKAGE;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ROOM_ALBUM;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ROOM_TEMPLATE;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ME;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_CONVERT_L1;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_CONVERT_L2;
|
||||
@@ -18,6 +19,7 @@ import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_
|
||||
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_FANS_TEAM_JOIN;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_GIFT_COMPOUND;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUPER_LUCKY_GIFT_TEMPLATE;
|
||||
import static com.chwl.core.redpackage.RedPackageTypeKt.ALL_DIAMOND;
|
||||
import static com.chwl.core.redpackage.RedPackageTypeKt.ALL_GIFT;
|
||||
import static com.chwl.core.redpackage.RedPackageTypeKt.ROOM_DIAMOND;
|
||||
@@ -58,9 +60,12 @@ import androidx.recyclerview.widget.SimpleItemAnimator;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.chwl.app.photo.BigPhotoActivity;
|
||||
import com.chwl.app.photo.PagerOption;
|
||||
import com.chwl.app.ui.widget.TextSpannableBuilder;
|
||||
import com.chwl.app.utils.ObjectTypeHelper;
|
||||
import com.chwl.core.im.custom.bean.TemplateMessageAttachment;
|
||||
import com.chwl.core.monsterhunting.bean.MonsterDataBean;
|
||||
import com.chwl.core.utils.extension.StringExtensionKt;
|
||||
import com.example.lib_utils.UiUtils;
|
||||
import com.netease.nim.uikit.business.uinfo.UserInfoHelper;
|
||||
import com.netease.nim.uikit.common.ui.span.RadiusBackgroundSpan;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
@@ -252,6 +257,7 @@ public class MessageView extends FrameLayout {
|
||||
private OnClick onClick;
|
||||
|
||||
private OnMsgLongClickListener onLongClickListener;
|
||||
private TemplateMessageAdapter templateMessageAdapter;
|
||||
|
||||
public MessageView(Context context) {
|
||||
this(context, null);
|
||||
@@ -265,7 +271,6 @@ public class MessageView extends FrameLayout {
|
||||
super(context, attr, i);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public void setOnLongClickListener(OnMsgLongClickListener onLongClickListener) {
|
||||
this.onLongClickListener = onLongClickListener;
|
||||
}
|
||||
@@ -335,19 +340,6 @@ public class MessageView extends FrameLayout {
|
||||
messageListView.getItemAnimator().setMoveDuration(0);
|
||||
messageListView.getItemAnimator().setRemoveDuration(0);
|
||||
((SimpleItemAnimator) messageListView.getItemAnimator()).setSupportsChangeAnimations(false);
|
||||
if (AvRoomDataManager.get().isOpenGame()) {
|
||||
messageListView.setOnTouchListener((v, event) -> {
|
||||
if (messageListView.getScrollState() == RecyclerView.SCROLL_STATE_IDLE
|
||||
&& event.getAction() == MotionEvent.ACTION_UP) {
|
||||
ViewGroup.LayoutParams layoutParams = getLayoutParams();
|
||||
int bigHeight = ScreenUtil.dip2px(200);
|
||||
int littleHeight = ScreenUtil.dip2px(80);
|
||||
layoutParams.height = layoutParams.height == littleHeight ? bigHeight : littleHeight;
|
||||
setLayoutParams(layoutParams);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
// 底部有新消息
|
||||
tvBottomTip = new TextView(context);
|
||||
@@ -435,6 +427,17 @@ public class MessageView extends FrameLayout {
|
||||
|
||||
}
|
||||
|
||||
private TemplateMessageAdapter getTemplateMessageAdapter() {
|
||||
if (templateMessageAdapter == null) {
|
||||
templateMessageAdapter = new TemplateMessageAdapter(uid -> {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(String.valueOf(uid)).subscribe(clickConsumer);
|
||||
}
|
||||
});
|
||||
}
|
||||
return templateMessageAdapter;
|
||||
}
|
||||
|
||||
public void onCurrentRoomReceiveNewMsg(List<ChatRoomMessage> messages) {
|
||||
if (messages == null) return;
|
||||
if (messages.size() == 1) {
|
||||
@@ -568,6 +571,10 @@ public class MessageView extends FrameLayout {
|
||||
this.needAutoScroll = needAutoScroll;
|
||||
}
|
||||
|
||||
public RecyclerView getMessageListView(){
|
||||
return messageListView;
|
||||
}
|
||||
|
||||
public interface OnClick {
|
||||
/**
|
||||
* 點擊關註
|
||||
@@ -584,157 +591,7 @@ public class MessageView extends FrameLayout {
|
||||
void onShowRoomIntroduction();
|
||||
|
||||
}
|
||||
|
||||
public static class SpannableBuilder {
|
||||
private SpannableStringBuilder builder;
|
||||
private TextView textView;
|
||||
|
||||
public SpannableBuilder(TextView textView) {
|
||||
builder = new SpannableStringBuilder();
|
||||
this.textView = textView;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param text 文字
|
||||
* @return -返回一個spannableStringBuilder
|
||||
*/
|
||||
public SpannableBuilder append(CharSequence text) {
|
||||
if (TextUtils.isEmpty(text)) return this;
|
||||
builder.append(text);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param drawable -icon url
|
||||
* @return -返回一個spannableStringBuilder
|
||||
*/
|
||||
public SpannableBuilder appendImg(String drawable) {
|
||||
if (TextUtils.isEmpty(drawable)) return this;
|
||||
int start = builder.length();
|
||||
builder.append("-");
|
||||
CustomImageSpan imageSpan = new CustomImageSpan(new ColorDrawable(Color.TRANSPARENT), textView, drawable);
|
||||
builder.setSpan(imageSpan, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param drawable -icon url
|
||||
* @param width 寬
|
||||
* @param height 高
|
||||
* @return -返回一個spannableStringBuilder
|
||||
*/
|
||||
public SpannableBuilder append(String drawable, int width, int height) {
|
||||
if (TextUtils.isEmpty(drawable)) return this;
|
||||
int start = builder.length();
|
||||
builder.append("-");
|
||||
CustomImageSpan imageSpan = new CustomImageSpan(new ColorDrawable(Color.TRANSPARENT), textView, drawable, width, height);
|
||||
builder.setSpan(imageSpan, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文本和背景分離的情況
|
||||
*/
|
||||
public SpannableBuilder appendBgAndContent(String drawable, String content) {
|
||||
if (TextUtils.isEmpty(drawable)) return this;
|
||||
int start = builder.length();
|
||||
builder.append("-");
|
||||
CustomImageSpan imageSpan = new CustomImageSpan(new ColorDrawable(Color.TRANSPARENT), textView, drawable, content);
|
||||
builder.setSpan(imageSpan, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param drawable -icon
|
||||
* @param width 寬
|
||||
* @param height 高
|
||||
* @return -返回一個spannableStringBuilder
|
||||
*/
|
||||
public SpannableBuilder append(Drawable drawable, int width, int height) {
|
||||
if (drawable == null) return this;
|
||||
drawable.setBounds(0, 0, width, height);
|
||||
int start = builder.length();
|
||||
builder.append("-");
|
||||
builder.setSpan(new CustomImageSpan(drawable), start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param imgUrl -icon url
|
||||
* @param height 高
|
||||
* @return -返回一個spannableStringBuilder,自適應寬度
|
||||
*/
|
||||
public SpannableBuilder append(String imgUrl, int height) {
|
||||
if (TextUtils.isEmpty(imgUrl)) return this;
|
||||
int start = builder.length();
|
||||
builder.append("-");
|
||||
builder.setSpan(new CustomAutoWidthImageSpan(new ColorDrawable(Color.TRANSPARENT), textView, imgUrl, height)
|
||||
, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param drawable -icon
|
||||
* @param width 寬
|
||||
* @param height 高
|
||||
* @return -返回一個spannableStringBuilder
|
||||
*/
|
||||
public SpannableBuilder append(Drawable drawable, int width, int height, Object... whats) {
|
||||
if (drawable == null) return this;
|
||||
try {
|
||||
drawable.setBounds(0, 0, width, height);
|
||||
int start = builder.length();
|
||||
builder.append("-");
|
||||
builder.setSpan(new CustomImageSpan(drawable), start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
if (whats != null) {
|
||||
for (int i = 0; i < whats.length; i++) {
|
||||
builder.setSpan(whats[0], start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param text -文字
|
||||
* @param what -span類型
|
||||
* @return -返回一個spannableStringBuilder
|
||||
*/
|
||||
public SpannableBuilder append(CharSequence text, Object what) {
|
||||
if (TextUtils.isEmpty(text)) return this;
|
||||
int start = builder.length();
|
||||
builder.append(text);
|
||||
builder.setSpan(what, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 支持多個spannable 對同一段文字修改
|
||||
*
|
||||
* @param text
|
||||
* @param what
|
||||
* @return
|
||||
*/
|
||||
public SpannableBuilder append(CharSequence text, Object... what) {
|
||||
if (TextUtils.isEmpty(text)) return this;
|
||||
int start = builder.length();
|
||||
builder.append(text);
|
||||
for (int i = 0; i < what.length; i++) {
|
||||
Object o = what[i];
|
||||
if (o == null) {
|
||||
continue;
|
||||
}
|
||||
builder.setSpan(what[i], start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpannableStringBuilder build() {
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class MessageAdapter extends RecyclerView.Adapter<MessageAdapter.MessageViewHolder> implements OnClickListener {
|
||||
|
||||
@@ -793,6 +650,10 @@ public class MessageView extends FrameLayout {
|
||||
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) {
|
||||
@@ -800,18 +661,18 @@ public class MessageView extends FrameLayout {
|
||||
// 房間通告
|
||||
if (ResUtil.getString(R.string.avroom_widget_messageview_03).equals(contentText)) {
|
||||
setUpdateGiftEffectMsg(tvContent);
|
||||
} else if (XConstants.ROOM_INTRODUCTION.equals(contentText) || contentText.contains(IMNetEaseManager.ROOM_INTRO_TAG)) {
|
||||
} else if (ResUtil.getString(R.string.yizhuan_xchat_android_constants_xchatconstants_08).equals(contentText) || contentText.contains(IMNetEaseManager.ROOM_INTRO_TAG)) {
|
||||
tvContent.setTextColor(ContextCompat.getColor(mContext, R.color.white));
|
||||
tvContent.setText(contentText);
|
||||
} else if (XConstants.DATING_TIPS_OPEN.equals(contentText) ||
|
||||
contentText.contains(XConstants.DATING_TIPS_IN) ||
|
||||
contentText.contains(XConstants.DATING_TIPS_NEW) ||
|
||||
contentText.contains(XConstants.DATING_TIPS_PUBLIC)) {
|
||||
} else if (ResUtil.getString(R.string.yizhuan_xchat_android_constants_xchatconstants_09).equals(contentText) ||
|
||||
contentText.contains(ResUtil.getString(R.string.yizhuan_xchat_android_constants_xchatconstants_011)) ||
|
||||
contentText.contains(ResUtil.getString(R.string.yizhuan_xchat_android_constants_xchatconstants_010)) ||
|
||||
contentText.contains(ResUtil.getString(R.string.yizhuan_xchat_android_constants_xchatconstants_012))) {
|
||||
//相親模式提示文案用特殊的顏色
|
||||
tvContent.setTextColor(ContextCompat.getColor(mContext, R.color.color_fe5d7f));
|
||||
tvContent.setText(contentText);
|
||||
} else {
|
||||
tvContent.setTextColor(ContextCompat.getColor(mContext, R.color.color_92F9E8));
|
||||
tvContent.setTextColor(ContextCompat.getColor(mContext, R.color.color_white));
|
||||
tvContent.setText(chatRoomMessage.getContent());
|
||||
tvContent.setBackgroundResource(R.drawable.shape_room_message_tip_bg);
|
||||
}
|
||||
@@ -1031,6 +892,20 @@ public class MessageView extends FrameLayout {
|
||||
setFairyMsg(chatRoomMessage, tvContent);
|
||||
} else if (first == CUSTOM_MSG_ROOM_ALBUM) {
|
||||
setRoomAlbumMsg(chatRoomMessage, baseViewHolder);
|
||||
} else if (first == CUSTOM_MSG_ROOM_TEMPLATE) {
|
||||
TemplateMessageAttachment templateMessageAttachment = (TemplateMessageAttachment) chatRoomMessage.getAttachment();
|
||||
if (templateMessageAttachment != null) {
|
||||
getTemplateMessageAdapter().convert(tvContent, templateMessageAttachment.getTemplateMessage());
|
||||
} else {
|
||||
getTemplateMessageAdapter().convert(tvContent, null);
|
||||
}
|
||||
} else if (first == CUSTOM_MSG_SUPER_LUCKY_GIFT_TEMPLATE) {
|
||||
TemplateMessageAttachment templateMessageAttachment = (TemplateMessageAttachment) chatRoomMessage.getAttachment();
|
||||
if (templateMessageAttachment != null) {
|
||||
getTemplateMessageAdapter().convert(tvContent, templateMessageAttachment.getTemplateMessage());
|
||||
} else {
|
||||
getTemplateMessageAdapter().convert(tvContent, null);
|
||||
}
|
||||
} else {
|
||||
tvContent.setTextColor(Color.WHITE);
|
||||
tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip));
|
||||
@@ -1146,7 +1021,7 @@ public class MessageView extends FrameLayout {
|
||||
FairyMsgAttachment attachment = (FairyMsgAttachment) chatRoomMessage.getAttachment();
|
||||
FairyMsgInfoBean fairyMsgInfo = attachment.getFairyMsgInfo();
|
||||
if (fairyMsgInfo == null) return;
|
||||
SpannableBuilder builder = null;
|
||||
TextSpannableBuilder builder = null;
|
||||
switch (attachment.getSecond()) {
|
||||
case CUSTOM_MSG_SUB_DRAW_GIFT_L1:
|
||||
case CUSTOM_MSG_SUB_DRAW_GIFT_L2:
|
||||
@@ -1188,8 +1063,8 @@ public class MessageView extends FrameLayout {
|
||||
|
||||
}
|
||||
|
||||
private SpannableBuilder builderConvertMsg(TextView textView, @NonNull FairyMsgInfoBean fairyMsgInfo, String type) {
|
||||
return new SpannableBuilder(textView)
|
||||
private TextSpannableBuilder builderConvertMsg(TextView textView, @NonNull FairyMsgInfoBean fairyMsgInfo, String type) {
|
||||
return new TextSpannableBuilder(textView)
|
||||
.append("厲害了!", new ForegroundColorSpan(whiteColor))
|
||||
.append(StringExtensionKt.subAndReplaceDot(fairyMsgInfo.getNick(), 7), new OriginalDrawStatusClickSpan(roomTipNickColor, false) {
|
||||
|
||||
@@ -1202,8 +1077,8 @@ public class MessageView extends FrameLayout {
|
||||
.append(fairyMsgInfo.getRewardShowValue() + "鉆" + fairyMsgInfo.getRewardName(), new ForegroundColorSpan(roomTipColor));
|
||||
}
|
||||
|
||||
private SpannableBuilder builderDrawMsg(TextView textView, @NonNull FairyMsgInfoBean fairyMsgInfo, String desc) {
|
||||
SpannableBuilder builder = new SpannableBuilder(textView)
|
||||
private TextSpannableBuilder builderDrawMsg(TextView textView, @NonNull FairyMsgInfoBean fairyMsgInfo, String desc) {
|
||||
TextSpannableBuilder builder = new TextSpannableBuilder(textView)
|
||||
.append(desc, new ForegroundColorSpan(whiteColor))
|
||||
.append(StringExtensionKt.subAndReplaceDot(fairyMsgInfo.getNick(), 7), new OriginalDrawStatusClickSpan(roomTipNickColor, false) {
|
||||
|
||||
@@ -1226,7 +1101,7 @@ public class MessageView extends FrameLayout {
|
||||
GiftCompoundAttachment giftCompoundAttachment = (GiftCompoundAttachment) chatRoomMessage.getAttachment();
|
||||
if (giftCompoundAttachment.getSecond() == CUSTOM_MSG_SUB_GIFT_COMPOUND) {
|
||||
GiftCompoundMsgBean msgInfo = giftCompoundAttachment.getMsgBean();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent);
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent);
|
||||
text.append(
|
||||
msgInfo.getNick(),
|
||||
new ForegroundColorSpan(roomTipNickColor),
|
||||
@@ -1257,7 +1132,7 @@ public class MessageView extends FrameLayout {
|
||||
FansTeamMsgAttachment fansTeamMsgAttachment = (FansTeamMsgAttachment) chatRoomMessage.getAttachment();
|
||||
if (fansTeamMsgAttachment.getSecond() == CUSTOM_MSG_SUB_FANS_TEAM_JOIN) {
|
||||
FansTeamMsgInfo msgInfo = fansTeamMsgAttachment.getFansTeamMsgInfo();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent);
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent);
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_04), new ForegroundColorSpan(whiteColor))
|
||||
.append(msgInfo.getNickname(), new ForegroundColorSpan(roomTipNickColor),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
@@ -1285,7 +1160,7 @@ public class MessageView extends FrameLayout {
|
||||
if (chatRoomMessage.getAttachment() instanceof VipMessageAttachment) {
|
||||
VipMessageAttachment datingAttachment = (VipMessageAttachment) chatRoomMessage.getAttachment();
|
||||
VipMessageInfo notifyInfo = datingAttachment.getVipMessageInfo();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent);
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent);
|
||||
int second = datingAttachment.getSecond();
|
||||
switch (second) {
|
||||
case CustomAttachment.CUSTOM_MSG_VIP_ROOM_OPEN:
|
||||
@@ -1334,7 +1209,7 @@ public class MessageView extends FrameLayout {
|
||||
if (attachment.getSecond() == CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY) {
|
||||
LuckyBagNoticeInfo noticeInfo = attachment.getLuckyBagNoticeInfo();
|
||||
String nickName = RegexUtil.getPrintableString(noticeInfo.getNick());
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_011), new ForegroundColorSpan(textColor))
|
||||
.append(nickName, new ForegroundColorSpan(roomTipNickColor))
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_012), new ForegroundColorSpan(textColor))
|
||||
@@ -1351,7 +1226,7 @@ public class MessageView extends FrameLayout {
|
||||
if (chatRoomMessage.getAttachment() instanceof DatingAttachment) {
|
||||
DatingAttachment datingAttachment = (DatingAttachment) chatRoomMessage.getAttachment();
|
||||
DatingNotifyInfo notifyInfo = datingAttachment.getDatingNotifyInfo();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent);
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent);
|
||||
switch (second) {
|
||||
case CustomAttachment.CUSTOM_MSG_SUB_DATING_SELECT:
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_015), new ForegroundColorSpan(whiteColor))
|
||||
@@ -1445,7 +1320,7 @@ public class MessageView extends FrameLayout {
|
||||
TarotAttachment attachment = (TarotAttachment) chatRoomMessage.getAttachment();
|
||||
TarotMsgBean tarotMsgBean = attachment.getTarotMsgBean();
|
||||
String nickName = RegexUtil.getPrintableString(tarotMsgBean.getNick());
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent);
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent);
|
||||
switch (attachment.getSecond()) {
|
||||
case CustomAttachment.CUSTOM_MESS_TAROT_SUCCESS:
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_026), new ForegroundColorSpan(textColor))
|
||||
@@ -1480,7 +1355,7 @@ public class MessageView extends FrameLayout {
|
||||
JoinMiniWorldNoticeAttachment joinMiniWorldNoticeAttachment = (JoinMiniWorldNoticeAttachment) chatRoomMessage.getAttachment();
|
||||
String nick = TextUtils.isEmpty(joinMiniWorldNoticeAttachment.getNick()) ? "" : joinMiniWorldNoticeAttachment.getNick();
|
||||
String worldName = TextUtils.isEmpty(joinMiniWorldNoticeAttachment.getWorldName()) ? "" : joinMiniWorldNoticeAttachment.getWorldName();
|
||||
SpannableBuilder append = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder append = new TextSpannableBuilder(tvContent)
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_028))
|
||||
.append(" " + nick + " ", new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
@@ -1509,7 +1384,7 @@ public class MessageView extends FrameLayout {
|
||||
RedEnvelopeRoomMsg roomMsg = attachment.getRedEnvelopeRoomMsg();
|
||||
String openNickname = RegexUtil.getPrintableString(roomMsg.getOpenRedEnvelopeUserNick());
|
||||
String sendNickname = RegexUtil.getPrintableString(roomMsg.getRedEnvelopeMasterNick());
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(openNickname, new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@Override
|
||||
@@ -1532,13 +1407,13 @@ public class MessageView extends FrameLayout {
|
||||
case ALL_DIAMOND:
|
||||
case ROOM_DIAMOND:
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_031), new ForegroundColorSpan(textColor))
|
||||
.append((int) roomMsg.getAmount() + ResUtil.getString(R.string.avroom_widget_messageview_032), new ForegroundColorSpan(roomTipColor));
|
||||
.append((int) roomMsg.getAmount() + ResUtil.getString(R.string.avroom_widget_messageview_027), new ForegroundColorSpan(roomTipColor));
|
||||
tvContent.setText(text.build());
|
||||
break;
|
||||
case ALL_GIFT:
|
||||
case ROOM_GIFT:
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_033), new ForegroundColorSpan(textColor))
|
||||
.append((int) roomMsg.getAmount() + ResUtil.getString(R.string.avroom_widget_messageview_034), new ForegroundColorSpan(roomTipColor))
|
||||
.append((int) roomMsg.getAmount() + ResUtil.getString(R.string.avroom_widget_messageview_027), new ForegroundColorSpan(roomTipColor))
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_035), new ForegroundColorSpan(textColor));
|
||||
tvContent.setText(text.build());
|
||||
}
|
||||
@@ -1589,7 +1464,7 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
|
||||
boolean follow = roomFollowOwnerAttachment.isFollow();
|
||||
SpannableBuilder append = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder append = new TextSpannableBuilder(tvContent)
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_036))
|
||||
.append(" " + nick + " ", new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
@@ -1624,7 +1499,7 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
tvContent.setTextColor(Color.WHITE);
|
||||
RoomFollowOwnerAttachment2 roomFollowOwnerAttachment = (RoomFollowOwnerAttachment2) chatRoomMessage.getAttachment();
|
||||
SpannableBuilder append = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder append = new TextSpannableBuilder(tvContent)
|
||||
.append(mContext.getResources().getDrawable(R.drawable.bg_follow), ScreenUtil.dip2px(190), ScreenUtil.dip2px(40));
|
||||
tvContent.setText(append.build());
|
||||
}
|
||||
@@ -1632,7 +1507,7 @@ public class MessageView extends FrameLayout {
|
||||
private void invitePK(RoomPkAttachment attachment, TextView tvContent) {
|
||||
Map<String, RoomPKInvitedUpMicMember> micMemberMap = attachment.getRoomPKInvitedUpMicMemberMap();
|
||||
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_041));
|
||||
boolean isHaveInTeam = false;
|
||||
Iterator<Map.Entry<String, RoomPKInvitedUpMicMember>> iterator = micMemberMap.entrySet().iterator();
|
||||
@@ -1676,7 +1551,7 @@ public class MessageView extends FrameLayout {
|
||||
|
||||
private void openRoomPKModeMsg(RoomPkAttachment attachment, TextView tvContent) {
|
||||
RoomPkData roomPkData = attachment.getRoomPkData();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(String.format(Locale.getDefault(), ResUtil.getString(R.string.avroom_widget_messageview_046),
|
||||
roomPkData.getDuration()),
|
||||
new ForegroundColorSpan(whiteColor));
|
||||
@@ -1694,7 +1569,7 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
|
||||
private void stopRoomPkModeMsg(TextView tvContent) {
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_050), new ForegroundColorSpan(whiteColor))
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_051), new ForegroundColorSpan(greyColor))
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_052), new ForegroundColorSpan(whiteColor));
|
||||
@@ -1703,7 +1578,7 @@ public class MessageView extends FrameLayout {
|
||||
|
||||
private void startRoomPk(RoomPkAttachment attachment, TextView textView) {
|
||||
RoomPkData roomPkData = attachment.getRoomPkData();
|
||||
SpannableBuilder text = new SpannableBuilder(textView)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(textView)
|
||||
.append(String.format(Locale.getDefault(),
|
||||
ResUtil.getString(R.string.avroom_widget_messageview_053), roomPkData.getDuration()),
|
||||
new ForegroundColorSpan(greyColor));
|
||||
@@ -1712,7 +1587,7 @@ public class MessageView extends FrameLayout {
|
||||
|
||||
private void restartRoomPKModeMsg(RoomPkAttachment attachment, TextView tvContent) {
|
||||
RoomPkData roomPkData = attachment.getRoomPkData();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(String.format(Locale.getDefault(), ResUtil.getString(R.string.avroom_widget_messageview_054),
|
||||
roomPkData.getDuration()),
|
||||
new ForegroundColorSpan(whiteColor));
|
||||
@@ -1731,7 +1606,7 @@ public class MessageView extends FrameLayout {
|
||||
|
||||
private void roomPkResult(RoomPkAttachment attachment, TextView textView) {
|
||||
RoomPkData roomPkData = attachment.getRoomPkData();
|
||||
SpannableBuilder text = new SpannableBuilder(textView)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(textView)
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_058), new ForegroundColorSpan(whiteColor));
|
||||
Map<String, PKTeamInfo> teamMap = new HashMap<>();
|
||||
PKTeamInfo blueTeam = null;
|
||||
@@ -1823,7 +1698,7 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
|
||||
private void startQueuingMicModeMsg(TextView tvContent) {
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_075), new ForegroundColorSpan(whiteColor))
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_076), new ForegroundColorSpan(greyColor))
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_077), new ForegroundColorSpan(whiteColor));
|
||||
@@ -1831,7 +1706,7 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
|
||||
private void stopQueuingMicModeMsg(TextView tvContent) {
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_078), new ForegroundColorSpan(whiteColor))
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_079), new ForegroundColorSpan(greyColor))
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_080), new ForegroundColorSpan(whiteColor));
|
||||
@@ -1841,7 +1716,7 @@ public class MessageView extends FrameLayout {
|
||||
private void switchToFreeMicMsg(TextView tvContent, ChatRoomMessage chatRoomMessage) {
|
||||
QueuingMicAttachment attachment = (QueuingMicAttachment) chatRoomMessage.getAttachment();
|
||||
QueuingMicInfo queuingMicInfo = attachment.getQueuingMicInfo();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_081), new ForegroundColorSpan(whiteColor))
|
||||
.append(String.format(Locale.getDefault(), ResUtil.getString(R.string.avroom_widget_messageview_082),
|
||||
JavaUtil.str2int(queuingMicInfo.getMicPos()) + 1), new ForegroundColorSpan(greyColor))
|
||||
@@ -1852,7 +1727,7 @@ public class MessageView extends FrameLayout {
|
||||
private void switchToLockMicMsg(TextView tvContent, ChatRoomMessage chatRoomMessage) {
|
||||
QueuingMicAttachment attachment = (QueuingMicAttachment) chatRoomMessage.getAttachment();
|
||||
QueuingMicInfo queuingMicInfo = attachment.getQueuingMicInfo();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_084), new ForegroundColorSpan(whiteColor))
|
||||
.append(String.format(Locale.getDefault(), ResUtil.getString(R.string.avroom_widget_messageview_085),
|
||||
JavaUtil.str2int(queuingMicInfo.getMicPos()) + 1), new ForegroundColorSpan(greyColor))
|
||||
@@ -1862,7 +1737,7 @@ public class MessageView extends FrameLayout {
|
||||
|
||||
private void setDragonBarRunawayMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) {
|
||||
ChatRoomMessageExtension extension = chatRoomMessage.getChatRoomMessageExtension();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(extension == null ? ResUtil.getString(R.string.avroom_widget_messageview_087) : RegexUtil.getPrintableString(extension.getSenderNick()), new ForegroundColorSpan(Color.WHITE),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@@ -1881,7 +1756,7 @@ public class MessageView extends FrameLayout {
|
||||
|
||||
private void setDragonBarCancelMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) {
|
||||
ChatRoomMessageExtension extension = chatRoomMessage.getChatRoomMessageExtension();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(extension == null ? ResUtil.getString(R.string.avroom_widget_messageview_089) : RegexUtil.getPrintableString(extension.getSenderNick()), new ForegroundColorSpan(Color.WHITE),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@@ -1911,7 +1786,7 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
msg = msg.substring(0, msg.length() - 1);
|
||||
// 內容
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(extension == null ? ResUtil.getString(R.string.avroom_widget_messageview_091) : RegexUtil.getPrintableString(extension.getSenderNick()), new ForegroundColorSpan(Color.WHITE),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@@ -1933,16 +1808,16 @@ public class MessageView extends FrameLayout {
|
||||
private void setBoxMeMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) {
|
||||
RoomBoxPrizeAttachment attachment = (RoomBoxPrizeAttachment) chatRoomMessage.getAttachment();
|
||||
// 內容
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_093), new ForegroundColorSpan(greyColor))
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append("厲害了 ", new ForegroundColorSpan(greyColor))
|
||||
.append(attachment.getNick() + " ", new ForegroundColorSpan(roomTipColor))
|
||||
.append(ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(R.string.avroom_widget_messageview_095), new ForegroundColorSpan(greyColor))
|
||||
.append("通過歡樂砸蛋" + "獲得 ", new ForegroundColorSpan(greyColor))
|
||||
.append(attachment.getPrizeName(), new ForegroundColorSpan(Color.WHITE));
|
||||
if (attachment.getPrizeNum() > 1) {
|
||||
text.append(" x" + attachment.getPrizeNum() + " ", new ForegroundColorSpan(roomTipColor));
|
||||
}
|
||||
if (attachment.getSecond() == CUSTOM_MSG_SUB_BOX_ME) {
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_096), new ForegroundColorSpan(Color.WHITE));
|
||||
text.append("(僅自己可見)", new ForegroundColorSpan(Color.WHITE));
|
||||
}
|
||||
tvContent.setText(text.build());
|
||||
}
|
||||
@@ -1951,7 +1826,7 @@ public class MessageView extends FrameLayout {
|
||||
RoomLuckySeaAttachment attachment = (RoomLuckySeaAttachment) chatRoomMessage.getAttachment();
|
||||
RoomLuckySeaMsgBean bean = attachment.getRoomLuckySeaMsgInfo();
|
||||
// 內容
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(ResUtil.getString(R.string.congratulation), new ForegroundColorSpan(greyColor))
|
||||
.append(bean.getNick(), new ForegroundColorSpan(roomTipNickColor),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
@@ -1990,7 +1865,7 @@ public class MessageView extends FrameLayout {
|
||||
private void setRadishMeMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) {
|
||||
RoomBoxPrizeAttachment attachment = (RoomBoxPrizeAttachment) chatRoomMessage.getAttachment();
|
||||
// 內容
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_097), new ForegroundColorSpan(greyColor))
|
||||
.append(attachment.getNick() + " ", new ForegroundColorSpan(roomTipColor))
|
||||
.append(attachment.getBoxTypeStr() + ResUtil.getString(R.string.avroom_widget_messageview_098), new ForegroundColorSpan(greyColor))
|
||||
@@ -2002,21 +1877,21 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
|
||||
private void setUpdateAudioMsg(TextView tvContent) {
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_099), new ForegroundColorSpan(roomTipColor))
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0100), new ForegroundColorSpan(greyColor));
|
||||
tvContent.setText(text.build());
|
||||
}
|
||||
|
||||
private void setUpdateGiftEffectMsg(TextView tvContent) {
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0101), new ForegroundColorSpan(roomTipColor))
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0102), new ForegroundColorSpan(greyColor));
|
||||
tvContent.setText(text.build());
|
||||
}
|
||||
|
||||
private void setUpdateScreenMsg(TextView tvContent, String contentText) {
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0103), new ForegroundColorSpan(roomTipColor))
|
||||
.append(contentText, new ForegroundColorSpan(greyColor));
|
||||
tvContent.setText(text.build());
|
||||
@@ -2025,7 +1900,7 @@ public class MessageView extends FrameLayout {
|
||||
private void setUpdateRoomPureModeMsg(TextView tvContent, IMMessage message) {
|
||||
RoomNoticeAttachment attachment = (RoomNoticeAttachment) message.getAttachment();
|
||||
RoomMessageViewNoticeInfo messageViewNoticeInfo = attachment.getRoomMessageViewNoticeInfo();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0104), new ForegroundColorSpan(roomTipColor))
|
||||
.append(messageViewNoticeInfo.getTips(), new ForegroundColorSpan(greyColor));
|
||||
tvContent.setText(text.build());
|
||||
@@ -2034,7 +1909,7 @@ public class MessageView extends FrameLayout {
|
||||
private void setCleanScreenMsg(TextView tvContent, IMMessage message) {
|
||||
CleanScreenAttachment attachment = (CleanScreenAttachment) message.getAttachment();
|
||||
// 內容
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(attachment.getRoleType() == 1 ? ResUtil.getString(R.string.avroom_widget_messageview_0105) : ResUtil.getString(R.string.avroom_widget_messageview_0106), new ForegroundColorSpan(Color.WHITE))
|
||||
.append("(" + attachment.getNick() + ") ", new ForegroundColorSpan(roomTipColor),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
@@ -2053,7 +1928,7 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
|
||||
private void setMonsterNotifyMessage(TextView tvContent, String notifyMessage) {
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(notifyMessage, new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.color_34D08B)));
|
||||
tvContent.setText(text.build());
|
||||
}
|
||||
@@ -2067,7 +1942,7 @@ public class MessageView extends FrameLayout {
|
||||
*/
|
||||
private void setInviteUpMicMsg(TextView tvContent, RoomQueueMsgAttachment attachment) {
|
||||
String targetNick = RegexUtil.getPrintableString(attachment.targetNick);
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0108), new ForegroundColorSpan(greyColor))
|
||||
.append(targetNick, new ForegroundColorSpan(roomTipColor))
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0109), new ForegroundColorSpan(greyColor));
|
||||
@@ -2077,7 +1952,7 @@ public class MessageView extends FrameLayout {
|
||||
private void setKickMsg(TextView tvContent, RoomQueueMsgAttachment attachment) {
|
||||
String nick = RegexUtil.getPrintableString(attachment.handleNick);
|
||||
String targetNick = RegexUtil.getPrintableString(attachment.targetNick);
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(targetNick, new ForegroundColorSpan(roomTipColor), new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@Override
|
||||
@@ -2106,7 +1981,7 @@ public class MessageView extends FrameLayout {
|
||||
private void setKickRoomMsg(TextView tvContent, RoomQueueMsgAttachment attachment) {
|
||||
String nick = RegexUtil.getPrintableString(attachment.handleNick);
|
||||
String targetNick = RegexUtil.getPrintableString(attachment.targetNick);
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(targetNick, new ForegroundColorSpan(roomTipColor), new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@Override
|
||||
@@ -2135,7 +2010,7 @@ public class MessageView extends FrameLayout {
|
||||
private void setAddBlackMsg(TextView tvContent, RoomQueueMsgAttachment attachment) {
|
||||
String nick = RegexUtil.getPrintableString(attachment.handleNick);
|
||||
String targetNick = RegexUtil.getPrintableString(attachment.targetNick);
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(targetNick, new ForegroundColorSpan(roomTipColor), new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@Override
|
||||
@@ -2184,7 +2059,7 @@ public class MessageView extends FrameLayout {
|
||||
*/
|
||||
private void setMsgText(ChatRoomMessage chatRoomMessage, TextView tvContent) {
|
||||
ChatRoomMessageExtension extension = chatRoomMessage.getChatRoomMessageExtension();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent);
|
||||
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))
|
||||
@@ -2222,7 +2097,7 @@ public class MessageView extends FrameLayout {
|
||||
tvContent.setText(text.build());
|
||||
}
|
||||
|
||||
private void addCommonTag(ChatRoomMessage chatRoomMessage, @NonNull SpannableBuilder builder, TextView tvContent) {
|
||||
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);
|
||||
@@ -2267,7 +2142,7 @@ public class MessageView extends FrameLayout {
|
||||
String senderNick = chatRoomMessage.getChatRoomMessageExtension().getSenderNick();
|
||||
senderNick = senderNick == null ? "" : senderNick;
|
||||
AuctionAttachment auctionAttachment = (AuctionAttachment) attachment;
|
||||
SpannableBuilder builder = new SpannableBuilder(tvContent);
|
||||
TextSpannableBuilder builder = new TextSpannableBuilder(tvContent);
|
||||
if (attachment.getSecond() == CustomAttachment.CUSTOM_MSG_SUB_TYPE_AUCTION_START) {
|
||||
builder.append(ResUtil.getString(R.string.avroom_widget_messageview_0117), new ForegroundColorSpan(roomTipNickColor));
|
||||
} else if (attachment.getSecond() == CustomAttachment.CUSTOM_MSG_SUB_TYPE_AUCTION_FINISH) {
|
||||
@@ -2281,7 +2156,7 @@ public class MessageView extends FrameLayout {
|
||||
builder.append(ResUtil.getString(R.string.avroom_widget_messageview_0120), new ForegroundColorSpan(roomTipNickColor));
|
||||
} else {
|
||||
builder.append(senderNick, new ForegroundColorSpan(roomTipNickColor))
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0121) + auctionAttachment.getAuctionInfo().getRivals().get(0).getAuctMoney() + ResUtil.getString(R.string.avroom_widget_messageview_0122));
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0121) + auctionAttachment.getAuctionInfo().getRivals().get(0).getAuctMoney() + ResUtil.getString(R.string.avroom_widget_messageview_027));
|
||||
}
|
||||
tvContent.setText(builder.build());
|
||||
}
|
||||
@@ -2295,7 +2170,7 @@ public class MessageView extends FrameLayout {
|
||||
*/
|
||||
private void setMsgRoomTip(TextView tvContent, RoomTipAttachment roomTipAttachment, ChatRoomMessage chatRoomMessage) {
|
||||
if (TextUtils.isEmpty(roomTipAttachment.getNick())) roomTipAttachment.setNick("");
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(getNewUserDrawable(chatRoomMessage), badgeWidth, badgeHeight)
|
||||
.append(RegexUtil.getPrintableString(roomTipAttachment.getNick()), new ForegroundColorSpan(roomTipColor))
|
||||
.append(roomTipAttachment.getSecond() == CustomAttachment.CUSTOM_MSG_SUB_TYPE_ROOM_TIP_SHARE_ROOM ?
|
||||
@@ -2311,7 +2186,7 @@ public class MessageView extends FrameLayout {
|
||||
*/
|
||||
private void setFollowRoomTip(TextView tvContent, RoomTipAttachment roomTipAttachment, ChatRoomMessage chatRoomMessage) {
|
||||
if (TextUtils.isEmpty(roomTipAttachment.getNick())) roomTipAttachment.setNick("");
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(getNewUserDrawable(chatRoomMessage), badgeWidth, badgeHeight)
|
||||
.append(RegexUtil.getPrintableString(roomTipAttachment.getNick()), new ForegroundColorSpan(roomTipColor))
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0125), new ForegroundColorSpan(greyColor));
|
||||
@@ -2328,7 +2203,7 @@ public class MessageView extends FrameLayout {
|
||||
* @param chatRoomMessage -
|
||||
*/
|
||||
private void setMsgFace(TextView tvContent, FaceAttachment faceAttachment, ChatRoomMessage chatRoomMessage) {
|
||||
SpannableBuilder builder = new SpannableBuilder(tvContent);
|
||||
TextSpannableBuilder builder = new TextSpannableBuilder(tvContent);
|
||||
List<FaceReceiveInfo> faceReceiveInfos = faceAttachment.getFaceReceiveInfos();
|
||||
FaceReceiveInfo faceReceiveInfo;
|
||||
FaceInfo faceInfo;
|
||||
@@ -2370,7 +2245,7 @@ public class MessageView extends FrameLayout {
|
||||
private void setMsgMultiGift(TextView tvContent, MultiGiftAttachment giftAttachment, ChatRoomMessage chatRoomMessage) {
|
||||
GiftInfo giftInfo = giftAttachment.getMultiGiftReceiveInfo().getGift();
|
||||
String nick = RegexUtil.getPrintableString(giftAttachment.getMultiGiftReceiveInfo().getNick());
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(getNewUserDrawable(chatRoomMessage), badgeWidth, badgeHeight)
|
||||
.append(nick, new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@@ -2381,7 +2256,7 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
})
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0126), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
.append(ResUtil.getString(R.string.gift_message_01), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
.append(giftInfo == null ? "" : giftInfo.getGiftUrl(), giftLength, giftLength)
|
||||
.append("X" + giftAttachment.getMultiGiftReceiveInfo().getGiftNum(), new ForegroundColorSpan(getResources().getColor(R.color.white)));
|
||||
tvContent.setText(text.build());
|
||||
@@ -2406,7 +2281,7 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
String nick = RegexUtil.getPrintableString(giftAttachment.getMultiLuckyGiftReceiveInfo().getNick());
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(getNewUserDrawable(chatRoomMessage), badgeWidth, badgeHeight)
|
||||
.append(nick, new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@@ -2417,9 +2292,9 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
})
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0127), new ForegroundColorSpan(getResources().getColor(R.color.white)));
|
||||
.append(ResUtil.getString(R.string.gift_message_01), new ForegroundColorSpan(getResources().getColor(R.color.white)));
|
||||
|
||||
text.append(luckyGiftInfo.getGiftName() + ResUtil.getString(R.string.avroom_widget_messageview_0128), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
text.append(luckyGiftInfo.getGiftName() + ResUtil.getString(R.string.gift_message_02), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
.append(luckyGiftInfo.getUser().getNick(), new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
@@ -2428,10 +2303,10 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
});
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_0129));
|
||||
text.append(ResUtil.getString(R.string.gift_message_04));
|
||||
for (GiftList luckyGiftList : luckyGiftInfo.getGiftList()) {
|
||||
if (luckyGiftList.getGiftInfo() == null) continue;
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_0130) + luckyGiftList.getGiftInfo().getGoldPrice() + ResUtil.getString(R.string.avroom_widget_messageview_0131))
|
||||
text.append(ResUtil.getString(R.string.gift_message_03) + luckyGiftList.getGiftInfo().getGoldPrice() + ResUtil.getString(R.string.gift_message_05))
|
||||
.append(luckyGiftList.getGiftInfo().getGiftUrl(), giftLength, giftLength)
|
||||
.append("X" + luckyGiftList.getGiftNum(), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
.append("、");
|
||||
@@ -2461,7 +2336,7 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
String nick = RegexUtil.getPrintableString(giftAttachment.getMultiLuckyGiftReceiveInfo().getNick());
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(getNewUserDrawable(chatRoomMessage), badgeWidth, badgeHeight)
|
||||
.append(nick, new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@@ -2472,9 +2347,9 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
})
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0132), new ForegroundColorSpan(getResources().getColor(R.color.white)));
|
||||
.append(ResUtil.getString(R.string.gift_message_01), new ForegroundColorSpan(getResources().getColor(R.color.white)));
|
||||
|
||||
text.append(luckyGiftInfo.getGiftName() + ResUtil.getString(R.string.avroom_widget_messageview_0133), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
text.append(luckyGiftInfo.getGiftName() + ResUtil.getString(R.string.gift_message_02), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
.append(luckyGiftInfo.getUser().getNick(), new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
@@ -2483,10 +2358,10 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
});
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_0134));
|
||||
text.append(ResUtil.getString(R.string.gift_message_04));
|
||||
for (GiftList luckyGiftList : luckyGiftInfo.getGiftList()) {
|
||||
if (luckyGiftList.getGiftInfo() == null) continue;
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_0135) + luckyGiftList.getGiftInfo().getGoldPrice() + ResUtil.getString(R.string.avroom_widget_messageview_0136))
|
||||
text.append(ResUtil.getString(R.string.gift_message_03) + luckyGiftList.getGiftInfo().getGoldPrice() + ResUtil.getString(R.string.gift_message_05))
|
||||
.append(luckyGiftList.getGiftInfo().getGiftUrl(), giftLength, giftLength)
|
||||
.append("X" + luckyGiftList.getGiftNum(), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
.append("、");
|
||||
@@ -2495,7 +2370,6 @@ public class MessageView extends FrameLayout {
|
||||
|
||||
Editable msg = text.builder;
|
||||
msg.delete(msg.length() - 1, msg.length());
|
||||
|
||||
tvContent.setText(text.build());
|
||||
tvContent.setOnClickListener(null);
|
||||
tvContent.setMovementMethod(new LinkMovementMethod());
|
||||
@@ -2511,7 +2385,7 @@ public class MessageView extends FrameLayout {
|
||||
private void setMsgBatchGift(TextView tvContent, GiftBatchAttachment attachment, ChatRoomMessage chatRoomMessage) {
|
||||
GiftInfo giftInfo = attachment.getGiftMultiReceiverInfo().getGift();
|
||||
String nick = RegexUtil.getPrintableString(attachment.getGiftMultiReceiverInfo().getNick());
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(getNewUserDrawable(chatRoomMessage), badgeWidth, badgeHeight)
|
||||
.append(nick, new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@@ -2522,7 +2396,7 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
})
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0137), new ForegroundColorSpan(getResources().getColor(R.color.white)));
|
||||
.append(ResUtil.getString(R.string.gift_message_06), new ForegroundColorSpan(getResources().getColor(R.color.white)));
|
||||
|
||||
for (GiftReceiver targetUser : attachment.getGiftMultiReceiverInfo().getTargetUsers()) {
|
||||
text.append(targetUser.getNick(), new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
@@ -2558,7 +2432,7 @@ public class MessageView extends FrameLayout {
|
||||
MagicInfo magicInfo = MagicModel.get().getMagicInfo(multiMagicReceivedInfo.getMagicId());
|
||||
String nick = RegexUtil.getPrintableString(multiMagicReceivedInfo.getNick());
|
||||
boolean showEffect = multiMagicReceivedInfo.isNeedShowExplode();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(getNewUserDrawable(chatRoomMessage), badgeWidth, badgeHeight)
|
||||
.append(nick, new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
@@ -2592,7 +2466,7 @@ public class MessageView extends FrameLayout {
|
||||
MagicInfo magicInfo = MagicModel.get().getMagicInfo(magicMultiReceiverInfo.getMagicId());
|
||||
String nick = RegexUtil.getPrintableString(magicMultiReceiverInfo.getNick());
|
||||
boolean showEffect = magicMultiReceiverInfo.isNeedShowExplode();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(getNewUserDrawable(chatRoomMessage), badgeWidth, badgeHeight)
|
||||
.append(nick, new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
@@ -2644,7 +2518,7 @@ public class MessageView extends FrameLayout {
|
||||
boolean showEffect = magicReceivedInfo.isNeedShowExplodeEffect();
|
||||
String nick = RegexUtil.getPrintableString(magicReceivedInfo.getNick());
|
||||
String targetNick = RegexUtil.getPrintableString(magicReceivedInfo.getTargetNick());
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(getNewUserDrawable(chatRoomMessage), badgeWidth, badgeHeight)
|
||||
.append(nick, new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@@ -2687,7 +2561,7 @@ public class MessageView extends FrameLayout {
|
||||
String nick = RegexUtil.getPrintableString(giftReceiveInfo.getNick());
|
||||
String targetNick = RegexUtil.getPrintableString(giftReceiveInfo.getTargetNick());
|
||||
String num = "X" + giftReceiveInfo.getGiftNum();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(getNewUserDrawable(chatRoomMessage), badgeWidth, badgeHeight)
|
||||
.append(nick, new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@@ -2698,7 +2572,7 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
})
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0149), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
.append(ResUtil.getString(R.string.gift_message_06), new ForegroundColorSpan(getResources().getColor(R.color.white)))
|
||||
.append(targetNick, new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@Override
|
||||
@@ -2742,7 +2616,7 @@ public class MessageView extends FrameLayout {
|
||||
String carName = NobleUtil.getCarName(CarInfo.CAR_NAME, chatRoomMessage);
|
||||
carName = TextUtils.isEmpty(carName) ? "" : "\"" + carName + "\"";
|
||||
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent);
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent);
|
||||
addCommonTag(chatRoomMessage, text, tvContent);
|
||||
text.append(senderNick, new ForegroundColorSpan(roomTipColor),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
@@ -2839,8 +2713,8 @@ public class MessageView extends FrameLayout {
|
||||
tvContent.setMovementMethod(new LinkMovementMethod());
|
||||
}
|
||||
|
||||
private SpannableBuilder getNotificationBuilder(TextView tvContent, String senderNick, String desc, String tagNick, String carName) {
|
||||
return new SpannableBuilder(tvContent)
|
||||
private TextSpannableBuilder getNotificationBuilder(TextView tvContent, String senderNick, String desc, String tagNick, String carName) {
|
||||
return new TextSpannableBuilder(tvContent)
|
||||
.append(senderNick, new ForegroundColorSpan(roomTipColor))
|
||||
.append(desc, new ForegroundColorSpan(textColor))
|
||||
.append(tagNick, new ForegroundColorSpan(roomTipColor))
|
||||
@@ -2869,7 +2743,7 @@ public class MessageView extends FrameLayout {
|
||||
// 系統通知icon
|
||||
Drawable icNotification = mContext.getResources().getDrawable(R.drawable.ic_system_notification);
|
||||
int width = (int) (icNotification.getIntrinsicWidth() / (icNotification.getIntrinsicHeight() + 0.F) * sysIconHeight);
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append(icNotification, width, sysIconHeight)
|
||||
.append(" 恭喜 ", new ForegroundColorSpan(greyColor))
|
||||
.append(senderNick, new ForegroundColorSpan(roomTipColor))
|
||||
@@ -2891,11 +2765,11 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
CarveUpGoldAttachment attachment = (CarveUpGoldAttachment) chatRoomMessage.getAttachment();
|
||||
// 內容
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent)
|
||||
.append("【簽到瓜分百萬】哇塞,恭喜 ", new ForegroundColorSpan(greyColor))
|
||||
.append(attachment.getNick() + " ", new ForegroundColorSpan(roomTipColor))
|
||||
.append("簽到獲得 ", new ForegroundColorSpan(greyColor))
|
||||
.append(attachment.getGoldNum() + "鉆石", new ForegroundColorSpan(roomTipColor))
|
||||
.append(attachment.getGoldNum() + "金幣", new ForegroundColorSpan(roomTipColor))
|
||||
.append("!", new ForegroundColorSpan(greyColor));
|
||||
tvContent.setText(text.build());
|
||||
}
|
||||
@@ -2917,9 +2791,9 @@ public class MessageView extends FrameLayout {
|
||||
ChatRoomMessageExtension extension = chatRoomMessage.getChatRoomMessageExtension();
|
||||
// 內容
|
||||
String fromAccount = chatRoomMessage.getFromAccount();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent);
|
||||
TextSpannableBuilder text = new TextSpannableBuilder(tvContent);
|
||||
addCommonTag(chatRoomMessage, text, tvContent);
|
||||
text.append(extension == null ? "我" : RegexUtil.getPrintableString(extension.getSenderNick()),
|
||||
text.append(extension == null ? getContext().getString(R.string.ui_widget_userinfodialog_01) : RegexUtil.getPrintableString(extension.getSenderNick()),
|
||||
new ForegroundColorSpan(greyColor),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
@@ -3068,7 +2942,7 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
} else {
|
||||
String content = chatRoomMessage.getContent();
|
||||
if (!TextUtils.isEmpty(content) && content.equals(XConstants.ROOM_INTRODUCTION))
|
||||
if (!TextUtils.isEmpty(content) && content.equals(ResUtil.getString(R.string.yizhuan_xchat_android_constants_xchatconstants_08)))
|
||||
if (onClick != null) {
|
||||
onClick.onShowRoomIntroduction();
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.lib_utils.UiUtils;
|
||||
import com.opensource.svgaplayer.SVGADrawable;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
@@ -98,7 +99,7 @@ public class MicroView extends LinearLayout implements View.OnLayoutChangeListen
|
||||
|
||||
public void bindAdapter(@NonNull BaseMicroViewAdapter adapter) {
|
||||
if (adapter instanceof DatingMicroViewAdapter) {
|
||||
if (datingItemDecoration == null) datingItemDecoration = new DatingItemDecoration();
|
||||
if (datingItemDecoration == null) datingItemDecoration = new DatingItemDecoration(UiUtils.INSTANCE.isRtl(getContext()));
|
||||
recyclerView.addItemDecoration(datingItemDecoration);
|
||||
} else if (datingItemDecoration != null) {
|
||||
recyclerView.removeItemDecoration(datingItemDecoration);
|
||||
@@ -181,8 +182,15 @@ public class MicroView extends LinearLayout implements View.OnLayoutChangeListen
|
||||
View view = child.findViewById(R.id.micro_layout);
|
||||
if (view != null) child = view;
|
||||
child.getLocationInWindow(location);
|
||||
int x = (location[0] + child.getWidth() / 2) - giftWidth / 2;
|
||||
int y = (location[1] + child.getHeight() / 2) - giftHeight / 2;
|
||||
int x;
|
||||
int y;
|
||||
if (UiUtils.INSTANCE.isRtl(getContext())) {
|
||||
location[0] = getWidth() - location[0];
|
||||
x = (location[0] - child.getWidth() / 2) - giftWidth / 2;
|
||||
}else{
|
||||
x = (location[0] + child.getWidth() / 2) - giftWidth / 2;
|
||||
}
|
||||
y = (location[1] + child.getHeight() / 2) - giftHeight / 2;
|
||||
Point point = new Point(x, y);
|
||||
LogUtils.d("x= " + x + " y= " + y);
|
||||
centerPoints.put(micPosition, point);
|
||||
|
@@ -35,18 +35,16 @@ import com.chwl.app.ui.utils.isDestroyed
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.app.ui.utils.loadAnim
|
||||
import com.chwl.app.ui.widget.SimpleAnimListener
|
||||
import com.chwl.app.ui.widget.TextSpannableBuilder
|
||||
import com.chwl.app.ui.widget.drawgift.DrawGiftPlayHelper
|
||||
import com.chwl.app.utils.SpannableBuilder
|
||||
import com.chwl.core.XConstants
|
||||
import com.chwl.core.auth.AuthModel
|
||||
import com.chwl.core.decoration.car.bean.CarInfo
|
||||
import com.chwl.core.im.custom.bean.*
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.manager.IMNetEaseManager
|
||||
import com.chwl.core.manager.RoomEvent
|
||||
import com.chwl.core.monsterhunting.SimpleAnimationListener
|
||||
import com.chwl.core.room.bean.DatingNotifyInfo
|
||||
import com.chwl.core.super_admin.util.SuperAdminUtil
|
||||
import com.chwl.core.user.UserModel
|
||||
@@ -54,7 +52,6 @@ import com.chwl.core.user.bean.UserInfo
|
||||
import com.chwl.core.utils.extension.subAndReplaceDot
|
||||
import com.chwl.library.utils.ListUtils
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.chwl.library.utils.StringUtils
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.ObservableEmitter
|
||||
import io.reactivex.ObservableOnSubscribe
|
||||
@@ -151,8 +148,8 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
.subscribe { roomEvent: RoomEvent? ->
|
||||
if (roomEvent == null || AvRoomDataManager.get().isSelfGamePlaying) return@subscribe
|
||||
when (roomEvent.event) {
|
||||
RoomEvent.BOX_NOTIFY -> addBoxNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.BOX_NOTIFY_SVGA -> addBoxNotify(roomEvent.chatRoomMessage)
|
||||
// RoomEvent.BOX_NOTIFY -> addBoxNotify(roomEvent.chatRoomMessage)
|
||||
// RoomEvent.BOX_NOTIFY_SVGA -> addBoxNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.DATING_ALL_NOTIFY -> addDatingAllNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.RADISH_NOTIFY,
|
||||
RoomEvent.RADISH_NOTIFY_SVGA -> addRadishNotify(roomEvent.chatRoomMessage)
|
||||
@@ -305,143 +302,143 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
*
|
||||
* @param chatRoomMessage
|
||||
*/
|
||||
private fun addBoxNotify(chatRoomMessage: ChatRoomMessage) {
|
||||
if (binding.clNotify.visibility == GONE) {
|
||||
binding.clNotify.visibility = VISIBLE
|
||||
}
|
||||
messagesBox.add(chatRoomMessage)
|
||||
if (boxDisposable == null || messagesBox.size == 1) {
|
||||
boxDisposable = Observable.interval(0, PERIOD.toLong(), TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.takeWhile { messagesBox.size > 0 && !mContext.isDestroyed() }
|
||||
.subscribe {
|
||||
if (binding.flBoxNotify.childCount == 0) {
|
||||
val msg = messagesBox.removeAt(0)
|
||||
val attachment = msg.attachment
|
||||
if (attachment is CustomAttachment) {
|
||||
if (attachment.second == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY) {
|
||||
showBoxNotify(msg)
|
||||
} else if(attachment.second == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
|
||||
showBoxNotifyBySVGA(msg)
|
||||
}
|
||||
// private fun addBoxNotify(chatRoomMessage: ChatRoomMessage) {
|
||||
// if (binding.clNotify.visibility == GONE) {
|
||||
// binding.clNotify.visibility = VISIBLE
|
||||
// }
|
||||
// messagesBox.add(chatRoomMessage)
|
||||
// if (boxDisposable == null || messagesBox.size == 1) {
|
||||
// boxDisposable = Observable.interval(0, PERIOD.toLong(), TimeUnit.MILLISECONDS)
|
||||
// .observeOn(AndroidSchedulers.mainThread())
|
||||
// .takeWhile { messagesBox.size > 0 && !mContext.isDestroyed() }
|
||||
// .subscribe {
|
||||
// if (binding.flBoxNotify.childCount == 0) {
|
||||
// val msg = messagesBox.removeAt(0)
|
||||
// val attachment = msg.attachment
|
||||
// if (attachment is CustomAttachment) {
|
||||
// if (attachment.second == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY) {
|
||||
// showBoxNotify(msg)
|
||||
// } else if(attachment.second == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
|
||||
// showBoxNotifyBySVGA(msg)
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// private fun showBoxNotify(chatRoomMessage: ChatRoomMessage) {
|
||||
// val attachment = chatRoomMessage.attachment as RoomBoxPrizeAttachment
|
||||
// val textView =
|
||||
// LayoutInflater.from(mContext).inflate(R.layout.layout_room_box_notify, null) as TextView
|
||||
// val text = SpannableBuilder()
|
||||
// .append(
|
||||
// ResUtil.getString(R.string.avroom_widget_roomeffectview_08),
|
||||
// ForegroundColorSpan(Color.WHITE)
|
||||
// )
|
||||
// .append(
|
||||
// attachment.nick.subAndReplaceDot(8),
|
||||
// ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
// )
|
||||
// .append(
|
||||
// ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(
|
||||
// R.string.avroom_widget_roomeffectview_010
|
||||
// ), ForegroundColorSpan(Color.WHITE)
|
||||
// )
|
||||
// .append(
|
||||
// attachment.prizeName,
|
||||
// ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
// )
|
||||
// if (attachment.prizeNum > 1) {
|
||||
// text.append("x" + attachment.prizeNum, ForegroundColorSpan(Color.WHITE))
|
||||
// }
|
||||
// textView.text = text.build()
|
||||
// animationBox = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
// binding.flBoxNotify.addView(textView)
|
||||
// textView.startAnimation(animationBox)
|
||||
// binding.flBoxNotify.postDelayed(
|
||||
// {
|
||||
// animationBox = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
|
||||
// textView.startAnimation(animationBox)
|
||||
// },
|
||||
// SHOW_TIME.toLong()
|
||||
// )
|
||||
// binding.flBoxNotify.postDelayed({
|
||||
// binding.flBoxNotify.removeView(textView)
|
||||
// }, CLOSE_TIME.toLong())
|
||||
// }
|
||||
|
||||
private fun showBoxNotify(chatRoomMessage: ChatRoomMessage) {
|
||||
val attachment = chatRoomMessage.attachment as RoomBoxPrizeAttachment
|
||||
val textView =
|
||||
LayoutInflater.from(mContext).inflate(R.layout.layout_room_box_notify, null) as TextView
|
||||
val text = SpannableBuilder()
|
||||
.append(
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_08),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
attachment.nick.subAndReplaceDot(8),
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(
|
||||
R.string.avroom_widget_roomeffectview_010
|
||||
), ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
attachment.prizeName,
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
if (attachment.prizeNum > 1) {
|
||||
text.append("x" + attachment.prizeNum, ForegroundColorSpan(Color.WHITE))
|
||||
}
|
||||
textView.text = text.build()
|
||||
animationBox = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
binding.flBoxNotify.addView(textView)
|
||||
textView.startAnimation(animationBox)
|
||||
binding.flBoxNotify.postDelayed(
|
||||
{
|
||||
animationBox = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
|
||||
textView.startAnimation(animationBox)
|
||||
},
|
||||
SHOW_TIME.toLong()
|
||||
)
|
||||
binding.flBoxNotify.postDelayed({
|
||||
binding.flBoxNotify.removeView(textView)
|
||||
}, CLOSE_TIME.toLong())
|
||||
}
|
||||
|
||||
private fun showBoxNotifyBySVGA(chatRoomMessage: ChatRoomMessage) {
|
||||
val attachment = chatRoomMessage.attachment as RoomBoxPrizeAttachment
|
||||
val text = SpannableBuilder()
|
||||
.append(
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_011),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
StringUtils.abbreviate(attachment.nick, 8) + " ",
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(
|
||||
R.string.avroom_widget_roomeffectview_013
|
||||
), ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
attachment.prizeName,
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
if (attachment.prizeNum > 1) {
|
||||
text.append("x" + attachment.prizeNum, ForegroundColorSpan(Color.WHITE))
|
||||
}
|
||||
val svgaImageView = SVGAImageView(mContext)
|
||||
svgaImageView.loops = 1
|
||||
svgaImageView.clearsAfterDetached = true
|
||||
val params = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
||||
svgaImageView.layoutParams = params
|
||||
svgaImageView.callback = object : SimpleSvgaCallback() {
|
||||
override fun onFinished() {
|
||||
animationBox = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
|
||||
animationBox!!.setAnimationListener(object : SimpleAnimationListener() {
|
||||
override fun onAnimationEnd(animation: Animation?) {
|
||||
binding.flBoxNotify.removeView(svgaImageView)
|
||||
}
|
||||
})
|
||||
binding.flBoxNotify.startAnimation(animationBox)
|
||||
}
|
||||
}
|
||||
animationBox = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
binding.flBoxNotify.addView(svgaImageView)
|
||||
binding.flBoxNotify.startAnimation(animationBox)
|
||||
|
||||
shareParser().decodeFromAssets("svga/box_notify.svga", object : SVGAParser.ParseCompletion {
|
||||
override fun onComplete(videoItem: SVGAVideoEntity) {
|
||||
val dynamicEntity = SVGADynamicEntity()
|
||||
val textPaint = TextPaint()
|
||||
textPaint.color = Color.WHITE //字體顏色
|
||||
textPaint.textSize = 24f //字體大小
|
||||
dynamicEntity.setDynamicText(
|
||||
StaticLayout(
|
||||
text.build(),
|
||||
0,
|
||||
text.build().length,
|
||||
textPaint,
|
||||
0,
|
||||
Layout.Alignment.ALIGN_CENTER,
|
||||
1.0f,
|
||||
0.0f,
|
||||
false
|
||||
), "bg"
|
||||
)
|
||||
val drawable = SVGADrawable(videoItem, dynamicEntity)
|
||||
svgaImageView.setImageDrawable(drawable)
|
||||
svgaImageView.stepToFrame(0, true)
|
||||
}
|
||||
|
||||
override fun onError() {}
|
||||
}, null)
|
||||
}
|
||||
// private fun showBoxNotifyBySVGA(chatRoomMessage: ChatRoomMessage) {
|
||||
// val attachment = chatRoomMessage.attachment as RoomBoxPrizeAttachment
|
||||
// val text = SpannableBuilder()
|
||||
// .append(
|
||||
// ResUtil.getString(R.string.avroom_widget_roomeffectview_011),
|
||||
// ForegroundColorSpan(Color.WHITE)
|
||||
// )
|
||||
// .append(
|
||||
// StringUtils.abbreviate(attachment.nick, 8) + " ",
|
||||
// ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
// )
|
||||
// .append(
|
||||
// ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(
|
||||
// R.string.avroom_widget_roomeffectview_013
|
||||
// ), ForegroundColorSpan(Color.WHITE)
|
||||
// )
|
||||
// .append(
|
||||
// attachment.prizeName,
|
||||
// ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
// )
|
||||
// if (attachment.prizeNum > 1) {
|
||||
// text.append("x" + attachment.prizeNum, ForegroundColorSpan(Color.WHITE))
|
||||
// }
|
||||
// val svgaImageView = SVGAImageView(mContext)
|
||||
// svgaImageView.loops = 1
|
||||
// svgaImageView.clearsAfterDetached = true
|
||||
// val params = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
||||
// svgaImageView.layoutParams = params
|
||||
// svgaImageView.callback = object : SimpleSvgaCallback() {
|
||||
// override fun onFinished() {
|
||||
// animationBox = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
|
||||
// animationBox!!.setAnimationListener(object : SimpleAnimationListener() {
|
||||
// override fun onAnimationEnd(animation: Animation?) {
|
||||
// binding.flBoxNotify.removeView(svgaImageView)
|
||||
// }
|
||||
// })
|
||||
// binding.flBoxNotify.startAnimation(animationBox)
|
||||
// }
|
||||
// }
|
||||
// animationBox = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
// binding.flBoxNotify.addView(svgaImageView)
|
||||
// binding.flBoxNotify.startAnimation(animationBox)
|
||||
//
|
||||
// shareParser().decodeFromAssets("svga/box_notify.svga", object : SVGAParser.ParseCompletion {
|
||||
// override fun onComplete(videoItem: SVGAVideoEntity) {
|
||||
// val dynamicEntity = SVGADynamicEntity()
|
||||
// val textPaint = TextPaint()
|
||||
// textPaint.color = Color.WHITE //字體顏色
|
||||
// textPaint.textSize = 24f //字體大小
|
||||
// dynamicEntity.setDynamicText(
|
||||
// StaticLayout(
|
||||
// text.build(),
|
||||
// 0,
|
||||
// text.build().length,
|
||||
// textPaint,
|
||||
// 0,
|
||||
// Layout.Alignment.ALIGN_CENTER,
|
||||
// 1.0f,
|
||||
// 0.0f,
|
||||
// false
|
||||
// ), "bg"
|
||||
// )
|
||||
// val drawable = SVGADrawable(videoItem, dynamicEntity)
|
||||
// svgaImageView.setImageDrawable(drawable)
|
||||
// svgaImageView.stepToFrame(0, true)
|
||||
// }
|
||||
//
|
||||
// override fun onError() {}
|
||||
// }, null)
|
||||
// }
|
||||
|
||||
/**
|
||||
* 幸運池飄屏
|
||||
@@ -720,7 +717,7 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
val textView = LayoutInflater.from(mContext)
|
||||
.inflate(R.layout.layout_member_in_notify, null) as SuperTextView
|
||||
// 內容
|
||||
val text = MessageView.SpannableBuilder(textView)
|
||||
val text = TextSpannableBuilder(textView)
|
||||
.append(targetNicks[0], ForegroundColorSpan(Color.WHITE))
|
||||
var enterText = ResUtil.getString(R.string.avroom_widget_roomeffectview_018)
|
||||
if (fromType == AVRoomActivity.FROM_TYPE_RECOMMEND) {
|
||||
@@ -1219,7 +1216,7 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
val msgBean = (chatRoomMessage.attachment as RoomRankAttachment).msgBean
|
||||
val rootView = LayoutInflater.from(mContext).inflate(R.layout.layout_room_rank_notify, null)
|
||||
val textView = rootView.findViewById<TextView>(R.id.tv_content)
|
||||
val text = MessageView.SpannableBuilder(textView)
|
||||
val text = TextSpannableBuilder(textView)
|
||||
.append(
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_025),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
|
@@ -39,6 +39,7 @@ import com.chwl.app.ui.utils.load
|
||||
import com.chwl.app.ui.utils.loadAnim
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity
|
||||
import com.chwl.app.ui.widget.SimpleAnimListener
|
||||
import com.chwl.app.ui.widget.TextSpannableBuilder
|
||||
import com.chwl.app.ui.widget.drawgift.DrawGiftPlayHelper
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil
|
||||
import com.chwl.app.utils.MsgBuilder
|
||||
@@ -165,13 +166,13 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
.subscribe { roomEvent: RoomEvent? ->
|
||||
if (roomEvent == null || AvRoomDataManager.get().isSelfGamePlaying) return@subscribe
|
||||
when (roomEvent.event) {
|
||||
RoomEvent.BOX_NOTIFY -> {//寻爱
|
||||
addPlayNotify(RoomEvent.BOX_NOTIFY, roomEvent.chatRoomMessage)
|
||||
}
|
||||
|
||||
RoomEvent.BOX_NOTIFY_SVGA -> {//寻爱svga
|
||||
addPlayNotify(RoomEvent.BOX_NOTIFY_SVGA, roomEvent.chatRoomMessage)
|
||||
}
|
||||
// RoomEvent.BOX_NOTIFY -> {//寻爱
|
||||
// addPlayNotify(RoomEvent.BOX_NOTIFY, roomEvent.chatRoomMessage)
|
||||
// }
|
||||
//
|
||||
// RoomEvent.BOX_NOTIFY_SVGA -> {//寻爱svga
|
||||
// addPlayNotify(RoomEvent.BOX_NOTIFY_SVGA, roomEvent.chatRoomMessage)
|
||||
// }
|
||||
|
||||
RoomEvent.TAROT_NOTIFY,
|
||||
RoomEvent.TAROT_NOTIFY_SVGA -> {
|
||||
@@ -182,9 +183,9 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage)
|
||||
}
|
||||
|
||||
RoomEvent.RECEIVE_ROOM_LUCKY_BAG_NOTICE, RoomEvent.RECEIVE_SERVICE_LUCKY_BAG_NOTICE ->//全服福袋
|
||||
//廳內福袋
|
||||
addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage)
|
||||
// RoomEvent.RECEIVE_ROOM_LUCKY_BAG_NOTICE, RoomEvent.RECEIVE_SERVICE_LUCKY_BAG_NOTICE ->//全服福袋
|
||||
// //廳內福袋
|
||||
// addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage)
|
||||
|
||||
RoomEvent.LUCKY_SEA_GIFT_ROOM_NOTIFY -> {// 星级厨房房间飘屏通知
|
||||
addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage)
|
||||
@@ -287,57 +288,57 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
when (messagesPlay[0].event) {
|
||||
RoomEvent.BOX_NOTIFY -> {//寻爱
|
||||
if ((mContext as AVRoomActivity).isTopActivity) {
|
||||
isPlayAnim = true
|
||||
val isPlay = onPlayAnimCallback?.invoke() ?: false
|
||||
if (isPlay) {
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, 180.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
} else {
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, 60.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
}
|
||||
showBoxNotify(
|
||||
messagesPlay.removeAt(0)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
RoomEvent.BOX_NOTIFY_SVGA -> {//寻爱
|
||||
if ((mContext as AVRoomActivity).isTopActivity) {
|
||||
isPlayAnim = true
|
||||
val isPlay = onPlayAnimCallback?.invoke() ?: false
|
||||
if (isPlay) {
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, 180.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
} else {
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, 60.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
}
|
||||
showBoxNotifyBySVGA(messagesPlay.removeAt(0))
|
||||
}
|
||||
}
|
||||
// RoomEvent.BOX_NOTIFY -> {//寻爱
|
||||
// if ((mContext as AVRoomActivity).isTopActivity) {
|
||||
// isPlayAnim = true
|
||||
// val isPlay = onPlayAnimCallback?.invoke() ?: false
|
||||
// if (isPlay) {
|
||||
// margin(
|
||||
// binding.clNotify,
|
||||
// 0,
|
||||
// UIUtil.dip2px(context, 180.0),
|
||||
// 0,
|
||||
// 0
|
||||
// )
|
||||
// } else {
|
||||
// margin(
|
||||
// binding.clNotify,
|
||||
// 0,
|
||||
// UIUtil.dip2px(context, 60.0),
|
||||
// 0,
|
||||
// 0
|
||||
// )
|
||||
// }
|
||||
// showBoxNotify(
|
||||
// messagesPlay.removeAt(0)
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// RoomEvent.BOX_NOTIFY_SVGA -> {//寻爱
|
||||
// if ((mContext as AVRoomActivity).isTopActivity) {
|
||||
// isPlayAnim = true
|
||||
// val isPlay = onPlayAnimCallback?.invoke() ?: false
|
||||
// if (isPlay) {
|
||||
// margin(
|
||||
// binding.clNotify,
|
||||
// 0,
|
||||
// UIUtil.dip2px(context, 180.0),
|
||||
// 0,
|
||||
// 0
|
||||
// )
|
||||
// } else {
|
||||
// margin(
|
||||
// binding.clNotify,
|
||||
// 0,
|
||||
// UIUtil.dip2px(context, 60.0),
|
||||
// 0,
|
||||
// 0
|
||||
// )
|
||||
// }
|
||||
// showBoxNotifyBySVGA(messagesPlay.removeAt(0))
|
||||
// }
|
||||
// }
|
||||
|
||||
RoomEvent.TAROT_NOTIFY -> {
|
||||
if ((mContext as AVRoomActivity).isTopActivity) {
|
||||
@@ -966,49 +967,49 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
isPlayAnim = false
|
||||
}, CLOSE_TIME.toLong())
|
||||
}
|
||||
|
||||
private fun showBoxNotify(roomPlayBean: RoomPlayBean) {
|
||||
val chatRoomMessage = roomPlayBean.chatRoomMessage
|
||||
val attachment = chatRoomMessage.attachment as RoomBoxPrizeAttachment
|
||||
val textView =
|
||||
LayoutInflater.from(mContext).inflate(R.layout.layout_room_box_notify, null) as TextView
|
||||
val text = SpannableBuilder()
|
||||
.append(
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_08),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
attachment.nick.subAndReplaceDot(8),
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(
|
||||
R.string.avroom_widget_roomeffectview_010
|
||||
), ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
attachment.prizeName,
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
if (attachment.prizeNum > 1) {
|
||||
text.append("x" + attachment.prizeNum, ForegroundColorSpan(Color.WHITE))
|
||||
}
|
||||
textView.text = text.build()
|
||||
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
binding.flPlayNotify.addView(textView)
|
||||
textView.startAnimation(animationPlay)
|
||||
binding.flPlayNotify.postDelayed(
|
||||
{
|
||||
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
|
||||
textView.startAnimation(animationPlay)
|
||||
},
|
||||
SHOW_TIME.toLong()
|
||||
)
|
||||
binding.flPlayNotify.postDelayed({
|
||||
binding.flPlayNotify.removeView(textView)
|
||||
isPlayAnim = false
|
||||
}, CLOSE_TIME.toLong())
|
||||
}
|
||||
//
|
||||
// private fun showBoxNotify(roomPlayBean: RoomPlayBean) {
|
||||
// val chatRoomMessage = roomPlayBean.chatRoomMessage
|
||||
// val attachment = chatRoomMessage.attachment as RoomBoxPrizeAttachment
|
||||
// val textView =
|
||||
// LayoutInflater.from(mContext).inflate(R.layout.layout_room_box_notify, null) as TextView
|
||||
// val text = SpannableBuilder()
|
||||
// .append(
|
||||
// ResUtil.getString(R.string.avroom_widget_roomeffectview_08),
|
||||
// ForegroundColorSpan(Color.WHITE)
|
||||
// )
|
||||
// .append(
|
||||
// attachment.nick.subAndReplaceDot(8),
|
||||
// ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
// )
|
||||
// .append(
|
||||
// ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(
|
||||
// R.string.avroom_widget_roomeffectview_010
|
||||
// ), ForegroundColorSpan(Color.WHITE)
|
||||
// )
|
||||
// .append(
|
||||
// attachment.prizeName,
|
||||
// ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
// )
|
||||
// if (attachment.prizeNum > 1) {
|
||||
// text.append("x" + attachment.prizeNum, ForegroundColorSpan(Color.WHITE))
|
||||
// }
|
||||
// textView.text = text.build()
|
||||
// animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
// binding.flPlayNotify.addView(textView)
|
||||
// textView.startAnimation(animationPlay)
|
||||
// binding.flPlayNotify.postDelayed(
|
||||
// {
|
||||
// animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
|
||||
// textView.startAnimation(animationPlay)
|
||||
// },
|
||||
// SHOW_TIME.toLong()
|
||||
// )
|
||||
// binding.flPlayNotify.postDelayed({
|
||||
// binding.flPlayNotify.removeView(textView)
|
||||
// isPlayAnim = false
|
||||
// }, CLOSE_TIME.toLong())
|
||||
// }
|
||||
|
||||
private fun showTarotNotifyBySVGA(roomPlayBean: RoomPlayBean) {
|
||||
val chatRoomMessage = roomPlayBean.chatRoomMessage
|
||||
@@ -1066,78 +1067,78 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
)
|
||||
}
|
||||
|
||||
private fun showBoxNotifyBySVGA(roomPlayBean: RoomPlayBean) {
|
||||
val chatRoomMessage = roomPlayBean.chatRoomMessage
|
||||
val attachment = chatRoomMessage.attachment as RoomBoxPrizeAttachment
|
||||
val text = SpannableBuilder()
|
||||
.append(
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_011),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
StringUtils.abbreviate(attachment.nick, 8) + " ",
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(
|
||||
R.string.avroom_widget_roomeffectview_013
|
||||
), ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
attachment.prizeName,
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
if (attachment.prizeNum > 1) {
|
||||
text.append("x" + attachment.prizeNum, ForegroundColorSpan(Color.WHITE))
|
||||
}
|
||||
val svgaImageView = SVGAImageView(mContext)
|
||||
svgaImageView.loops = 1
|
||||
svgaImageView.clearsAfterDetached = true
|
||||
val params = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
||||
svgaImageView.layoutParams = params
|
||||
svgaImageView.callback = object : SimpleSvgaCallback() {
|
||||
override fun onFinished() {
|
||||
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
|
||||
animationPlay!!.setAnimationListener(object : SimpleAnimationListener() {
|
||||
override fun onAnimationEnd(animation: Animation?) {
|
||||
binding.flPlayNotify.removeView(svgaImageView)
|
||||
isPlayAnim = false
|
||||
}
|
||||
})
|
||||
binding.flPlayNotify.startAnimation(animationPlay)
|
||||
}
|
||||
}
|
||||
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
binding.flPlayNotify.addView(svgaImageView)
|
||||
binding.flPlayNotify.startAnimation(animationPlay)
|
||||
|
||||
shareParser().decodeFromAssets("svga/box_notify.svga", object : SVGAParser.ParseCompletion {
|
||||
override fun onComplete(videoItem: SVGAVideoEntity) {
|
||||
val dynamicEntity = SVGADynamicEntity()
|
||||
val textPaint = TextPaint()
|
||||
textPaint.color = Color.WHITE //字體顏色
|
||||
textPaint.textSize = 24f //字體大小
|
||||
dynamicEntity.setDynamicText(
|
||||
StaticLayout(
|
||||
text.build(),
|
||||
0,
|
||||
text.build().length,
|
||||
textPaint,
|
||||
0,
|
||||
Layout.Alignment.ALIGN_CENTER,
|
||||
1.0f,
|
||||
0.0f,
|
||||
false
|
||||
), "bg"
|
||||
)
|
||||
val drawable = SVGADrawable(videoItem, dynamicEntity)
|
||||
svgaImageView.setImageDrawable(drawable)
|
||||
svgaImageView.stepToFrame(0, true)
|
||||
}
|
||||
|
||||
override fun onError() {}
|
||||
}, null)
|
||||
}
|
||||
// private fun showBoxNotifyBySVGA(roomPlayBean: RoomPlayBean) {
|
||||
// val chatRoomMessage = roomPlayBean.chatRoomMessage
|
||||
// val attachment = chatRoomMessage.attachment as RoomBoxPrizeAttachment
|
||||
// val text = SpannableBuilder()
|
||||
// .append(
|
||||
// ResUtil.getString(R.string.avroom_widget_roomeffectview_011),
|
||||
// ForegroundColorSpan(Color.WHITE)
|
||||
// )
|
||||
// .append(
|
||||
// StringUtils.abbreviate(attachment.nick, 8) + " ",
|
||||
// ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
// )
|
||||
// .append(
|
||||
// ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(
|
||||
// R.string.avroom_widget_roomeffectview_013
|
||||
// ), ForegroundColorSpan(Color.WHITE)
|
||||
// )
|
||||
// .append(
|
||||
// attachment.prizeName,
|
||||
// ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
// )
|
||||
// if (attachment.prizeNum > 1) {
|
||||
// text.append("x" + attachment.prizeNum, ForegroundColorSpan(Color.WHITE))
|
||||
// }
|
||||
// val svgaImageView = SVGAImageView(mContext)
|
||||
// svgaImageView.loops = 1
|
||||
// svgaImageView.clearsAfterDetached = true
|
||||
// val params = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
||||
// svgaImageView.layoutParams = params
|
||||
// svgaImageView.callback = object : SimpleSvgaCallback() {
|
||||
// override fun onFinished() {
|
||||
// animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
|
||||
// animationPlay!!.setAnimationListener(object : SimpleAnimationListener() {
|
||||
// override fun onAnimationEnd(animation: Animation?) {
|
||||
// binding.flPlayNotify.removeView(svgaImageView)
|
||||
// isPlayAnim = false
|
||||
// }
|
||||
// })
|
||||
// binding.flPlayNotify.startAnimation(animationPlay)
|
||||
// }
|
||||
// }
|
||||
// animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
// binding.flPlayNotify.addView(svgaImageView)
|
||||
// binding.flPlayNotify.startAnimation(animationPlay)
|
||||
//
|
||||
// shareParser().decodeFromAssets("svga/box_notify.svga", object : SVGAParser.ParseCompletion {
|
||||
// override fun onComplete(videoItem: SVGAVideoEntity) {
|
||||
// val dynamicEntity = SVGADynamicEntity()
|
||||
// val textPaint = TextPaint()
|
||||
// textPaint.color = Color.WHITE //字體顏色
|
||||
// textPaint.textSize = 24f //字體大小
|
||||
// dynamicEntity.setDynamicText(
|
||||
// StaticLayout(
|
||||
// text.build(),
|
||||
// 0,
|
||||
// text.build().length,
|
||||
// textPaint,
|
||||
// 0,
|
||||
// Layout.Alignment.ALIGN_CENTER,
|
||||
// 1.0f,
|
||||
// 0.0f,
|
||||
// false
|
||||
// ), "bg"
|
||||
// )
|
||||
// val drawable = SVGADrawable(videoItem, dynamicEntity)
|
||||
// svgaImageView.setImageDrawable(drawable)
|
||||
// svgaImageView.stepToFrame(0, true)
|
||||
// }
|
||||
//
|
||||
// override fun onError() {}
|
||||
// }, null)
|
||||
// }
|
||||
|
||||
/**
|
||||
* 幸運池飄屏
|
||||
@@ -1416,7 +1417,7 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
val textView = LayoutInflater.from(mContext)
|
||||
.inflate(R.layout.layout_member_in_notify, null) as SuperTextView
|
||||
// 內容
|
||||
val text = MessageView.SpannableBuilder(textView)
|
||||
val text = TextSpannableBuilder(textView)
|
||||
.append(targetNicks[0], ForegroundColorSpan(Color.WHITE))
|
||||
var enterText = ResUtil.getString(R.string.avroom_widget_roomeffectview_018)
|
||||
if (fromType == AVRoomActivity.FROM_TYPE_RECOMMEND) {
|
||||
@@ -1936,7 +1937,7 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
val msgBean = (chatRoomMessage.attachment as RoomRankAttachment).msgBean
|
||||
val rootView = LayoutInflater.from(mContext).inflate(R.layout.layout_room_rank_notify, null)
|
||||
val textView = rootView.findViewById<TextView>(R.id.tv_content)
|
||||
val text = MessageView.SpannableBuilder(textView)
|
||||
val text = TextSpannableBuilder(textView)
|
||||
.append(
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_025),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
|
@@ -0,0 +1,178 @@
|
||||
package com.chwl.app.avroom.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import com.chwl.app.common.widget.OriginalDrawStatusClickSpan
|
||||
import com.chwl.app.ui.widget.TextSpannableBuilder
|
||||
import com.chwl.app.utils.CommonJumpHelper
|
||||
import com.chwl.app.utils.SpannableBuilder
|
||||
import com.chwl.core.home.bean.BannerInfo
|
||||
import com.chwl.core.im.custom.bean.TemplateMessage
|
||||
import com.chwl.core.im.custom.bean.TemplateMessage.TemplateNode
|
||||
import com.chwl.core.im.custom.bean.TemplateMessage.Content
|
||||
import com.example.lib_utils.UiUtils
|
||||
|
||||
|
||||
class TemplateMessageAdapter(val listener: Listener?) {
|
||||
|
||||
/**
|
||||
* 解析为文本(子节点只支持TEXT类型)
|
||||
*/
|
||||
fun parse(context: Context, attachment: TemplateMessage?): SpannableStringBuilder? {
|
||||
val builder = SpannableBuilder()
|
||||
if (attachment == null) {
|
||||
return null
|
||||
}
|
||||
val nodeList = attachment.getNodeList()
|
||||
nodeList.forEach {
|
||||
if (it is TemplateNode.NormalNode) {
|
||||
val textColor = parseColor(it.textColor)
|
||||
if (textColor != null) {
|
||||
builder.append(it.text, ForegroundColorSpan(textColor))
|
||||
} else {
|
||||
builder.append(it.text)
|
||||
}
|
||||
} else if (it is TemplateNode.SpecialNode) {
|
||||
when (it.content.type) {
|
||||
Content.TEXT -> {
|
||||
val text = it.content.text?.getFirstText()
|
||||
if (!text.isNullOrEmpty()) {
|
||||
val textColor = parseColor(it.content.textColor)
|
||||
val clickSpan = createClickSpan(context, it.content, listener)
|
||||
val list = ArrayList<Any>()
|
||||
if (textColor != null) {
|
||||
list.add(ForegroundColorSpan(textColor))
|
||||
}
|
||||
if (clickSpan != null) {
|
||||
list.add(clickSpan)
|
||||
}
|
||||
builder.append(text, *list.toArray())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return builder.build()
|
||||
}
|
||||
|
||||
fun convert(textView: TextView, attachment: TemplateMessage?) {
|
||||
if (attachment == null) {
|
||||
textView.text = ""
|
||||
return
|
||||
}
|
||||
val nodeList = attachment.getNodeList()
|
||||
val textBuilder = TextSpannableBuilder(textView)
|
||||
nodeList.forEach {
|
||||
if (it is TemplateNode.NormalNode) {
|
||||
val textColor = parseColor(it.textColor)
|
||||
if (textColor != null) {
|
||||
textBuilder.append(it.text, ForegroundColorSpan(textColor))
|
||||
} else {
|
||||
textBuilder.append(it.text)
|
||||
}
|
||||
} else if (it is TemplateNode.SpecialNode) {
|
||||
when (it.content.type) {
|
||||
Content.TEXT -> {
|
||||
val text = it.content.text?.getFirstText()
|
||||
if (!text.isNullOrEmpty()) {
|
||||
val textColor = parseColor(it.content.textColor)
|
||||
val clickSpan = createClickSpan(textView.context, it.content, listener)
|
||||
val list = ArrayList<Any>()
|
||||
if (textColor != null) {
|
||||
list.add(ForegroundColorSpan(textColor))
|
||||
}
|
||||
if (clickSpan != null) {
|
||||
list.add(clickSpan)
|
||||
}
|
||||
textBuilder.append(text, *list.toArray())
|
||||
}
|
||||
}
|
||||
|
||||
TemplateMessage.Content.IMAGE -> {
|
||||
val image = it.content.image
|
||||
val width = it.content.width ?: 0
|
||||
val height = it.content.height ?: 0
|
||||
val clickSpan = createClickSpan(textView.context, it.content, listener)
|
||||
if (height > 0 && width == 0) {
|
||||
if (clickSpan != null) {
|
||||
textBuilder.append(
|
||||
image,
|
||||
UiUtils.dip2px(height.toFloat()),
|
||||
clickSpan
|
||||
)
|
||||
} else {
|
||||
textBuilder.append(image, UiUtils.dip2px(height.toFloat()))
|
||||
}
|
||||
} else if (height > 0 && width > 0) {
|
||||
if (clickSpan != null) {
|
||||
textBuilder.append(
|
||||
image,
|
||||
UiUtils.dip2px(width.toFloat()),
|
||||
UiUtils.dip2px(height.toFloat()), clickSpan
|
||||
)
|
||||
} else {
|
||||
textBuilder.append(
|
||||
image,
|
||||
UiUtils.dip2px(width.toFloat()),
|
||||
UiUtils.dip2px(height.toFloat())
|
||||
)
|
||||
}
|
||||
} else {
|
||||
if (clickSpan != null) {
|
||||
textBuilder.appendImg(image, clickSpan)
|
||||
} else {
|
||||
textBuilder.appendImg(image)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
textView.text = textBuilder.build()
|
||||
textView.setOnClickListener(null)
|
||||
textView.movementMethod = LinkMovementMethod()
|
||||
}
|
||||
|
||||
private fun createClickSpan(
|
||||
context: Context,
|
||||
content: Content,
|
||||
listener: Listener?
|
||||
): OriginalDrawStatusClickSpan? {
|
||||
val skipType = content.getSkipType()
|
||||
val skipUri = content.getSkipUri()
|
||||
if (skipType > 0 && !skipUri.isNullOrEmpty()) {
|
||||
return object : OriginalDrawStatusClickSpan() {
|
||||
override fun onClick(widget: View) {
|
||||
if (skipType == BannerInfo.SKIP_TYPE_ROOM_USER_CARD) {
|
||||
listener?.onShowUserCard(skipUri)
|
||||
} else {
|
||||
CommonJumpHelper.bannerJump(context, content)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
fun parseColor(color: String?): Int? {
|
||||
if (color == null) {
|
||||
return null
|
||||
}
|
||||
try {
|
||||
return Color.parseColor(color)
|
||||
} catch (e: java.lang.Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
interface Listener {
|
||||
fun onShowUserCard(uid: String)
|
||||
}
|
||||
}
|
@@ -8,6 +8,7 @@ import android.util.AttributeSet
|
||||
import android.widget.ProgressBar
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import com.chwl.app.R
|
||||
import com.example.lib_utils.UiUtils
|
||||
|
||||
class VipProgressBar(context: Context, attrs: AttributeSet?) : ProgressBar(context, attrs) {
|
||||
|
||||
@@ -19,6 +20,10 @@ class VipProgressBar(context: Context, attrs: AttributeSet?) : ProgressBar(conte
|
||||
private var mHeight = 0
|
||||
private val leftPadding = ScreenUtil.dip2px(9f)
|
||||
|
||||
private var isRTL = false
|
||||
init {
|
||||
isRTL = UiUtils.isRtl(context)
|
||||
}
|
||||
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||
super.onSizeChanged(w, h, oldw, oldh)
|
||||
mWidth = w
|
||||
@@ -28,7 +33,10 @@ class VipProgressBar(context: Context, attrs: AttributeSet?) : ProgressBar(conte
|
||||
@Synchronized
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
super.onDraw(canvas)
|
||||
val radio = progress * 1.0f / max
|
||||
var radio = progress * 1.0f / max
|
||||
if (isRTL) {
|
||||
radio = 1 - radio
|
||||
}
|
||||
canvas.drawBitmap(
|
||||
thumbBitmap,
|
||||
(mWidth - leftPadding * 2) * radio - thumbWidth / 2f + leftPadding,
|
||||
|
@@ -4,16 +4,10 @@ import static com.chwl.core.Constants.DEBUG_MAX_UID;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MESS_HEAD_NOBLE;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MESS_SUB_OPENNOBLE;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MESS_SUB_RENEWNOBLE;
|
||||
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_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_NOTIFY_H5_SUB_WHOLE_SERVICE;
|
||||
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_VIP;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_VIP_USER_ALL_UPGRADE;
|
||||
@@ -25,6 +19,7 @@ import android.app.Dialog;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Build;
|
||||
@@ -49,6 +44,8 @@ import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chwl.app.notify.GlobalNotifyManager;
|
||||
import com.chwl.library.language.LanguageHelper;
|
||||
import com.google.gson.Gson;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.netease.nimlib.sdk.NIMSDK;
|
||||
@@ -87,11 +84,9 @@ import com.chwl.app.ui.widget.dialog.OpenNobleGlobalNoticeDialog;
|
||||
import com.chwl.app.utils.UserUtils;
|
||||
import com.chwl.core.XConstants;
|
||||
import com.chwl.core.bean.BaseProtocol;
|
||||
import com.chwl.core.gift.bean.LuckyBagNoticeInfo;
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment;
|
||||
import com.chwl.core.im.custom.bean.NotifyH5Info;
|
||||
import com.chwl.core.im.custom.bean.PlayEffectInfo;
|
||||
import com.chwl.core.im.custom.bean.RoomBoxPrizeInfo;
|
||||
import com.chwl.core.im.custom.bean.RoomLuckySeaMsgBean;
|
||||
import com.chwl.core.im.custom.bean.TarotMsgBean;
|
||||
import com.chwl.core.manager.IMNetEaseManager;
|
||||
@@ -176,6 +171,7 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
if (roomEvent == null) return;
|
||||
onReceiveChatRoomEvent(roomEvent);
|
||||
}));
|
||||
GlobalNotifyManager.INSTANCE.bindActivity(this);
|
||||
}
|
||||
|
||||
protected void onReceiveChatRoomEvent(RoomEvent roomEvent) {
|
||||
@@ -515,6 +511,18 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
super.attachBaseContext(LanguageHelper.INSTANCE.wrapContext(newBase));
|
||||
LanguageHelper.INSTANCE.wrapContext(newBase.getApplicationContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
LanguageHelper.INSTANCE.changeLanguage(this, LanguageHelper.INSTANCE.getCurrentLanguage());
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@Override
|
||||
protected void onResume() {
|
||||
@@ -858,6 +866,10 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
return rxPermissions.request(mPerms);
|
||||
}
|
||||
|
||||
public RxPermissions getRxPermissions() {
|
||||
return rxPermissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收到全局广播信息
|
||||
*
|
||||
@@ -930,62 +942,62 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_HEADER_TYPE_GIFT:
|
||||
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
|
||||
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|
||||
// || this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|
||||
|| UserUtils.getUserInfo() == null)
|
||||
return;
|
||||
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 (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
|
||||
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|
||||
// || this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|
||||
|| UserUtils.getUserInfo() == null)
|
||||
return;
|
||||
if (playEffectList == null) {
|
||||
playEffectList = new LinkedList<>();
|
||||
}
|
||||
RoomBoxPrizeInfo roomBoxPrizeInfo = JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomBoxPrizeInfo.class);
|
||||
if (roomBoxPrizeInfo == null) return;
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
|
||||
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
|
||||
playEffectInfo.setSecond(CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA);
|
||||
playEffectInfo.setRoomBoxPrizeInfo(roomBoxPrizeInfo);
|
||||
playEffectList.add(playEffectInfo);
|
||||
if (playEffectDialog != null && playEffectDialog.isShowing()) {
|
||||
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
|
||||
PlayEffectInfo dataBean = playEffectList.peekFirst();
|
||||
if (dataBean != null) {
|
||||
return;
|
||||
} else {
|
||||
playEffectDialog.dismiss();
|
||||
}
|
||||
} else {
|
||||
showPlayEffectDialog();
|
||||
}
|
||||
}
|
||||
break;
|
||||
// case CUSTOM_MSG_HEADER_TYPE_GIFT:
|
||||
// if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
|
||||
// if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|
||||
//// || this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|
||||
// || UserUtils.getUserInfo() == null)
|
||||
// return;
|
||||
// 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 (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
|
||||
// if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|
||||
//// || this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|
||||
// || UserUtils.getUserInfo() == null)
|
||||
// return;
|
||||
// if (playEffectList == null) {
|
||||
// playEffectList = new LinkedList<>();
|
||||
// }
|
||||
// RoomBoxPrizeInfo roomBoxPrizeInfo = JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomBoxPrizeInfo.class);
|
||||
// if (roomBoxPrizeInfo == null) return;
|
||||
// if (baseProtocol.getSecond() == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
|
||||
// PlayEffectInfo playEffectInfo = new PlayEffectInfo();
|
||||
// playEffectInfo.setSecond(CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA);
|
||||
// playEffectInfo.setRoomBoxPrizeInfo(roomBoxPrizeInfo);
|
||||
// playEffectList.add(playEffectInfo);
|
||||
// if (playEffectDialog != null && playEffectDialog.isShowing()) {
|
||||
// // 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
|
||||
// PlayEffectInfo dataBean = playEffectList.peekFirst();
|
||||
// if (dataBean != null) {
|
||||
// return;
|
||||
// } else {
|
||||
// playEffectDialog.dismiss();
|
||||
// }
|
||||
// } else {
|
||||
// showPlayEffectDialog();
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
case CustomAttachment.CUSTOM_MESS_TAROT:
|
||||
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
|
||||
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|
||||
@@ -1074,35 +1086,35 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_LUCKY_GIFT://福袋
|
||||
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
|
||||
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|
||||
// || this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|
||||
|| UserUtils.getUserInfo() == null)
|
||||
return;
|
||||
if (playEffectList == null) {
|
||||
playEffectList = new LinkedList<>();
|
||||
}
|
||||
LuckyBagNoticeInfo luckyBagNoticeInfo = JSON.parseObject(String.valueOf(baseProtocol.getData()), LuckyBagNoticeInfo.class);
|
||||
if (luckyBagNoticeInfo == null) return;
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL) {
|
||||
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
|
||||
playEffectInfo.setSecond(CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL);
|
||||
playEffectInfo.setLuckyBagNoticeInfo(luckyBagNoticeInfo);
|
||||
playEffectList.add(playEffectInfo);
|
||||
if (playEffectDialog != null && playEffectDialog.isShowing()) {
|
||||
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
|
||||
PlayEffectInfo dataBean = playEffectList.peekFirst();
|
||||
if (dataBean != null) {
|
||||
return;
|
||||
} else {
|
||||
playEffectDialog.dismiss();
|
||||
}
|
||||
} else {
|
||||
showPlayEffectDialog();
|
||||
}
|
||||
}
|
||||
break;
|
||||
// case CUSTOM_MSG_LUCKY_GIFT://福袋
|
||||
// if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
|
||||
// if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|
||||
//// || this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|
||||
// || UserUtils.getUserInfo() == null)
|
||||
// return;
|
||||
// if (playEffectList == null) {
|
||||
// playEffectList = new LinkedList<>();
|
||||
// }
|
||||
// LuckyBagNoticeInfo luckyBagNoticeInfo = JSON.parseObject(String.valueOf(baseProtocol.getData()), LuckyBagNoticeInfo.class);
|
||||
// if (luckyBagNoticeInfo == null) return;
|
||||
// if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL) {
|
||||
// PlayEffectInfo playEffectInfo = new PlayEffectInfo();
|
||||
// playEffectInfo.setSecond(CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL);
|
||||
// playEffectInfo.setLuckyBagNoticeInfo(luckyBagNoticeInfo);
|
||||
// playEffectList.add(playEffectInfo);
|
||||
// if (playEffectDialog != null && playEffectDialog.isShowing()) {
|
||||
// // 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
|
||||
// PlayEffectInfo dataBean = playEffectList.peekFirst();
|
||||
// if (dataBean != null) {
|
||||
// return;
|
||||
// } else {
|
||||
// playEffectDialog.dismiss();
|
||||
// }
|
||||
// } else {
|
||||
// showPlayEffectDialog();
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
case CUSTOM_MSG_FAIRY://夺宝精灵
|
||||
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
|
||||
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|
||||
@@ -1360,14 +1372,14 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
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;
|
||||
baseMvpActivity.onReceivedNimBroadcastMessage(body);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
jsonObject = null;
|
||||
}
|
||||
if (jsonObject == null) return;
|
||||
if (jsonObject.containsKey("body")) {
|
||||
String body = jsonObject.getString("body");
|
||||
if (TextUtils.isEmpty(body)) return;
|
||||
baseMvpActivity.onReceivedNimBroadcastMessage(body);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.util.Consumer;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
@@ -56,6 +57,7 @@ public abstract class BaseFragment extends RxFragment implements KeyEvent.Callba
|
||||
protected RxPermissions rxPermissions;
|
||||
|
||||
private boolean isLoaded = false;
|
||||
public Consumer<Boolean> onHiddenChangedListener;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@@ -182,6 +184,9 @@ public abstract class BaseFragment extends RxFragment implements KeyEvent.Callba
|
||||
@Override
|
||||
public void onHiddenChanged(boolean hidden) {
|
||||
super.onHiddenChanged(hidden);
|
||||
if (onHiddenChangedListener != null) {
|
||||
onHiddenChangedListener.accept(hidden);
|
||||
}
|
||||
}
|
||||
|
||||
public Stack<Integer> activityForResult = new Stack<Integer>();
|
||||
|
@@ -19,7 +19,7 @@ open class BaseViewModel : ViewModel() {
|
||||
|
||||
fun safeLaunch(
|
||||
needLoading: Boolean = false,
|
||||
onError: (e: Throwable) -> Unit = {
|
||||
onError: suspend(e: Throwable) -> Unit = {
|
||||
if (it.message != "Job was cancelled") {
|
||||
val message = ExceptionHandle.handleException(it)
|
||||
message.toast()
|
||||
|
22
app/src/main/java/com/chwl/app/base/GlobalViewModelOwner.kt
Normal file
22
app/src/main/java/com/chwl/app/base/GlobalViewModelOwner.kt
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.chwl.app.base
|
||||
|
||||
|
||||
import androidx.lifecycle.ViewModelStore
|
||||
import androidx.lifecycle.ViewModelStoreOwner
|
||||
import com.example.lib_utils.ICleared
|
||||
|
||||
class GlobalViewModelOwner : ViewModelStoreOwner, ICleared {
|
||||
|
||||
companion object {
|
||||
private val viewModelStore by lazy { ViewModelStore() }
|
||||
val instance by lazy { GlobalViewModelOwner() }
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
viewModelStore.clear()
|
||||
}
|
||||
|
||||
override val viewModelStore: ViewModelStore
|
||||
get() = GlobalViewModelOwner.viewModelStore
|
||||
}
|
@@ -11,6 +11,7 @@ import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.LayoutDirection;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -20,9 +21,12 @@ import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.text.TextUtilsCompat;
|
||||
|
||||
import com.chwl.app.R;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* 类描述:
|
||||
@@ -446,18 +450,33 @@ public class TitleBar extends ViewGroup implements View.OnClickListener {
|
||||
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), height);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
mLeftLayout.layout(0, mStatusBarHeight, mLeftLayout.getMeasuredWidth(), mLeftLayout.getMeasuredHeight() + mStatusBarHeight);
|
||||
mRightLayout.layout(mScreenWidth - mRightLayout.getMeasuredWidth(), mStatusBarHeight,
|
||||
mScreenWidth, mRightLayout.getMeasuredHeight() + mStatusBarHeight);
|
||||
if (mLeftLayout.getMeasuredWidth() > mRightLayout.getMeasuredWidth()) {
|
||||
mCenterLayout.layout(mLeftLayout.getMeasuredWidth(), mStatusBarHeight,
|
||||
mScreenWidth - mLeftLayout.getMeasuredWidth(), getMeasuredHeight());
|
||||
if(TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == LayoutDirection.RTL) {
|
||||
mRightLayout.layout(0, mStatusBarHeight, mRightLayout.getMeasuredWidth(), mRightLayout.getMeasuredHeight() + mStatusBarHeight);
|
||||
mLeftLayout.layout(mScreenWidth - mLeftLayout.getMeasuredWidth(), mStatusBarHeight,
|
||||
mScreenWidth, mLeftLayout.getMeasuredHeight() + mStatusBarHeight);
|
||||
if (mRightLayout.getMeasuredWidth() > mLeftLayout.getMeasuredWidth()) {
|
||||
mCenterLayout.layout(mRightLayout.getMeasuredWidth(), mStatusBarHeight,
|
||||
mScreenWidth - mRightLayout.getMeasuredWidth(), getMeasuredHeight());
|
||||
} else {
|
||||
mCenterLayout.layout(mLeftLayout.getMeasuredWidth(), mStatusBarHeight,
|
||||
mScreenWidth - mLeftLayout.getMeasuredWidth(), getMeasuredHeight());
|
||||
}
|
||||
} else {
|
||||
mCenterLayout.layout(mRightLayout.getMeasuredWidth(), mStatusBarHeight,
|
||||
mScreenWidth - mRightLayout.getMeasuredWidth(), getMeasuredHeight());
|
||||
mLeftLayout.layout(0, mStatusBarHeight, mLeftLayout.getMeasuredWidth(), mLeftLayout.getMeasuredHeight() + mStatusBarHeight);
|
||||
mRightLayout.layout(mScreenWidth - mRightLayout.getMeasuredWidth(), mStatusBarHeight,
|
||||
mScreenWidth, mRightLayout.getMeasuredHeight() + mStatusBarHeight);
|
||||
if (mLeftLayout.getMeasuredWidth() > mRightLayout.getMeasuredWidth()) {
|
||||
mCenterLayout.layout(mLeftLayout.getMeasuredWidth(), mStatusBarHeight,
|
||||
mScreenWidth - mLeftLayout.getMeasuredWidth(), getMeasuredHeight());
|
||||
} else {
|
||||
mCenterLayout.layout(mRightLayout.getMeasuredWidth(), mStatusBarHeight,
|
||||
mScreenWidth - mRightLayout.getMeasuredWidth(), getMeasuredHeight());
|
||||
}
|
||||
}
|
||||
|
||||
mDividerView.layout(0, getMeasuredHeight() - mDividerView.getMeasuredHeight(), getMeasuredWidth(), getMeasuredHeight());
|
||||
}
|
||||
|
||||
|
@@ -10,10 +10,8 @@ import com.chwl.app.base.TitleBar;
|
||||
import com.chwl.app.bills.adapter.GiftExpendAdapter;
|
||||
import com.chwl.app.databinding.ActivityBillsGiftBinding;
|
||||
import com.chwl.app.ui.pay.ChargeActivity;
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity;
|
||||
import com.chwl.app.ui.widget.RecyclerViewNoBugLinearLayoutManager;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.core.UriProvider;
|
||||
import com.chwl.core.bills.BillModel;
|
||||
import com.chwl.core.bills.bean.BillItemEntity;
|
||||
import com.chwl.core.bills.bean.ExpendInfo;
|
||||
@@ -21,8 +19,6 @@ import com.chwl.core.bills.bean.ExpendListInfo;
|
||||
import com.chwl.core.pay.PayModel;
|
||||
import com.chwl.core.pay.bean.WalletInfo;
|
||||
import com.chwl.library.annatation.ActLayoutRes;
|
||||
import com.chwl.library.common.util.DeviceUtil;
|
||||
import com.chwl.library.utils.AppMetaDataUtil;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.chwl.app.bills.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
@@ -13,10 +12,8 @@ import com.chwl.app.base.TitleBar;
|
||||
import com.chwl.app.bills.adapter.GiftIncomeAdapter;
|
||||
import com.chwl.app.databinding.ActivityBillsGiftBinding;
|
||||
import com.chwl.app.ui.pay.ChargeActivity;
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity;
|
||||
import com.chwl.app.ui.widget.RecyclerViewNoBugLinearLayoutManager;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.core.UriProvider;
|
||||
import com.chwl.core.bills.BillModel;
|
||||
import com.chwl.core.bills.bean.BillItemEntity;
|
||||
import com.chwl.core.bills.bean.IncomeInfo;
|
||||
@@ -24,8 +21,6 @@ import com.chwl.core.bills.bean.IncomeListInfo;
|
||||
import com.chwl.core.pay.PayModel;
|
||||
import com.chwl.core.pay.bean.WalletInfo;
|
||||
import com.chwl.library.annatation.ActLayoutRes;
|
||||
import com.chwl.library.common.util.DeviceUtil;
|
||||
import com.chwl.library.utils.AppMetaDataUtil;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
|
@@ -12,18 +12,14 @@ import com.chwl.app.base.TitleBar;
|
||||
import com.chwl.app.bills.adapter.ChargeBillsAdapter;
|
||||
import com.chwl.app.databinding.ActivityBillsBinding;
|
||||
import com.chwl.app.ui.pay.ChargeActivity;
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity;
|
||||
import com.chwl.app.ui.widget.RecyclerViewNoBugLinearLayoutManager;
|
||||
import com.chwl.core.XConstants;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.core.UriProvider;
|
||||
import com.chwl.core.bills.BillModel;
|
||||
import com.chwl.core.bills.bean.BillItemEntity;
|
||||
import com.chwl.core.bills.bean.ExpendInfo;
|
||||
import com.chwl.core.bills.bean.ExpendListInfo;
|
||||
import com.chwl.library.annatation.ActLayoutRes;
|
||||
import com.chwl.library.common.util.DeviceUtil;
|
||||
import com.chwl.library.utils.AppMetaDataUtil;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
@@ -150,7 +146,7 @@ public class ChargeBillsActivity extends BillBaseActivity<ActivityBillsBinding>
|
||||
adapter.addData(billItemEntities);
|
||||
} else {
|
||||
if (mCurrentCounter == Constants.PAGE_START) {
|
||||
showNoData(R.drawable.icon_common_failure, XConstants.EMPTY_RECORD_AND_THREE_MONTHS_TIPSS);
|
||||
showNoData(R.drawable.icon_common_failure, ResUtil.getString(R.string.yizhuan_xchat_android_constants_xchatconstants_017));
|
||||
} else {
|
||||
adapter.loadMoreEnd(true);
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ public class ChargeBillsAdapter extends BillBaseAdapter {
|
||||
if (expendInfo == null) {
|
||||
return;
|
||||
}
|
||||
baseViewHolder.setText(R.id.tv_gold, ResUtil.getString(R.string.bills_adapter_chargebillsadapter_01) + expendInfo.getGoldNum() + ResUtil.getString(R.string.bills_adapter_chargebillsadapter_02))
|
||||
baseViewHolder.setText(R.id.tv_gold, ResUtil.getString(R.string.bills_adapter_chargebillsadapter_01) + expendInfo.getGoldNum() + ResUtil.getString(R.string.diamond))
|
||||
.setText(R.id.tv_money, expendInfo.getShowStr())
|
||||
.setText(R.id.tv_charge_time, TimeUtils.getYearMonthDayHourMinuteSecond(expendInfo.getRecordTime()));
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ public class WithdrawBillsAdapter extends BillBaseAdapter {
|
||||
IncomeInfo incomeInfo = billItemEntity.mWithdrawInfo;
|
||||
if (incomeInfo == null) return;
|
||||
baseViewHolder.setText(R.id.tv_date, TimeUtils.getYearMonthDayHourMinuteSecond(incomeInfo.getRecordTime()))
|
||||
.setText(R.id.tv_diamondNum, ResUtil.getString(R.string.bills_adapter_withdrawbillsadapter_01) + incomeInfo.getDiamondNum() + ResUtil.getString(R.string.bills_adapter_withdrawbillsadapter_02))
|
||||
.setText(R.id.tv_diamondNum, ResUtil.getString(R.string.bills_adapter_withdrawbillsadapter_01) + incomeInfo.getDiamondNum() + ResUtil.getString(R.string.diamond))
|
||||
.setText(R.id.tv_money, "+" + incomeInfo.getMoney() + ResUtil.getString(R.string.bills_adapter_withdrawbillsadapter_03));
|
||||
}
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ public class WithdrawRedBillsAdapter extends BillBaseAdapter {
|
||||
public void convertNormal(BaseViewHolder baseViewHolder, BillItemEntity billItemEntity) {
|
||||
RedBagInfo redBagInfo = billItemEntity.mRedBagInfo;
|
||||
if (redBagInfo == null) return;
|
||||
baseViewHolder.setText(R.id.tv_diamondNum, ResUtil.getString(R.string.bills_adapter_withdrawredbillsadapter_01) + redBagInfo.getPacketNum() + ResUtil.getString(R.string.bills_adapter_withdrawredbillsadapter_02))
|
||||
baseViewHolder.setText(R.id.tv_diamondNum, ResUtil.getString(R.string.bills_adapter_withdrawredbillsadapter_01) + redBagInfo.getPacketNum() + ResUtil.getString(R.string.diamond))
|
||||
.setText(R.id.tv_date, TimeUtils.getYearMonthDayHourMinuteSecond(redBagInfo.getCreateTime()))
|
||||
// .setText(R.id.tv_money, "+" + redBagInfo.getMoney() + ResUtil.getString(R.string.bills_adapter_withdrawredbillsadapter_03))
|
||||
;
|
||||
|
@@ -20,6 +20,7 @@ import com.chwl.core.bills.bean.IncomeInfo;
|
||||
import com.chwl.core.bills.bean.IncomeListInfo;
|
||||
import com.chwl.library.base.factory.CreatePresenter;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -124,7 +125,7 @@ public class GiftIncomeFragment extends BaseBillsFragment<IGiftIncomeView, GiftI
|
||||
adapter.addData(billItemEntities);
|
||||
} else {
|
||||
if (mCurrentCounter == Constants.PAGE_START) {
|
||||
showNoData(R.drawable.icon_common_failure, XConstants.EMPTY_RECORD_AND_THREE_MONTHS_TIPSS);
|
||||
showNoData(R.drawable.icon_common_failure, ResUtil.getString(R.string.yizhuan_xchat_android_constants_xchatconstants_017));
|
||||
} else {
|
||||
adapter.loadMoreEnd(true);
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ import com.chwl.core.bills.bean.ExpendInfo;
|
||||
import com.chwl.core.bills.bean.ExpendListInfo;
|
||||
import com.chwl.library.base.factory.CreatePresenter;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -125,7 +126,7 @@ public class GiftOutputFragment extends BaseBillsFragment<IGiftOutputView, GiftO
|
||||
adapter.addData(billItemEntities);
|
||||
} else {
|
||||
if (mCurrentCounter == Constants.PAGE_START) {
|
||||
showNoData(R.drawable.icon_common_failure, XConstants.EMPTY_RECORD_AND_THREE_MONTHS_TIPSS);
|
||||
showNoData(R.drawable.icon_common_failure, ResUtil.getString(R.string.yizhuan_xchat_android_constants_xchatconstants_017));
|
||||
} else {
|
||||
adapter.loadMoreEnd(true);
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@ import com.chwl.core.bills.bean.IncomeInfo;
|
||||
import com.chwl.core.bills.bean.IncomeListInfo;
|
||||
import com.chwl.library.annatation.ActLayoutRes;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@@ -157,7 +158,7 @@ public class WithdrawBillsFragment extends BaseBindingFragment<FragmentXrexylerv
|
||||
adapter.addData(billItemEntities);
|
||||
} else {
|
||||
if (mCurrentCounter == 1) {
|
||||
showNoData(R.drawable.icon_common_failure, XConstants.EMPTY_RECORD_AND_THREE_MONTHS_TIPSS);
|
||||
showNoData(R.drawable.icon_common_failure, ResUtil.getString(R.string.yizhuan_xchat_android_constants_xchatconstants_017));
|
||||
} else {
|
||||
adapter.loadMoreEnd(true);
|
||||
}
|
||||
|
@@ -21,12 +21,10 @@ import com.chwl.app.R;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.chwl.app.view.GenderAgeTextView;
|
||||
import com.chwl.core.utils.StarUtils;
|
||||
import com.chwl.library.utils.TimeUtils;
|
||||
import com.chwl.library.utils.config.BasicConfig;
|
||||
import com.chwl.library.widget.IOSSwitchView;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by huangmeng1 on 2018/1/4.
|
||||
|
@@ -207,7 +207,7 @@ class PhotoDialog : BaseDialogFragment<PhotoDialogBinding>(), EasyPermissions.Pe
|
||||
REQUEST_CODE_OPEN_CAMERA_PROVIDER -> {
|
||||
if (mOnResultCallBack == null || data == null) return
|
||||
PhotoProvider.getResultPathListAsync(data) { paths ->
|
||||
val list = paths?.toMutableList() ?: ArrayList()
|
||||
val list = paths?.mapNotNull { it.path }?.toMutableList() ?: ArrayList()
|
||||
val path = list[0]
|
||||
if (!TextUtils.isEmpty(path)) {
|
||||
mJob?.cancel()
|
||||
@@ -233,7 +233,7 @@ class PhotoDialog : BaseDialogFragment<PhotoDialogBinding>(), EasyPermissions.Pe
|
||||
REQUEST_CODE_OPEN_PHOTO_PROVIDER -> {
|
||||
if (mOnResultCallBack == null || data == null) return
|
||||
PhotoProvider.getResultPathListAsync(data) { list ->
|
||||
val paths = list?.toMutableList() ?: ArrayList()
|
||||
val paths = list?.mapNotNull { it.path }?.toMutableList() ?: ArrayList()
|
||||
if (paths.isEmpty()) {
|
||||
mOnResultCallBack?.choicePhotoCallBack(paths)
|
||||
} else {
|
||||
|
@@ -130,7 +130,7 @@ object PhotoProvider {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getResultPathListAsync(data: Intent?, resultListener: ((List<String>?) -> Unit)) {
|
||||
fun getResultPathListAsync(data: Intent?, resultListener: ((List<Photo>?) -> Unit)) {
|
||||
cancelJop()
|
||||
mPhotoJob = MainScope().launch {
|
||||
val list: List<Photo>? = data?.getParcelableArrayListExtra(EasyPhotos.RESULT_PHOTOS)
|
||||
@@ -150,22 +150,21 @@ object PhotoProvider {
|
||||
* 1. 项目使用到BitmapFactory.decodeFile(imgPath, options)之类的方法,该方法在android Q直接使用外部path测试中发现,获取图片信息失败
|
||||
*
|
||||
*/
|
||||
private fun copyToInternalCache(photos: List<Photo>?): List<String>? {
|
||||
private fun copyToInternalCache(photos: List<Photo>?): List<Photo>? {
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
val foldPath = getInternalPath() + File.separator
|
||||
val newPaths = ArrayList<String>()
|
||||
photos?.forEach {
|
||||
if (it.uri != null && !it.name.isNullOrEmpty()) {
|
||||
val path = "$foldPath${it.name}"
|
||||
if (FileHelper.copyFileFromUri(it.uri, path, true)) {
|
||||
newPaths.add(path)
|
||||
it.path = path
|
||||
LibLogger.debug(TAG, "path: ${it.path} , displayName: ${it.name} , newPath: $path ")
|
||||
}
|
||||
}
|
||||
}
|
||||
newPaths
|
||||
photos
|
||||
} else {
|
||||
photos?.takeIf { it.isNotEmpty() }?.map { it.path }
|
||||
photos
|
||||
}
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user