Compare commits
270 Commits
master
...
release2.2
Author | SHA1 | Date | |
---|---|---|---|
![]() |
bdcfb21e6e | ||
![]() |
5c7d2e9645 | ||
![]() |
d2f24c4457 | ||
![]() |
7ec11e0aba | ||
![]() |
f4a9690c1b | ||
![]() |
0742894540 | ||
![]() |
d0fe8e892e | ||
![]() |
b9120dca54 | ||
![]() |
8ebaddad07 | ||
![]() |
b63b4ba07a | ||
![]() |
a211267517 | ||
![]() |
d0e88440e3 | ||
![]() |
260ed56c99 | ||
![]() |
505917b70f | ||
![]() |
03d013fcba | ||
![]() |
19301bbd84 | ||
![]() |
694a73931b | ||
![]() |
d34929d7c7 | ||
![]() |
73eccecfc9 | ||
![]() |
eb1546570a | ||
![]() |
7ba43a51d4 | ||
![]() |
bae4660840 | ||
![]() |
b9fd24e0ff | ||
![]() |
4bef25e1e3 | ||
![]() |
72480daa98 | ||
![]() |
1defcb0d28 | ||
![]() |
4885a0bdbd | ||
![]() |
5900702ca6 | ||
![]() |
9e6928580f | ||
![]() |
e644ced1ed | ||
![]() |
1667dd3863 | ||
![]() |
c04d3e283b | ||
![]() |
2b6d66c31e | ||
![]() |
e56bbb5f8f | ||
![]() |
7bf7e232d0 | ||
![]() |
d63a441296 | ||
![]() |
e81ec19168 | ||
![]() |
588b96ec7b | ||
![]() |
514abbc314 | ||
![]() |
94d9183952 | ||
![]() |
6eedd5cc46 | ||
![]() |
087091275f | ||
![]() |
f54a8ec175 | ||
![]() |
fee8f2ceb9 | ||
![]() |
a18a66b496 | ||
![]() |
80e21bee74 | ||
![]() |
e031dd9d02 | ||
![]() |
19a3b64a32 | ||
![]() |
34a5571338 | ||
![]() |
5b4eeb80e8 | ||
![]() |
f7889ace18 | ||
![]() |
cfc909df42 | ||
![]() |
ebc989cccf | ||
![]() |
5ad1c017c3 | ||
![]() |
15a80f5537 | ||
![]() |
38fde6109b | ||
![]() |
3199114ff6 | ||
![]() |
57139f1f97 | ||
![]() |
c7d7d98873 | ||
![]() |
d7da6d4be4 | ||
![]() |
b9a2f03184 | ||
![]() |
5ef9be75d2 | ||
![]() |
cf3ab9ce84 | ||
![]() |
3ba31c46d8 | ||
![]() |
e8f7eca1af | ||
![]() |
d93b6fbf60 | ||
![]() |
6ec57834fd | ||
![]() |
c3dab80e71 | ||
![]() |
60e56beb43 | ||
![]() |
a0667bdd8d | ||
![]() |
ba65ad680f | ||
![]() |
5163c2dc9d | ||
![]() |
ad5a769f25 | ||
![]() |
be291fa7e1 | ||
![]() |
27713e5300 | ||
![]() |
80e180f2b8 | ||
![]() |
ba93c9c0fe | ||
![]() |
6f9d1d81ad | ||
![]() |
81d0cd819d | ||
![]() |
36897df28b | ||
![]() |
6bdfe0426e | ||
![]() |
997b7ee9a3 | ||
![]() |
b885a24b8e | ||
![]() |
5d2551e04f | ||
![]() |
309e696a07 | ||
![]() |
68c9c6a8cb | ||
![]() |
448e6800ab | ||
![]() |
068ffcbed4 | ||
![]() |
cf7b49b69d | ||
![]() |
09fd7c586a | ||
![]() |
03b77fae08 | ||
![]() |
b75ba89d75 | ||
![]() |
2074039de2 | ||
![]() |
6b580ad2a6 | ||
![]() |
6134962297 | ||
![]() |
ce5cc20ac4 | ||
![]() |
bc718f26c6 | ||
![]() |
8f9a5bd565 | ||
![]() |
623a721e58 | ||
![]() |
a9be418fc3 | ||
![]() |
5b781b890c | ||
![]() |
4a6892d0c6 | ||
![]() |
a6e6992b1a | ||
![]() |
248e306e85 | ||
![]() |
bce08e82ca | ||
![]() |
32814780c2 | ||
![]() |
d0dc4cab49 | ||
![]() |
80d571d1d1 | ||
![]() |
b92c97dfb9 | ||
![]() |
e585899c44 | ||
![]() |
03f28b7be0 | ||
![]() |
c7225892f0 | ||
![]() |
f8d4601c38 | ||
![]() |
ce4fce319e | ||
![]() |
ce4293ec35 | ||
![]() |
1c9de5f03a | ||
![]() |
2734ff1ff2 | ||
![]() |
c7a28c5ac9 | ||
![]() |
ae4d327baf | ||
![]() |
9e9eb5d5b7 | ||
![]() |
96b1ad9e4c | ||
![]() |
48c527e789 | ||
![]() |
4e0a55ae46 | ||
![]() |
c85065d86c | ||
![]() |
c1371fab10 | ||
![]() |
6717f9aa69 | ||
![]() |
61cafd8c8c | ||
![]() |
e4f0853d3e | ||
![]() |
46a2985a49 | ||
![]() |
b2f9f07ded | ||
![]() |
5023d9a250 | ||
![]() |
29957775e0 | ||
![]() |
5f73c46868 | ||
![]() |
656eea5ebc | ||
![]() |
f9b8c20d85 | ||
![]() |
2d7b55ad0d | ||
![]() |
91350218d6 | ||
![]() |
ca56ee0877 | ||
![]() |
23214de384 | ||
![]() |
da45a64af9 | ||
![]() |
e236ef2aff | ||
![]() |
7de533bf3f | ||
![]() |
e23363c736 | ||
![]() |
4395951973 | ||
![]() |
e02020577d | ||
![]() |
61306e833a | ||
![]() |
49ba0a2701 | ||
![]() |
2e32184248 | ||
![]() |
bab64db25c | ||
![]() |
612502153c | ||
![]() |
9cdb0eef53 | ||
![]() |
6528ac407a | ||
![]() |
94d18e6035 | ||
![]() |
08abf47890 | ||
![]() |
cb89eccf23 | ||
![]() |
b57622ad42 | ||
![]() |
fd71af897f | ||
![]() |
1998258bda | ||
![]() |
5cce2cb68c | ||
![]() |
08230c55a3 | ||
![]() |
f51dec1101 | ||
![]() |
1dd5d64a09 | ||
![]() |
30d793d794 | ||
![]() |
d2fb38f094 | ||
![]() |
01958edd06 | ||
![]() |
5a2903d14d | ||
![]() |
1bade9dd00 | ||
![]() |
8d7ab335e2 | ||
![]() |
8bf25ad378 | ||
![]() |
6e11cfb30d | ||
![]() |
0c2fd28f15 | ||
![]() |
a2e0e9df53 | ||
![]() |
9e3ebfa541 | ||
![]() |
94a0575909 | ||
![]() |
3d161b94e4 | ||
![]() |
08d9534095 | ||
![]() |
ff1cd57d98 | ||
![]() |
2a57ad3145 | ||
![]() |
92f2db36ae | ||
![]() |
362c75f93c | ||
![]() |
b9c3bbdbec | ||
![]() |
0a24dc66e6 | ||
![]() |
ca62822bfb | ||
![]() |
5db5afa5ed | ||
![]() |
edad692309 | ||
![]() |
23a34434a0 | ||
![]() |
8ad38583ff | ||
![]() |
391fae9006 | ||
![]() |
9854e91fe8 | ||
![]() |
d587f1b43d | ||
![]() |
595d3a767a | ||
![]() |
4d13cf5e9c | ||
![]() |
62ce160dfa | ||
![]() |
c631c1d3a8 | ||
![]() |
27420aa51a | ||
![]() |
12c5344d72 | ||
![]() |
a716136090 | ||
![]() |
f860c96887 | ||
![]() |
873ecf1d2b | ||
![]() |
957b64476f | ||
![]() |
306e0a99a0 | ||
![]() |
bfd619e8b5 | ||
![]() |
4c0184c80b | ||
![]() |
aeb47da0ee | ||
![]() |
d99ef80d2e | ||
![]() |
77dcc9d117 | ||
![]() |
a7f17276c5 | ||
![]() |
63f1e02c6f | ||
![]() |
5c6657c538 | ||
![]() |
7548b4174a | ||
![]() |
068172bbd2 | ||
![]() |
0dda893e1f | ||
![]() |
928857f97d | ||
![]() |
46a2dab191 | ||
![]() |
877c3d9361 | ||
![]() |
ef8ca0b939 | ||
![]() |
50a20f7822 | ||
![]() |
9cc59dd275 | ||
![]() |
1ac47c055d | ||
![]() |
24f1437418 | ||
![]() |
f794fe960f | ||
![]() |
282036bb20 | ||
![]() |
ffab260d6a | ||
![]() |
8c47c3e717 | ||
![]() |
c36f127bce | ||
![]() |
d46ec289ea | ||
![]() |
a9405eb8f8 | ||
![]() |
f5d3f45001 | ||
![]() |
49f2764344 | ||
![]() |
e2a477bd0d | ||
![]() |
0cc24f4adf | ||
![]() |
44e918bd68 | ||
![]() |
cc21e2969a | ||
![]() |
cbe2234c83 | ||
![]() |
68e091131d | ||
![]() |
346b535757 | ||
![]() |
a16a918d06 | ||
![]() |
d3b6a16db9 | ||
![]() |
c34e8b034d | ||
![]() |
d2b0e904c8 | ||
![]() |
b57e7afb6d | ||
![]() |
edcabd157d | ||
![]() |
384831effa | ||
![]() |
f8f0c2c59b | ||
![]() |
96e3c65f2f | ||
![]() |
d8c1a89005 | ||
![]() |
e014e6a6b2 | ||
![]() |
144fa832f1 | ||
![]() |
9b7c0cae6b | ||
![]() |
f6f79f83dc | ||
![]() |
09f0eac2b3 | ||
![]() |
951c42592e | ||
![]() |
fdfec8610d | ||
![]() |
fcf9f65984 | ||
![]() |
2ef89535d5 | ||
![]() |
f742102a60 | ||
![]() |
eb73898872 | ||
![]() |
122f2d374f | ||
![]() |
7adefe8375 | ||
![]() |
34b9233825 | ||
![]() |
cd5b1728f8 | ||
![]() |
ac53bbd484 | ||
![]() |
48a096a64a | ||
![]() |
0dd0e131f2 | ||
![]() |
4999c6e955 | ||
![]() |
259c3e408a | ||
![]() |
58b66848d9 | ||
![]() |
bf805afdb5 | ||
![]() |
a1221fa5a5 | ||
![]() |
7515f50095 |
@@ -26,7 +26,7 @@ dependencies {
|
||||
api 'androidx.annotation:annotation:1.4.0'
|
||||
api 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation "androidx.core:core-ktx:1.7.0"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@@ -2,7 +2,6 @@ apply plugin: 'com.android.application'
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
apply plugin: 'com.google.firebase.crashlytics'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
apply plugin: 'com.tencent.vasdolly'
|
||||
apply from: '../mob.gradle'
|
||||
|
||||
@@ -21,20 +20,20 @@ android {
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
multiDexEnabled true
|
||||
|
||||
ndk {
|
||||
//设置支持的SO库架构
|
||||
if (onlyArm64) {
|
||||
abiFilters "arm64-v8a"
|
||||
} else {
|
||||
abiFilters "armeabi-v7a", "arm64-v8a"
|
||||
}
|
||||
}
|
||||
|
||||
flavorDimensions 'default'
|
||||
|
||||
manifestPlaceholders = [CRASHLYTICS_COLLECTION_ENABLED: CRASHLYTICS_COLLECTION_ENABLED.toBoolean()]
|
||||
}
|
||||
|
||||
splits {
|
||||
abi {
|
||||
enable true
|
||||
reset()
|
||||
include 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
|
||||
universalApk true
|
||||
}
|
||||
}
|
||||
|
||||
bundle {
|
||||
language {
|
||||
enableSplit = false
|
||||
@@ -48,20 +47,29 @@ android {
|
||||
}
|
||||
|
||||
//在apk文件后边生成版本号信息
|
||||
android.applicationVariants.all {
|
||||
variant ->
|
||||
variant.outputs.all {
|
||||
def date = new Date().format("MMddHHmm", TimeZone.getTimeZone("GMT+08"))
|
||||
outputFileName = "peko_${buildType.name}_v${defaultConfig.versionName}-${date}.apk"
|
||||
android.applicationVariants.configureEach { variant ->
|
||||
variant.outputs.configureEach { output ->
|
||||
def date = new Date().format("MMddHHmm", TimeZone.getTimeZone("GMT+08"))
|
||||
|
||||
def outputFile = output.outputFile
|
||||
if (outputFile == null || !outputFile.name.endsWith('.apk')) {
|
||||
return
|
||||
}
|
||||
|
||||
def abi = output.getFilter(com.android.build.OutputFile.ABI)
|
||||
if (abi == null) {
|
||||
abi = "universal"
|
||||
}
|
||||
outputFileName = "piko_${buildType.name}_v${defaultConfig.versionName}_${abi}_${date}.apk"
|
||||
}
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
lint {
|
||||
abortOnError false
|
||||
disable 'MissingTranslation'
|
||||
disable 'ExtraTranslation'
|
||||
disable 'MissingTranslation', 'ExtraTranslation', 'ContentDescription', 'SmallSp'
|
||||
}
|
||||
|
||||
|
||||
dataBinding {
|
||||
enabled = true
|
||||
}
|
||||
@@ -139,19 +147,23 @@ android {
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
def server_url_debug = '"http://beta.api.pekolive.com/"'
|
||||
def server_url_release = '"https://api.pekolive.com/"'
|
||||
|
||||
debug {
|
||||
println("minifyEnabled = " + minify_enabled)
|
||||
|
||||
ext.enableCrashlytics = false
|
||||
ext.alwaysUpdateBuildId = false // Firebase Crashlytics禁用更新构建ID
|
||||
|
||||
buildConfigField "String", "BASE_URL", "\"https://beta.api.pekolive.com/\""
|
||||
buildConfigField "String", "BASE_URL", server_url_debug
|
||||
buildConfigField "String", "BASE_URL_DEBUG", "BASE_URL"
|
||||
buildConfigField "String", "BASE_URL_STAGING", "BASE_URL"
|
||||
buildConfigField "String", "BASE_URL_RELEASE", "BASE_URL"
|
||||
minifyEnabled false // 是否混淆
|
||||
buildConfigField "String", "BASE_URL_RELEASE", server_url_release
|
||||
minifyEnabled minify_enabled.toBoolean() // 是否混淆
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
crunchPngs false // 停用 PNG 压缩
|
||||
signingConfig signingConfigs.v2
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
gradle.taskGraph.whenReady {
|
||||
tasks.each { task ->
|
||||
if (task.name.contains("Test") || task.name.contains("Lint")) {
|
||||
@@ -169,7 +181,7 @@ android {
|
||||
mappingFileUploadEnabled CRASHLYTICS_COLLECTION_ENABLED.toBoolean()
|
||||
}
|
||||
|
||||
buildConfigField "String", "BASE_URL", "\"https://api.pekolive.com/\""
|
||||
buildConfigField "String", "BASE_URL", server_url_release
|
||||
buildConfigField "String", "BASE_URL_DEBUG", "BASE_URL"
|
||||
buildConfigField "String", "BASE_URL_STAGING", "BASE_URL"
|
||||
buildConfigField "String", "BASE_URL_RELEASE", "BASE_URL"
|
||||
@@ -203,6 +215,9 @@ dependencies {
|
||||
implementation 'androidx.appcompat:appcompat:1.4.2'
|
||||
implementation 'com.google.android.material:material:1.6.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2'
|
||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
|
||||
@@ -287,6 +302,7 @@ dependencies {
|
||||
//wheelView
|
||||
implementation 'com.contrarywind:wheelview:4.1.0'
|
||||
|
||||
implementation 'tech.sud.mgp:SudMGP-static:1.3.3.1158'
|
||||
}
|
||||
|
||||
channel {
|
||||
@@ -294,7 +310,7 @@ channel {
|
||||
outputDir = new File(project.buildDir, "channelapk")
|
||||
//多渠道包的命名规则,默认为:${appName}-${versionName}-${versionCode}-${flavorName}-${buildType}-${buildTime}
|
||||
def only64 = onlyArm64 ? "-only64" : ""
|
||||
apkNameFormat = 'peko-${buildType}only64-${flavorName}-v${versionName}-${buildTime}'.replace("only64", only64)
|
||||
apkNameFormat = 'piko-${buildType}only64-${flavorName}-v${versionName}-${buildTime}'.replace("only64", only64)
|
||||
//快速模式:生成渠道包时不进行校验(速度可以提升10倍以上,默认为false)
|
||||
fastMode = false
|
||||
//buildTime的时间格式,默认格式:yyyyMMdd-HHmmss
|
||||
|
16
app/proguard-rules.pro
vendored
@@ -99,16 +99,18 @@
|
||||
-keep class android.support.v7.** { *;}
|
||||
|
||||
#----------------EventBus事件巴士-----------------
|
||||
-keepclassmembers class ** {
|
||||
-keepattributes *Annotation*
|
||||
-keepclassmembers class * {
|
||||
@org.greenrobot.eventbus.Subscribe <methods>;
|
||||
}
|
||||
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
|
||||
|
||||
# Only required if you use AsyncExecutor
|
||||
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
|
||||
<init>(Java.lang.Throwable);
|
||||
# If using AsyncExecutord, keep required constructor of default event used.
|
||||
# Adjust the class name if a custom failure event type is used.
|
||||
-keepclassmembers class org.greenrobot.eventbus.util.ThrowableFailureEvent {
|
||||
<init>(java.lang.Throwable);
|
||||
}
|
||||
|
||||
# Accessed via reflection, avoid renaming or removal
|
||||
-keep class org.greenrobot.eventbus.android.AndroidComponentsImpl
|
||||
|
||||
#-------------云信相关的混淆配置------------
|
||||
-dontwarn com.netease.**
|
||||
@@ -233,6 +235,8 @@
|
||||
-keep class org.json.** {*;}
|
||||
-dontwarn com.yizhuan.xchat_android_core.**
|
||||
-keep class com.yizhuan.xchat_android_core.** {*;}
|
||||
-keep class com.yizhuan.treasure_box.bean.** {*;}
|
||||
-keep class com.yizhuan.erban.avroom.bean.** {*;}
|
||||
|
||||
|
||||
#百度统计
|
||||
|
Before Width: | Height: | Size: 604 B After Width: | Height: | Size: 767 B |
Before Width: | Height: | Size: 709 B After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 373 B After Width: | Height: | Size: 692 B |
Before Width: | Height: | Size: 470 B After Width: | Height: | Size: 1.2 KiB |
@@ -51,8 +51,15 @@
|
||||
tools:node="remove" />
|
||||
<uses-permission android:name="android.permission.FLASHLIGHT" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
|
||||
<uses-permission
|
||||
android:name="android.permission.READ_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="32" />
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="32" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" /> <!-- 如果需要实时音视频通话模块,下面的权限也是必须的。否则,可以不加 -->
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <!-- SDK 权限申明, 第三方 APP 接入时,请将 com.netease.nim.demo 替换为自己的包名 -->
|
||||
@@ -72,6 +79,9 @@
|
||||
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
|
||||
<!-- AppsFlyer需要,参考:https://dev.appsflyer.com/hc/docs/install-android-sdk#setting-required-permissions -->
|
||||
<uses-permission android:name="com.google.android.gms.permission.AD_ID" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<!-- 对于 Android 12.0 及以上设备,还需要添加如下权限: -->
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||
|
||||
<application
|
||||
android:name=".application.XChatApplication"
|
||||
@@ -85,6 +95,7 @@
|
||||
android:theme="@style/MyMaterialTheme"
|
||||
tools:replace="android:name,android:allowBackup"
|
||||
tools:targetApi="n">
|
||||
|
||||
<activity
|
||||
android:name=".other.activity.SplashActivity"
|
||||
android:exported="true"
|
||||
@@ -111,7 +122,7 @@
|
||||
|
||||
<data
|
||||
android:host="main"
|
||||
android:scheme="pekoapp" />
|
||||
android:scheme="pikoapp" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
@@ -211,7 +222,7 @@
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:label="Peko"
|
||||
android:label="Piko"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustPan|stateAlwaysHidden" /> <!-- 配置的service和receiver -->
|
||||
@@ -243,6 +254,10 @@
|
||||
android:name=".avroom.activity.RoomBlackListActivity"
|
||||
android:label="@string/main_androidmanifest_09"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".module_hall.hall.activity.RoomIncomeActivity"
|
||||
android:label="房间流水"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.yizhuan.tutu.music.activity.AddLocalMusicListActivity"
|
||||
android:label="@string/main_androidmanifest_010"
|
||||
@@ -969,15 +984,14 @@
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".treasurefairy.HomeFairyActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden|mcc|mnc|locale|touchscreen|screenLayout|keyboard|navigation|fontScale|uiMode|smallestScreenSize|layoutDirection"
|
||||
android:exported="false"
|
||||
android:theme="@style/dialog_web_view_activity" />
|
||||
android:theme="@style/transparent_activity" />
|
||||
|
||||
<activity
|
||||
android:name=".ui.webview.FairyDialogWebViewActivity"
|
||||
android:configChanges="screenSize|orientation|keyboardHidden|mcc|mnc|locale|touchscreen|screenLayout|keyboard|navigation|fontScale|uiMode|smallestScreenSize|layoutDirection"
|
||||
android:exported="false"
|
||||
android:theme="@style/dialog_web_view_activity" />
|
||||
android:theme="@style/transparent_activity" />
|
||||
|
||||
<meta-data
|
||||
android:name="notch.config"
|
||||
@@ -1001,6 +1015,10 @@
|
||||
android:name="flutterEmbedding"
|
||||
android:value="2" />
|
||||
|
||||
<meta-data
|
||||
android:name="Mob-Https"
|
||||
android:value="yes" />
|
||||
|
||||
<provider
|
||||
android:name="com.netease.nimlib.ipc.NIMContentProvider"
|
||||
android:authorities="${applicationId}.ipc.provider"
|
||||
@@ -1018,8 +1036,7 @@
|
||||
android:name="com.netease.nimlib.service.NimReceiver"
|
||||
android:exported="false"
|
||||
android:process=":core"
|
||||
tools:node="remove">
|
||||
</receiver>
|
||||
tools:node="remove"></receiver>
|
||||
<receiver android:name="com.netease.nimlib.service.ResponseReceiver" />
|
||||
<receiver
|
||||
android:name=".reciever.IncomingCallReceiver"
|
||||
@@ -1029,6 +1046,7 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver android:name=".reciever.NotificationClickReceiver" />
|
||||
|
||||
<service
|
||||
android:name="com.netease.nimlib.service.NimService"
|
||||
android:process=":core" />
|
||||
@@ -1043,6 +1061,33 @@
|
||||
<service
|
||||
android:name=".service.DaemonService"
|
||||
android:enabled="true" />
|
||||
|
||||
<meta-data
|
||||
android:name="com.facebook.sdk.ApplicationId"
|
||||
android:value="@string/facebook_app_id" />
|
||||
<meta-data
|
||||
android:name="com.facebook.sdk.ClientToken"
|
||||
android:value="@string/facebook_client_token" />
|
||||
|
||||
<activity
|
||||
android:name="com.facebook.FacebookActivity"
|
||||
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
|
||||
android:label="@string/app_name" />
|
||||
<activity
|
||||
android:name="com.facebook.CustomTabActivity"
|
||||
android:exported="true">
|
||||
<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:scheme="@string/fb_login_protocol_scheme" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".avroom.room_album.RoomAlbumActivity" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
BIN
app/src/main/assets/svga/home_living.svga
Normal file
BIN
app/src/main/assets/svga/home_voice_playing.svga
Normal file
BIN
app/src/main/assets/svga/home_white_living.svga
Normal file
BIN
app/src/main/assets/svga/svga_home_pk.svga
Normal file
BIN
app/src/main/assets/svga/svga_notify_h5.svga
Normal file
BIN
app/src/main/assets/svga/svga_tarot_senior.svga
Normal file
@@ -214,6 +214,8 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
!TextUtils.isEmpty(linkedInfo.getDynamicId())) {
|
||||
DynamicDetailActivity.start(context, JavaUtil.str2long(linkedInfo.getDynamicId()),
|
||||
JavaUtil.str2long(linkedInfo.getWorldId()), 6);
|
||||
} else if (linkedInfo.getType().equals("7") && !TextUtils.isEmpty(linkedInfo.getUid())) {
|
||||
NimP2PMessageActivity.start(context, linkedInfo.getUid());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ import com.yizhuan.erban.relation.cp.dialog.CpGlobalDialog;
|
||||
import com.yizhuan.erban.ui.widget.LevelUpDialog;
|
||||
import com.yizhuan.erban.ui.widget.RecallDialog;
|
||||
import com.yizhuan.erban.ui.widget.lottery_dialog.LotteryDialogManager;
|
||||
import com.yizhuan.erban.vip.VipUpgradeDialog;
|
||||
import com.yizhuan.erban.vip.dialog.VipUpgradeDialog;
|
||||
import com.yizhuan.xchat_android_core.activity.bean.LotteryInfo;
|
||||
import com.yizhuan.xchat_android_core.level.event.CharmLevelUpEvent;
|
||||
import com.yizhuan.xchat_android_core.level.event.LevelUpEvent;
|
||||
@@ -27,8 +27,6 @@ import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
/**
|
||||
* 全局处理,比如App弹窗
|
||||
* create by lvzebiao @2019/8/14
|
||||
|
@@ -17,6 +17,7 @@ import androidx.multidex.MultiDex;
|
||||
|
||||
import com.bumptech.glide.request.target.ViewTarget;
|
||||
import com.coorchice.library.utils.LogUtils;
|
||||
import com.facebook.stetho.Stetho;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.mob.MobSDK;
|
||||
import com.mob.moblink.MobLink;
|
||||
@@ -48,7 +49,6 @@ import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.common.app.ActivityStack;
|
||||
import com.yizhuan.erban.common.util.AppLifeCycleHelper;
|
||||
import com.yizhuan.erban.module_hall.HallDataManager;
|
||||
import com.yizhuan.erban.other.activity.SplashActivity;
|
||||
import com.yizhuan.erban.radish.wallet.RadishWalletManager;
|
||||
import com.yizhuan.erban.utils.PushMessageHandler;
|
||||
import com.yizhuan.xchat_android_constants.XChatConstants;
|
||||
@@ -65,6 +65,7 @@ import com.yizhuan.xchat_android_core.im.custom.bean.OpenSignInAttachment;
|
||||
import com.yizhuan.xchat_android_core.initial.InitialModel;
|
||||
import com.yizhuan.xchat_android_core.interceptor.NoParamsInterceptor;
|
||||
import com.yizhuan.xchat_android_core.interceptor.ParamsInterceptor;
|
||||
import com.yizhuan.xchat_android_core.interceptor.TimeSyncInterceptor;
|
||||
import com.yizhuan.xchat_android_core.manager.IMMessageManager;
|
||||
import com.yizhuan.xchat_android_core.manager.IMSystemMsgManager;
|
||||
import com.yizhuan.xchat_android_core.market_verify.MarketVerifyModel;
|
||||
@@ -162,6 +163,11 @@ public class XChatApplication extends BaseApp {
|
||||
public String makeRevokeMsgTip(String s, IMMessage imMessage) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String makeCategory(IMMessage message) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
private static XChatApplication instance;
|
||||
//生命周期监听
|
||||
@@ -248,6 +254,7 @@ public class XChatApplication extends BaseApp {
|
||||
//fixed: Glide Exception:"You must not call setTag() on a view Glide is targeting"
|
||||
ViewTarget.setTagId(R.id.tag_glide);
|
||||
|
||||
initStetho(context);
|
||||
init(channel);
|
||||
|
||||
//生命周期监听
|
||||
@@ -401,6 +408,7 @@ public class XChatApplication extends BaseApp {
|
||||
.setBaseUrl(url)
|
||||
.addInterceptors(new ParamsInterceptor(httpParams))
|
||||
.addInterceptors(new NoParamsInterceptor())//注意:拦截器的添加顺序,请求的拦截顺序
|
||||
.addInterceptors(new TimeSyncInterceptor())
|
||||
.certificates()
|
||||
.build();
|
||||
//单例的model 初始化
|
||||
@@ -413,11 +421,11 @@ public class XChatApplication extends BaseApp {
|
||||
SVGAParser.Companion.shareParser().init(BasicConfig.INSTANCE.getAppContext());
|
||||
try {
|
||||
/** svga动画缓存路径 */
|
||||
File cacheDir = new File(BasicConfig.INSTANCE.getAppContext().getApplicationContext().getExternalCacheDir(), "http");
|
||||
if (!cacheDir.exists()) cacheDir.mkdirs();
|
||||
HttpResponseCache.install(cacheDir, 1024 * 1024 * 128);
|
||||
String cacheDirPath = FileHelper.getRootCacheDir().getAbsolutePath();
|
||||
File cacheFie = new File(cacheDirPath, "cacheDir");
|
||||
HttpResponseCache.install(cacheFie, 1024 * 1024 * 128);
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "testtest", e);
|
||||
Log.e(TAG, "HttpResponseCache install error :" + e.getMessage());
|
||||
}
|
||||
|
||||
initRxNet(BasicConfig.INSTANCE.getAppContext(), UriProvider.JAVA_WEB_URL);
|
||||
@@ -503,10 +511,7 @@ public class XChatApplication extends BaseApp {
|
||||
BasicConfig.INSTANCE.setAppContext(this.getApplicationContext());
|
||||
SharedPreferenceUtils.init(this);
|
||||
ResUtil.init(this);
|
||||
boolean isShowPrivacyAgreement = (boolean) SharedPreferenceUtils.get(SplashActivity.SHOW_PRIVACY_AGREEMENT, true);
|
||||
if (!isShowPrivacyAgreement) {
|
||||
initOtherSDK();
|
||||
}
|
||||
initOtherSDK();
|
||||
initContext(this);
|
||||
//首次启动事件
|
||||
HashMap<String, Object> map = new HashMap<>(2);
|
||||
@@ -542,4 +547,18 @@ public class XChatApplication extends BaseApp {
|
||||
unregisterActivityLifecycleCallbacks(lifeCycleHelper);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化Stetho(网络调试)
|
||||
*/
|
||||
private static void initStetho(Context context) {
|
||||
if (Env.isDebug()) {
|
||||
Stetho.initialize(
|
||||
Stetho.newInitializerBuilder(context)
|
||||
.enableDumpapp(Stetho.defaultDumperPluginsProvider(context))
|
||||
.enableWebKitInspector(Stetho.defaultInspectorModulesProvider(context))
|
||||
.build()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -109,6 +109,9 @@ public class AudioPlayerHelper {
|
||||
}
|
||||
|
||||
public void endPlay() {
|
||||
if (listener != null) {
|
||||
listener.onCompletion();
|
||||
}
|
||||
handler.removeMessages(WHAT_STATUS.COUNT_PLAY);
|
||||
if (player != null) {
|
||||
if (preparing) {
|
||||
|
@@ -18,7 +18,7 @@ import com.yizhuan.erban.ui.im.avtivity.NimFriendModel;
|
||||
import com.yizhuan.erban.ui.im.avtivity.NimP2PMessageActivity;
|
||||
import com.yizhuan.erban.ui.widget.ButtonItem;
|
||||
import com.yizhuan.erban.ui.widget.GiftDialog;
|
||||
import com.yizhuan.erban.vip.VipHelper;
|
||||
import com.yizhuan.erban.vip.util.VipHelper;
|
||||
import com.yizhuan.tutu.room_chat.activity.RoomMsgActivity;
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
import com.yizhuan.xchat_android_core.bean.RoomQueueInfo;
|
||||
|
@@ -2,13 +2,21 @@ package com.yizhuan.erban.avroom.activity;
|
||||
|
||||
import static android.view.View.VISIBLE;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_BOX;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAIRY;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ROOM_PK;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_GIFT_L5;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_ROOM_PK_NOTIFY;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -31,6 +39,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
@@ -58,7 +67,7 @@ import com.yizhuan.erban.avroom.fragment.HomePartyFragment;
|
||||
import com.yizhuan.erban.avroom.fragment.InputPwdDialogFragment;
|
||||
import com.yizhuan.erban.avroom.presenter.AvRoomPresenter;
|
||||
import com.yizhuan.erban.avroom.presenter.HomePartyPresenter;
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageOpenDialog;
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageHandler;
|
||||
import com.yizhuan.erban.avroom.view.IAvRoomView;
|
||||
import com.yizhuan.erban.avroom.widget.VerticalViewPagerAdapter;
|
||||
import com.yizhuan.erban.base.BaseMvpActivity;
|
||||
@@ -74,10 +83,7 @@ import com.yizhuan.erban.ui.utils.ImageLoadUtils;
|
||||
import com.yizhuan.erban.ui.webview.CommonWebViewActivity;
|
||||
import com.yizhuan.erban.ui.webview.DialogWebViewActivity;
|
||||
import com.yizhuan.erban.ui.widget.NobleOpenNoticeView;
|
||||
import com.yizhuan.erban.ui.widget.dialog.AllServiceGiftDialog;
|
||||
import com.yizhuan.erban.ui.widget.dialog.AllServiceGiftLevelOneDialog;
|
||||
import com.yizhuan.erban.ui.widget.dialog.AllServiceGiftLevelThreeDialog;
|
||||
import com.yizhuan.erban.ui.widget.dialog.AllServiceGiftLevelTwoDialog;
|
||||
import com.yizhuan.erban.ui.widget.dialog.AllServiceGiftLevelDialog;
|
||||
import com.yizhuan.erban.ui.widget.dialog.MonsterDialog;
|
||||
import com.yizhuan.erban.utils.UserUtils;
|
||||
import com.yizhuan.tutu.room_chat.activity.RoomMsgActivity;
|
||||
@@ -90,9 +96,19 @@ import com.yizhuan.xchat_android_core.channel_page.bean.HelloMessageInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.GiftModel;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagNoticeInfo;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.FairyMsgAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.NotifyH5Attachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.NotifyH5Info;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeInfo;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomLuckySeaAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomLuckySeaMsgBean;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomPKAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomPkBean;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomReceivedLuckyGiftAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.TarotAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.TarotMsgBean;
|
||||
import com.yizhuan.xchat_android_core.initial.InitialModel;
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
|
||||
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager;
|
||||
@@ -111,7 +127,6 @@ import com.yizhuan.xchat_android_core.patriarch.event.CloseMinRoomEvent;
|
||||
import com.yizhuan.xchat_android_core.patriarch.event.ImPushMsgPmLimitTimeEvent;
|
||||
import com.yizhuan.xchat_android_core.patriarch.event.PmDismissAllLimitDialogEvent;
|
||||
import com.yizhuan.xchat_android_core.patriarch.exception.PmRoomLimitException;
|
||||
import com.yizhuan.xchat_android_core.redpackage.RedPackageModel;
|
||||
import com.yizhuan.xchat_android_core.redpackage.RedPackageNotifyInfo;
|
||||
import com.yizhuan.xchat_android_core.room.anotherroompk.ShowGiftDialogEvent;
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
|
||||
@@ -123,6 +138,9 @@ import com.yizhuan.xchat_android_core.room.event.RoomTaskTipsEvent;
|
||||
import com.yizhuan.xchat_android_core.room.pk.event.PKStateEvent;
|
||||
import com.yizhuan.xchat_android_core.super_admin.util.SAdminOptUtil;
|
||||
import com.yizhuan.xchat_android_core.super_admin.util.SuperAdminUtil;
|
||||
import com.yizhuan.xchat_android_core.support.room.RoomContext;
|
||||
import com.yizhuan.xchat_android_core.support.room.RoomView;
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.FairyMsgInfoBean;
|
||||
import com.yizhuan.xchat_android_core.user.UserModel;
|
||||
import com.yizhuan.xchat_android_core.user.bean.FirstChargeInfo;
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfo;
|
||||
@@ -130,7 +148,6 @@ import com.yizhuan.xchat_android_core.utils.LogUtils;
|
||||
import com.yizhuan.xchat_android_core.utils.StringUtils;
|
||||
import com.yizhuan.xchat_android_library.base.factory.CreatePresenter;
|
||||
import com.yizhuan.xchat_android_library.rxbus.RxBus;
|
||||
import com.yizhuan.xchat_android_library.utils.JavaUtil;
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil;
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil;
|
||||
import com.yizhuan.xchat_android_library.utils.UIUtils;
|
||||
@@ -142,10 +159,8 @@ import org.greenrobot.eventbus.ThreadMode;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Single;
|
||||
@@ -161,7 +176,7 @@ import io.reactivex.disposables.Disposable;
|
||||
*/
|
||||
@CreatePresenter(AvRoomPresenter.class)
|
||||
public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter>
|
||||
implements View.OnClickListener, IAvRoomView {
|
||||
implements View.OnClickListener, IAvRoomView, RoomView {
|
||||
|
||||
public static final int FROM_TYPE_NORMAL = 0;
|
||||
public static final int FROM_TYPE_RECOMMEND = 1;
|
||||
@@ -199,7 +214,6 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
private RoomInfo mRoomInfo;
|
||||
private ImageView ivHeadWear;
|
||||
private MonsterDialog monsterDialog;
|
||||
private List<RedPackageOpenDialog> openDialogs;
|
||||
private ViewPager2 viewpager;
|
||||
private VerticalViewPagerAdapter mAdapter;
|
||||
/*********************************显示全服礼物***************************************/
|
||||
@@ -207,10 +221,10 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
private GiftBroadcastObserver giftObserver;
|
||||
private Dialog giftDialog;
|
||||
private LinkedList<AllServiceGiftProtocol.DataBean> giftList;
|
||||
private boolean isResume = true;
|
||||
@Nullable
|
||||
private SingleRoomTipDialog singleRoomTipDialog;
|
||||
|
||||
// 通过红包进来时,有该参数
|
||||
private RedPackageNotifyInfo redPackageNotifyInfo;
|
||||
public static void start(Context context, long roomUid) {
|
||||
startForFromType(context, roomUid, FROM_TYPE_NORMAL, null, null);
|
||||
}
|
||||
@@ -394,6 +408,12 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
fromUid = intent.getStringExtra("fromUid");
|
||||
giftId = intent.getIntExtra("giftId", 0);
|
||||
mRoomInfo = intent.getParcelableExtra(Constants.ROOM_INFO);
|
||||
Object notifyInfo = intent.getSerializableExtra("notifyInfo");
|
||||
if (notifyInfo instanceof RedPackageNotifyInfo) {
|
||||
redPackageNotifyInfo = (RedPackageNotifyInfo) notifyInfo;
|
||||
}else{
|
||||
redPackageNotifyInfo = null;
|
||||
}
|
||||
if (mRoomInfo != null) {
|
||||
roomUid = mRoomInfo.getRoomUid();
|
||||
} else {
|
||||
@@ -492,8 +512,6 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
if (giftList != null) {
|
||||
giftList.clear();
|
||||
}
|
||||
if (!isResume) showRedPackage(AvRoomDataManager.get().mCurrentRoomInfo);
|
||||
isResume = true;
|
||||
}
|
||||
|
||||
private void onRoomEventReceive(RoomEvent roomEvent) {
|
||||
@@ -597,9 +615,6 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
case RoomEvent.MY_SELF_KICK_OUT_ROOM_BY_S_ADMIN:
|
||||
toBack(true);
|
||||
break;
|
||||
case RoomEvent.RECEIVE_RED_PACKAGE:
|
||||
showRedPackage(AvRoomDataManager.get().mCurrentRoomInfo);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
@@ -661,6 +676,17 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
RxBus.get().post(new ShowGiftDialogEvent().setGiftId(giftId));
|
||||
giftId = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO 临时方案:后续逐步完善整个房间的RoomContext替换计划
|
||||
* PS:目前房间进入的逻辑有些凌乱,没有明确的生命周期,看代码逻辑,无论是第一次还是再次进入都会走这里,所以在这里绑定View
|
||||
*/
|
||||
getRoomContext().onViewAttach(this);
|
||||
|
||||
/**
|
||||
* 每次View重新创建(意味着可能在房间外点了红包),就重新尝试加载红包并展示
|
||||
*/
|
||||
tryShowSourceRedPackage();
|
||||
}
|
||||
|
||||
private void showLiveFinishView(long uid) {
|
||||
@@ -697,42 +723,24 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
AvRoomDataManager.get().release();
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void showRedPackage(RoomInfo roomInfo) {
|
||||
if (roomInfo == null) return;
|
||||
RedPackageNotifyInfo inRoomNotifyInfo = (RedPackageNotifyInfo) getIntent().getSerializableExtra("notifyInfo");
|
||||
Map<String, Long> redMap = DemoCache.readRedPackage();
|
||||
RedPackageModel.INSTANCE.getRedPackage(roomInfo.getUid())
|
||||
.compose(bindToLifecycle())
|
||||
.doFinally(() -> {
|
||||
if (inRoomNotifyInfo != null && (redMap == null || !redMap.containsKey(inRoomNotifyInfo.getRedEnvelopeId()))) {
|
||||
showRedPackageOpenDialog(inRoomNotifyInfo);
|
||||
}
|
||||
})
|
||||
.filter(notifyInfo -> inRoomNotifyInfo == null || !notifyInfo.getRedEnvelopeId().equals(inRoomNotifyInfo.getRedEnvelopeId()))
|
||||
.subscribe(this::showRedPackageOpenDialog);
|
||||
}
|
||||
|
||||
private void showRedPackageOpenDialog(RedPackageNotifyInfo notifyInfo) {
|
||||
if (!isResume) return;
|
||||
if (openDialogs == null) {
|
||||
openDialogs = new ArrayList<>();
|
||||
}
|
||||
RedPackageOpenDialog openDialog = RedPackageOpenDialog.Companion.newInstance(notifyInfo);
|
||||
openDialog.show(this);
|
||||
if (openDialog.getDialog() != null) {
|
||||
openDialog.getDialog().setOnDismissListener(dialog -> openDialogs.remove(openDialog));
|
||||
}
|
||||
openDialogs.add(openDialog);
|
||||
if (openDialogs.size() >= SHOW_RED_DIALOG_MAX) {
|
||||
openDialogs.get(SHOW_RED_DIALOG_MAX - 1).dismissAllowingStateLoss();
|
||||
/**
|
||||
* 尝试展示来源红包(在房间外点击红包入口进入房间时)
|
||||
*/
|
||||
private void tryShowSourceRedPackage() {
|
||||
try {
|
||||
if (redPackageNotifyInfo != null) {
|
||||
RedPackageHandler handler = getRoomContext().findAbility(RedPackageHandler.class.getSimpleName());
|
||||
if (handler != null) {
|
||||
long id = Long.parseLong(redPackageNotifyInfo.getRedEnvelopeId());
|
||||
handler.tryShowRedPackage(id);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void dismissRedPackageDialog() {
|
||||
if (openDialogs != null) {
|
||||
openDialogs.clear();
|
||||
}
|
||||
if (mCurrentFragment != null) {
|
||||
mCurrentFragment.dismissSendRedPackageDialog();
|
||||
}
|
||||
@@ -1057,7 +1065,6 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
DemoCache.readNewUserChargeGift() == 0) {
|
||||
DemoCache.saveNewUserChargeGift(1);
|
||||
}
|
||||
showRedPackage(AvRoomDataManager.get().mCurrentRoomInfo);
|
||||
dismissLoadingDialog();
|
||||
}
|
||||
|
||||
@@ -1177,10 +1184,9 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
baseProtocol = null;
|
||||
}
|
||||
if (baseProtocol == null) return;
|
||||
|
||||
if (!isValid()) return;
|
||||
switch (baseProtocol.getFirst()) {
|
||||
case CUSTOM_MSG_HEADER_TYPE_GIFT:
|
||||
if (!isValid()) return;
|
||||
if (giftList == null) {
|
||||
giftList = new LinkedList<>();
|
||||
}
|
||||
@@ -1203,8 +1209,72 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_LUCKY_GIFT:
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY) {
|
||||
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);
|
||||
TarotAttachment tarotAttachment = new TarotAttachment(CustomAttachment.CUSTOM_MESS_TAROT,
|
||||
CustomAttachment.CUSTOM_MESS_TAROT_SENIOR_PRIZE_WINNING);
|
||||
tarotAttachment.setTarotMsgBean(tarotMsgBean);
|
||||
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(
|
||||
String.valueOf(AvRoomDataManager.get().getRoomId()), tarotAttachment);
|
||||
IMNetEaseManager.get().getChatRoomEventObservable()
|
||||
.onNext(new RoomEvent()
|
||||
.setEvent(RoomEvent.TAROT_NOTIFY_SVGA)
|
||||
.setChatRoomMessage(message));
|
||||
AvRoomDataManager.get().addChatRoomMessage(message);
|
||||
}
|
||||
break;
|
||||
case CustomAttachment.CUSTOM_MSG_NOTIFY_H5:
|
||||
if (baseProtocol.getSecond() == CustomAttachment.CUSTOM_MSG_NOTIFY_H5_SUB_WHOLE_SERVICE) {
|
||||
NotifyH5Info bean = JSON.parseObject(String.valueOf(baseProtocol.getData()), NotifyH5Info.class);
|
||||
NotifyH5Attachment notifyH5Attachment = new NotifyH5Attachment(baseProtocol.getSecond());
|
||||
notifyH5Attachment.setBean(bean);
|
||||
ChatRoomMessage notifyH5Msg = ChatRoomMessageBuilder.createChatRoomCustomMessage(
|
||||
String.valueOf(AvRoomDataManager.get().getRoomId()), notifyH5Attachment);
|
||||
IMNetEaseManager.get().getChatRoomEventObservable()
|
||||
.onNext(new RoomEvent()
|
||||
.setEvent(RoomEvent.NOTIFY_H5)
|
||||
.setChatRoomMessage(notifyH5Msg));
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_LUCKY_SEA://星级厨房
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL) {
|
||||
RoomLuckySeaAttachment attachment = new RoomLuckySeaAttachment(CUSTOM_MSG_LUCKY_SEA, CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL);
|
||||
attachment.setRoomLuckySeaMsgBean(JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomLuckySeaMsgBean.class));
|
||||
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), attachment);
|
||||
IMNetEaseManager.get().addMessages(message);
|
||||
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);
|
||||
@@ -1212,6 +1282,14 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
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);
|
||||
attachment.setFairyMsgInfo(JSON.parseObject(String.valueOf(baseProtocol.getData()), FairyMsgInfoBean.class));
|
||||
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), attachment);
|
||||
IMNetEaseManager.get().noticeRoomEvent(message, RoomEvent.FAIRY_DRAW_GIFT_L5);
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_ROOM_PK:
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_SUB_ROOM_PK_NOTIFY) {
|
||||
RoomPKAttachment attachment = new RoomPKAttachment(CUSTOM_MSG_SUB_ROOM_PK_NOTIFY);
|
||||
@@ -1227,7 +1305,9 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
|
||||
private void showGiftDialog() {
|
||||
if (giftList.size() == 0) return;
|
||||
giftDialog = generateAllServiceGiftDialog(this, giftList.peekFirst());
|
||||
AllServiceGiftProtocol.DataBean data = giftList.peekFirst();
|
||||
if (data == null) return;
|
||||
giftDialog = generateAllServiceGiftDialog(this, data);
|
||||
giftDialog.setOnDismissListener(dialog -> {
|
||||
giftList.pollFirst();
|
||||
AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst();
|
||||
@@ -1242,30 +1322,16 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
giftDialog.show();
|
||||
}
|
||||
|
||||
private AllServiceGiftDialog generateAllServiceGiftDialog(Context context, AllServiceGiftProtocol.DataBean dataBean) {
|
||||
switch (JavaUtil.str2int(dataBean.getLevelNum())) {
|
||||
default:
|
||||
case AllServiceGiftDialog.ALL_SERVICE_GIFT_LEVEL_1:
|
||||
return new AllServiceGiftLevelOneDialog(context, dataBean);
|
||||
|
||||
case AllServiceGiftDialog.ALL_SERVICE_GIFT_LEVEL_2:
|
||||
|
||||
return new AllServiceGiftLevelTwoDialog(context, dataBean);
|
||||
|
||||
case AllServiceGiftDialog.ALL_SERVICE_GIFT_LEVEL_3:
|
||||
return new AllServiceGiftLevelThreeDialog(context, dataBean);
|
||||
}
|
||||
private AllServiceGiftLevelDialog generateAllServiceGiftDialog(@NonNull Context context, @NonNull AllServiceGiftProtocol.DataBean dataBean) {
|
||||
return new AllServiceGiftLevelDialog(context, dataBean);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
registerGiftBroadcastMessage(false);
|
||||
isResume = false;
|
||||
}
|
||||
|
||||
|
||||
private void handlePmExitRoom() {
|
||||
EventBus.getDefault().post(new PmDismissAllLimitDialogEvent());
|
||||
getMvpPresenter().exitRoom();
|
||||
@@ -1311,6 +1377,24 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
getLimitEnterRoomHelper().handleThisContext(this, event.getData(), true, this::handlePmExitRoom);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public RoomContext getRoomContext() {
|
||||
return RoomContext.Companion.get();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public LifecycleOwner getLifecycleOwner() {
|
||||
return this;
|
||||
}
|
||||
|
||||
private static class GiftBroadcastObserver implements Observer<BroadcastMessage> {
|
||||
private WeakReference<AVRoomActivity> mReference;
|
||||
|
||||
@@ -1343,5 +1427,4 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -60,7 +60,7 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
protected static final int TYPE_BOSS = 1;
|
||||
protected static final int TYPE_NORMAL = 0;
|
||||
protected static final int TYPE_INVALID = -2;
|
||||
protected OnMicroItemClickListener onMicroItemClickListener;
|
||||
protected OnMicroItemClickListener onMicroItemClickListener = null;
|
||||
protected Context context;
|
||||
|
||||
public BaseMicroViewAdapter(Context context) {
|
||||
|
@@ -39,7 +39,7 @@ class RoomPKBoardView @JvmOverloads constructor(
|
||||
) : DragLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
private val binding = LayoutRoomPkBoardViewBinding.inflate(LayoutInflater.from(context))
|
||||
private val observer = Observer<RoomPkBean> { updateView(it) }
|
||||
private val observer = Observer<RoomPkBean?> { updateView(it) }
|
||||
private var disposable: Disposable? = null
|
||||
private lateinit var helpPopupWindow: PopupWindow
|
||||
private var roomPkBean: RoomPkBean? = null
|
||||
|
@@ -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,"Peko号:${item.erbanNo}")
|
||||
.setText(R.id.tv_room_id,"Piko号:${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)
|
||||
|
@@ -30,71 +30,71 @@ class RoomPkFinishDialog : BaseDialog<DialogRoomPkFinishBinding>() {
|
||||
|
||||
@SuppressLint("CheckResult", "SetTextI18n")
|
||||
override fun init() {
|
||||
binding.ivClose.setOnClickListener { dismissAllowingStateLoss() }
|
||||
binding.tvTitleRed.text = roomPkBean.cTitle.subAndReplaceDot(7)
|
||||
binding.tvValueRed.text = "${roomPkBean.cAmount}"
|
||||
binding.ivRedWin.isVisible = roomPkBean.cUid == roomPkBean.winUid && roomPkBean.winUid != 0L
|
||||
binding?.ivClose?.setOnClickListener { dismissAllowingStateLoss() }
|
||||
binding?.tvTitleRed?.text = roomPkBean.cTitle.subAndReplaceDot(7)
|
||||
binding?.tvValueRed?.text = "${roomPkBean.cAmount}"
|
||||
binding?.ivRedWin?.isVisible = roomPkBean.cUid == roomPkBean.winUid && roomPkBean.winUid != 0L
|
||||
ImageLoadUtils.loadImage(
|
||||
context,
|
||||
roomPkBean.cAvatar,
|
||||
binding.ivAvatarRed,
|
||||
binding?.ivAvatarRed,
|
||||
R.drawable.default_avatar
|
||||
)
|
||||
|
||||
binding.tvTitleBlue.text = roomPkBean.aTitle.subAndReplaceDot(7)
|
||||
binding.tvValueBlue.text = "${roomPkBean.aAmount}"
|
||||
binding.ivBlueWin.isVisible =
|
||||
binding?.tvTitleBlue?.text = roomPkBean.aTitle.subAndReplaceDot(7)
|
||||
binding?.tvValueBlue?.text = "${roomPkBean.aAmount}"
|
||||
binding?.ivBlueWin?.isVisible =
|
||||
roomPkBean.cUid != roomPkBean.winUid && roomPkBean.winUid != 0L
|
||||
ImageLoadUtils.loadImage(
|
||||
context,
|
||||
roomPkBean.aAvatar,
|
||||
binding.ivAvatarBlue,
|
||||
binding?.ivAvatarBlue,
|
||||
R.drawable.default_avatar
|
||||
)
|
||||
|
||||
roomPkBean.csRank.getOrNull(0)?.let {
|
||||
binding.tvNickContribute.text = it.nick.subAndReplaceDot(7)
|
||||
binding.tvValueContribute.text = "神豪值:${it.amount}"
|
||||
binding?.tvNickContribute?.text = it.nick.subAndReplaceDot(7)
|
||||
binding?.tvValueContribute?.text = "神豪值:${it.amount}"
|
||||
ImageLoadUtils.loadImage(
|
||||
context,
|
||||
it.avatar,
|
||||
binding.ivAvatarContribute,
|
||||
binding?.ivAvatarContribute,
|
||||
R.drawable.default_avatar
|
||||
)
|
||||
}
|
||||
|
||||
roomPkBean.crRank.getOrNull(0)?.let {
|
||||
binding.tvNickCharm.text = it.nick.subAndReplaceDot(7)
|
||||
binding.tvValueCharm.text = "魅力值:${it.amount}"
|
||||
binding?.tvNickCharm?.text = it.nick.subAndReplaceDot(7)
|
||||
binding?.tvValueCharm?.text = "魅力值:${it.amount}"
|
||||
ImageLoadUtils.loadImage(
|
||||
context,
|
||||
it.avatar,
|
||||
binding.ivAvatarCharm,
|
||||
binding?.ivAvatarCharm,
|
||||
R.drawable.default_avatar
|
||||
)
|
||||
}
|
||||
|
||||
when (roomPkBean.winUid) {
|
||||
0L -> {
|
||||
binding.viewBg.setBackgroundResource(R.drawable.bg_719cea_radius_10)
|
||||
binding.clRoot.setBackgroundResource(R.drawable.bg_room_pk_finish_deuce)
|
||||
binding.viewContribute.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_deuce)
|
||||
binding.viewCharm.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_deuce)
|
||||
binding.ivClose.setImageResource(R.drawable.ic_room_pk_finish_close_deuce)
|
||||
binding?.viewBg?.setBackgroundResource(R.drawable.bg_719cea_radius_10)
|
||||
binding?.clRoot?.setBackgroundResource(R.drawable.bg_room_pk_finish_deuce)
|
||||
binding?.viewContribute?.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_deuce)
|
||||
binding?.viewCharm?.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_deuce)
|
||||
binding?.ivClose?.setImageResource(R.drawable.ic_room_pk_finish_close_deuce)
|
||||
}
|
||||
roomPkBean.cUid -> {
|
||||
binding.viewBg.setBackgroundResource(R.drawable.bg_edbf89_radius_10)
|
||||
binding.clRoot.setBackgroundResource(R.drawable.bg_room_pk_finish_win)
|
||||
binding.viewContribute.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_win)
|
||||
binding.viewCharm.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_win)
|
||||
binding.ivClose.setImageResource(R.drawable.ic_room_pk_finish_close_win)
|
||||
binding?.viewBg?.setBackgroundResource(R.drawable.bg_edbf89_radius_10)
|
||||
binding?.clRoot?.setBackgroundResource(R.drawable.bg_room_pk_finish_win)
|
||||
binding?.viewContribute?.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_win)
|
||||
binding?.viewCharm?.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_win)
|
||||
binding?.ivClose?.setImageResource(R.drawable.ic_room_pk_finish_close_win)
|
||||
}
|
||||
else -> {
|
||||
binding.viewBg.setBackgroundResource(R.drawable.bg_bfabf6_radius_10)
|
||||
binding.clRoot.setBackgroundResource(R.drawable.bg_room_pk_finish_failed)
|
||||
binding.viewContribute.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_failed)
|
||||
binding.viewCharm.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_failed)
|
||||
binding.ivClose.setImageResource(R.drawable.ic_room_pk_finish_close_failed)
|
||||
binding?.viewBg?.setBackgroundResource(R.drawable.bg_bfabf6_radius_10)
|
||||
binding?.clRoot?.setBackgroundResource(R.drawable.bg_room_pk_finish_failed)
|
||||
binding?.viewContribute?.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_failed)
|
||||
binding?.viewCharm?.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_failed)
|
||||
binding?.ivClose?.setImageResource(R.drawable.ic_room_pk_finish_close_failed)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -29,23 +29,23 @@ class RoomPkForceFinishDialog : BaseDialog<DialogRoomPkForceFinishBinding>() {
|
||||
|
||||
@SuppressLint("CheckResult", "SetTextI18n")
|
||||
override fun init() {
|
||||
binding.ivClose.setOnClickListener { dismissAllowingStateLoss() }
|
||||
binding.tvTitleRed.text = roomPkBean.cTitle.subAndReplaceDot(7)
|
||||
binding.tvValueRed.text = "${roomPkBean.cAmount}"
|
||||
binding?.ivClose?.setOnClickListener { dismissAllowingStateLoss() }
|
||||
binding?.tvTitleRed?.text = roomPkBean.cTitle.subAndReplaceDot(7)
|
||||
binding?.tvValueRed?.text = "${roomPkBean.cAmount}"
|
||||
ImageLoadUtils.loadImage(
|
||||
context,
|
||||
roomPkBean.cAvatar,
|
||||
binding.ivAvatarRed,
|
||||
binding?.ivAvatarRed,
|
||||
R.drawable.default_avatar
|
||||
)
|
||||
|
||||
binding.tvTitleBlue.text = roomPkBean.aTitle.subAndReplaceDot(7)
|
||||
binding.tvValueBlue.text = "${roomPkBean.aAmount}"
|
||||
binding?.tvTitleBlue?.text = roomPkBean.aTitle.subAndReplaceDot(7)
|
||||
binding?.tvValueBlue?.text = "${roomPkBean.aAmount}"
|
||||
|
||||
ImageLoadUtils.loadImage(
|
||||
context,
|
||||
roomPkBean.aAvatar,
|
||||
binding.ivAvatarBlue,
|
||||
binding?.ivAvatarBlue,
|
||||
R.drawable.default_avatar
|
||||
)
|
||||
|
||||
|
@@ -36,26 +36,26 @@ class RoomPkReceivedDialog : BaseDialog<DialogRoomPkReceivedBinding>() {
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
binding.tvNick.text = pkBean.inviteRoomTitle.subAndReplaceDot(7)
|
||||
binding.tvTime.text = "${pkBean.pkDuration}分鐘"
|
||||
binding?.tvNick?.text = pkBean.inviteRoomTitle.subAndReplaceDot(7)
|
||||
binding?.tvTime?.text = "${pkBean.pkDuration}分鐘"
|
||||
pkBean.pkDesc.ifNotNullOrEmpty {
|
||||
binding.tvDescTitle.isVisible = true
|
||||
binding.tvDesc.isVisible = true
|
||||
binding.tvDesc.text = it
|
||||
binding?.tvDescTitle?.isVisible = true
|
||||
binding?.tvDesc?.isVisible = true
|
||||
binding?.tvDesc?.text = it
|
||||
}
|
||||
disposable = Observable.intervalRange(0, 10, 0, 1, TimeUnit.SECONDS)
|
||||
.compose(bindToLifecycle())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doOnComplete { dismissAllowingStateLoss() }
|
||||
.subscribe {
|
||||
binding.tvCloseTime.text = "${10 - it}"
|
||||
binding?.tvCloseTime?.text = "${10 - it}"
|
||||
}
|
||||
|
||||
binding.tvReceived.setOnClickListener {
|
||||
binding?.tvReceived?.setOnClickListener {
|
||||
commit(true)
|
||||
}
|
||||
|
||||
binding.tvRefuse.setOnClickListener {
|
||||
binding?.tvRefuse?.setOnClickListener {
|
||||
commit(false)
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,6 @@ class RoomPkRuleDialog : BaseDialog<DialogRoomPkRuleBinding>() {
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
binding.ivClose.setOnClickListener { dismissAllowingStateLoss() }
|
||||
binding?.ivClose?.setOnClickListener { dismissAllowingStateLoss() }
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package com.yizhuan.erban.avroom.bean
|
||||
|
||||
data class RoomAlbumPhotoInfo(
|
||||
val giftId: Int,
|
||||
val giftNum: Int,
|
||||
val giftUrl: String,
|
||||
val id: Int,
|
||||
val photoUrl: String,
|
||||
val roomUid: Int,
|
||||
val status: Int,
|
||||
val totalGoldPrice: Int,
|
||||
val type: Int,
|
||||
val uid: Int
|
||||
)
|
@@ -0,0 +1,8 @@
|
||||
package com.yizhuan.erban.avroom.bean
|
||||
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage
|
||||
|
||||
data class RoomPlayBean(
|
||||
val event: Int,
|
||||
val chatRoomMessage: ChatRoomMessage
|
||||
)
|
@@ -0,0 +1,19 @@
|
||||
package com.yizhuan.erban.avroom.core
|
||||
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageHandler
|
||||
import com.yizhuan.xchat_android_core.support.room.RoomAbility
|
||||
import com.yizhuan.xchat_android_core.support.room.RoomContext
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/10/26 15:41
|
||||
* Desc:语音房
|
||||
* @param roomId roomUid
|
||||
**/
|
||||
class AudioRoomContext(roomId: Long) : RoomContext(roomId) {
|
||||
|
||||
override fun loadAbility(list: MutableMap<String, RoomAbility>) {
|
||||
super.loadAbility(list)
|
||||
// 红包处理器
|
||||
list[RedPackageHandler::class.java.simpleName] = RedPackageHandler()
|
||||
}
|
||||
}
|
@@ -33,10 +33,10 @@ class CreateGameRoomDialog : BaseDialog<DialogCreateGameRoomBinding>() {
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
|
||||
binding.rvGame.itemAnimator = null
|
||||
binding?.rvGame?.itemAnimator = null
|
||||
rvDelegate = RVDelegate.Builder<GameInfo>()
|
||||
.setAdapter(gameAdapter)
|
||||
.setRecyclerView(binding.rvGame)
|
||||
.setRecyclerView(binding?.rvGame)
|
||||
.setLayoutManager(GridLayoutManager(context, 2))
|
||||
.build()
|
||||
|
||||
@@ -48,7 +48,7 @@ class CreateGameRoomDialog : BaseDialog<DialogCreateGameRoomBinding>() {
|
||||
)
|
||||
}
|
||||
|
||||
binding.ivClose.setOnClickListener {
|
||||
binding?.ivClose?.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
|
@@ -33,14 +33,14 @@ class CreateRoomDialog : BaseDialog<DialogCreateRoomBinding>() {
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
if(isHomeGame){
|
||||
binding.tvPlayType.isVisible = false
|
||||
binding.rgType.isVisible = false
|
||||
binding.rvGame.isVisible = true
|
||||
binding?.tvPlayType?.isVisible = false
|
||||
binding?.rgType?.isVisible = false
|
||||
binding?.rvGame?.isVisible = true
|
||||
}
|
||||
binding.rvGame.itemAnimator = null
|
||||
binding?.rvGame?.itemAnimator = null
|
||||
rvDelegate = RVDelegate.Builder<GameInfo>()
|
||||
.setAdapter(gameAdapter)
|
||||
.setRecyclerView(binding.rvGame)
|
||||
.setRecyclerView(binding?.rvGame)
|
||||
.setLayoutManager(LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false))
|
||||
.build()
|
||||
|
||||
@@ -55,22 +55,22 @@ class CreateRoomDialog : BaseDialog<DialogCreateRoomBinding>() {
|
||||
checkCreateEnable()
|
||||
}
|
||||
|
||||
binding.rbGameRoom.setOnCheckedChangeListener { _, isChecked ->
|
||||
binding?.rbGameRoom?.setOnCheckedChangeListener { _, isChecked ->
|
||||
checkCreateEnable()
|
||||
if (isChecked) {
|
||||
binding.rvGame.isVisible = true
|
||||
binding?.rvGame?.isVisible = true
|
||||
}
|
||||
}
|
||||
|
||||
binding.rbPartyRoom.setOnCheckedChangeListener { _, isChecked ->
|
||||
binding?.rbPartyRoom?.setOnCheckedChangeListener { _, isChecked ->
|
||||
checkCreateEnable()
|
||||
if (isChecked) {
|
||||
binding.rvGame.isInvisible = true
|
||||
binding?.rvGame?.isInvisible = true
|
||||
}
|
||||
}
|
||||
binding.tvCreate.setOnClickListener {
|
||||
binding?.tvCreate?.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
if (binding.rbPartyRoom.isChecked) {
|
||||
if (binding?.rbPartyRoom?.isChecked == true) {
|
||||
OpenRoomHelper.openHomePartyRoom(requireActivity() as BaseActivity)
|
||||
} else {
|
||||
if (selectIndex != -1) {
|
||||
@@ -84,7 +84,7 @@ class CreateRoomDialog : BaseDialog<DialogCreateRoomBinding>() {
|
||||
}
|
||||
}
|
||||
|
||||
binding.ivClose.setOnClickListener {
|
||||
binding?.ivClose?.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
@@ -105,10 +105,10 @@ class CreateRoomDialog : BaseDialog<DialogCreateRoomBinding>() {
|
||||
|
||||
private fun checkCreateEnable() {
|
||||
if(isHomeGame){
|
||||
binding.tvCreate.isEnabled = selectIndex != -1
|
||||
binding?.tvCreate?.isEnabled = selectIndex != -1
|
||||
}else {
|
||||
binding.tvCreate.isEnabled = binding.rbPartyRoom.isChecked ||
|
||||
(binding.rbGameRoom.isChecked && selectIndex != -1)
|
||||
binding?.tvCreate?.isEnabled = binding?.rbPartyRoom?.isChecked == true ||
|
||||
(binding?.rbGameRoom?.isChecked == true && selectIndex != -1)
|
||||
}
|
||||
}
|
||||
}
|
@@ -9,11 +9,11 @@ class NewUserGiftDialog(val giftInfo: GiftInfo) :
|
||||
BaseDialog<DialogNewUserGiftBinding>() {
|
||||
|
||||
override fun init() {
|
||||
binding.ivClose.setOnClickListener {
|
||||
binding?.ivClose?.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
binding.ivGift.load(giftInfo.giftUrl)
|
||||
binding.tvGiftName.text = "${giftInfo.giftName}*${giftInfo.count}"
|
||||
binding?.ivGift?.load(giftInfo.giftUrl)
|
||||
binding?.tvGiftName?.text = "${giftInfo.giftName}*${giftInfo.count}"
|
||||
}
|
||||
|
||||
}
|
@@ -24,13 +24,14 @@ import com.yizhuan.erban.avroom.activity.CreatePKActivity;
|
||||
import com.yizhuan.erban.avroom.activity.RoomSettingActivity;
|
||||
import com.yizhuan.erban.avroom.anotherroompk.RoomPKCreateActivity;
|
||||
import com.yizhuan.erban.avroom.giftvalue.GiftValueDialogUiHelper;
|
||||
import com.yizhuan.erban.avroom.room_album.RoomAlbumActivity;
|
||||
import com.yizhuan.erban.avroom.singleroompk.SingleRoomPKCreateActivity;
|
||||
import com.yizhuan.erban.common.util.Utils;
|
||||
import com.yizhuan.erban.common.widget.dialog.DialogManager;
|
||||
import com.yizhuan.erban.ui.widget.ButtonItem;
|
||||
import com.yizhuan.erban.ui.widget.recyclerview.decoration.ColorDecoration;
|
||||
import com.yizhuan.erban.ui.widget.recyclerview.layoutmanager.FullyGridLayoutManager;
|
||||
import com.yizhuan.erban.vip.VipBroadcastDialog;
|
||||
import com.yizhuan.erban.vip.dialog.VipBroadcastDialog;
|
||||
import com.yizhuan.tutu.room_chat.activity.RoomInviteFansActivity;
|
||||
import com.yizhuan.xchat_android_constants.XChatConstants;
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
@@ -112,10 +113,11 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
true));
|
||||
rvOPtList.setLayoutManager(new FullyGridLayoutManager(getContext(), 5));
|
||||
optAdapter = new OptAdapter(context, null);
|
||||
addRoomAlbum(optAdapter);
|
||||
addDatingAction(optAdapter);
|
||||
// addPKAction(optAdapter);
|
||||
addPKAction(optAdapter);
|
||||
addRoomPKAction(optAdapter);
|
||||
// addSingleRoomPKAction(optAdapter);
|
||||
addSingleRoomPKAction(optAdapter);
|
||||
addSendBroadcastAction(optAdapter);
|
||||
// addInviteFansOptAdapter();
|
||||
addVipSendBroadcastAction(optAdapter);
|
||||
@@ -123,7 +125,7 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
addRoomSettingAction(optAdapter);
|
||||
addGiftEffectAction(optAdapter);
|
||||
addOpenOrClosePublicScreenAction(optAdapter);
|
||||
addRedPackageSwitch();
|
||||
// addRedPackageSwitch();
|
||||
addCleanScreenAction(optAdapter);
|
||||
addRoomLimit(optAdapter);
|
||||
addGiftValueAction(optAdapter);
|
||||
@@ -267,6 +269,14 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
}
|
||||
}
|
||||
|
||||
private void addRoomAlbum(OptAdapter optAdapter) {
|
||||
if (AvRoomDataManager.get().isHasRoomAlbum()) {
|
||||
optAdapter.addData(new OptAction(R.drawable.ic_room_operation_album, "房间相册", () -> {
|
||||
RoomAlbumActivity.start(getContext());
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 相亲 模式
|
||||
*
|
||||
@@ -331,7 +341,7 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
* @param optAdapter
|
||||
*/
|
||||
private void addRedPacketAction(OptAdapter optAdapter) {
|
||||
if (AvRoomDataManager.get().isRedEnvelopeOpen()) {
|
||||
if (AvRoomDataManager.get().getRedEnvelopeType() > 0) {
|
||||
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (roomInfo == null) {
|
||||
return;
|
||||
@@ -342,7 +352,6 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -419,7 +428,7 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
superAdminModel.roomOperate(SuperAdminModel.CLOSE_PUBLIC_SCREEN).subscribe();
|
||||
}
|
||||
AvRoomModel.get().closeScreen(roomInfo.getRoomId(),
|
||||
!isCloseScreen)
|
||||
!isCloseScreen)
|
||||
.compose(RxHelper.bindContext(context))
|
||||
.flatMap(data -> IMNetEaseManager.get().closeOpenScreen(
|
||||
data.getRoomId(), data))
|
||||
@@ -639,7 +648,7 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
}
|
||||
optAdapter.addData(new OptAction(R.drawable.icon_room_shield_report,
|
||||
ResUtil.getString(R.string.me_shield_report),
|
||||
() ->{
|
||||
() -> {
|
||||
DialogManager dialogManager = new DialogManager(context);
|
||||
List<ButtonItem> buttonItems = new ArrayList<>();
|
||||
ButtonItem buttonItem1 = new ButtonItem(ResUtil.getString(R.string.me_shield_room), () -> {
|
||||
|
@@ -44,31 +44,31 @@ class SendBroadcastDialog : BaseDialog<DialogSendBroadcastBinding>() {
|
||||
|
||||
@SuppressLint("CheckResult", "SetTextI18n")
|
||||
override fun init() {
|
||||
binding.ivClose.setOnClickListener {
|
||||
binding?.ivClose?.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
adapter = SendBroadcastAdapter()
|
||||
rvDelegate = RVDelegate.Builder<String>()
|
||||
.setAdapter(adapter)
|
||||
.setRecyclerView(binding.rvRecommend)
|
||||
.setRecyclerView(binding?.rvRecommend)
|
||||
.setLayoutManager(LinearLayoutManager(context))
|
||||
.build()
|
||||
|
||||
adapter.setOnItemClickListener { _, _, position ->
|
||||
binding.editContent.setText(adapter.getItem(position))
|
||||
binding?.editContent?.setText(adapter.getItem(position))
|
||||
}
|
||||
|
||||
binding.editContent.addTextChangedListener(object : TextWatcherWrapper() {
|
||||
binding?.editContent?.addTextChangedListener(object : TextWatcherWrapper() {
|
||||
override fun afterTextChanged(editable: Editable?) {
|
||||
val contentLength = editable?.length ?: 0
|
||||
binding.tvContentNumLimit.text =
|
||||
binding?.tvContentNumLimit?.text =
|
||||
"${contentLength}/${broadcastInfo?.maxWords ?: 20}"
|
||||
binding.tvSend.isEnabled = contentLength != 0
|
||||
binding?.tvSend?.isEnabled = contentLength != 0
|
||||
}
|
||||
})
|
||||
|
||||
binding.tvSend.setOnClickListener {
|
||||
binding?.tvSend?.setOnClickListener {
|
||||
if (CommonUtils.isFastDoubleClick(1000)) return@setOnClickListener
|
||||
sendBroadcast()
|
||||
}
|
||||
@@ -90,13 +90,13 @@ class SendBroadcastDialog : BaseDialog<DialogSendBroadcastBinding>() {
|
||||
private fun initData(info: BroadcastInfo) {
|
||||
broadcastInfo = info
|
||||
rvDelegate.setNewData(info.recommends)
|
||||
binding.tvAvailableCountNum.text = "${info.availableTimes}/${info.total}"
|
||||
binding.editContent.hint = "输入内容不能少于${info.minWords}个字,请文明发言哦~"
|
||||
binding.tvContentNumLimit.text = "0/${info.maxWords}"
|
||||
binding?.tvAvailableCountNum?.text = "${info.availableTimes}/${info.total}"
|
||||
binding?.editContent?.hint = "输入内容不能少于${info.minWords}个字,请文明发言哦~"
|
||||
binding?.tvContentNumLimit?.text = "0/${info.maxWords}"
|
||||
if (info.seconds > 0) {
|
||||
beginIntervalTime(info)
|
||||
} else {
|
||||
binding.tvSendHint.text = "发布后,${info.minutes}分钟内不可再发布广播"
|
||||
binding?.tvSendHint?.text = "发布后,${info.minutes}分钟内不可再发布广播"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,10 +107,10 @@ class SendBroadcastDialog : BaseDialog<DialogSendBroadcastBinding>() {
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(bindToLifecycle())
|
||||
.doOnComplete {
|
||||
binding.tvSendHint.text = "发布后,${info.minutes}分钟内不可再发布广播"
|
||||
binding?.tvSendHint?.text = "发布后,${info.minutes}分钟内不可再发布广播"
|
||||
}
|
||||
.subscribe {
|
||||
binding.tvSendHint.text = SpannableBuilder()
|
||||
binding?.tvSendHint?.text = SpannableBuilder()
|
||||
.append(
|
||||
"${info.seconds - it}",
|
||||
ForegroundColorSpan(Color.parseColor("#FFFDA615"))
|
||||
@@ -127,7 +127,7 @@ class SendBroadcastDialog : BaseDialog<DialogSendBroadcastBinding>() {
|
||||
return
|
||||
}
|
||||
broadcastInfo?.let {
|
||||
val msg = binding.editContent.text
|
||||
val msg = binding?.editContent?.text
|
||||
if (msg.isNullOrEmpty() || msg.length < it.minWords) {
|
||||
"输入内容不能少于${it.minWords}个字!".toast()
|
||||
return@let
|
||||
|
@@ -9,7 +9,7 @@ class SingleRoomTipDialog :
|
||||
BaseDialog<DialogSingleRoomTipBinding>() {
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun init() {
|
||||
binding.root.setOnClickListener {
|
||||
binding?.root?.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
dialog?.window?.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL)
|
||||
|
@@ -18,8 +18,8 @@ import android.widget.TextView
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.android.billingclient.api.BillingClient
|
||||
import com.android.billingclient.api.BillingResult
|
||||
import com.android.billingclient.api.ProductDetails
|
||||
import com.android.billingclient.api.Purchase
|
||||
import com.android.billingclient.api.SkuDetails
|
||||
import com.appsflyer.AFInAppEventParameterName
|
||||
import com.appsflyer.AFInAppEventType
|
||||
import com.appsflyer.AppsFlyerLib
|
||||
@@ -123,7 +123,7 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
ResUtil.getString(R.string.avroom_firstcharge_firstchargedialog_01).toast()
|
||||
} else if (channel.equals(Constants.GOOGLE)) {
|
||||
goodsList?.get(position)?.let { charge ->
|
||||
buyProduct(charge.skuDetails)
|
||||
buyProduct(charge.productDetails)
|
||||
}
|
||||
} else {
|
||||
CommonWebViewActivity.start(
|
||||
@@ -142,18 +142,23 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
FirstChargeReward.ONE -> {
|
||||
spanSize = 6
|
||||
}
|
||||
|
||||
FirstChargeReward.TWO_LEFT -> {
|
||||
spanSize = 3
|
||||
}
|
||||
|
||||
FirstChargeReward.TWO_RIGHT -> {
|
||||
spanSize = 3
|
||||
}
|
||||
|
||||
FirstChargeReward.THREE -> {
|
||||
spanSize = 2
|
||||
}
|
||||
|
||||
FirstChargeReward.TWO_LEFT_SMALL -> {
|
||||
spanSize = 3
|
||||
}
|
||||
|
||||
FirstChargeReward.TWO_RIGHT_SMALL -> {
|
||||
spanSize = 3
|
||||
}
|
||||
@@ -196,11 +201,13 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
binding.rbPlanC.visibility = View.GONE
|
||||
binding.rbPlanA.text = "$${goodsList[0].chargeMoney}"
|
||||
}
|
||||
|
||||
2 -> {
|
||||
binding.rbPlanC.visibility = View.GONE
|
||||
binding.rbPlanA.text = "$${goodsList[0].chargeMoney}"
|
||||
binding.rbPlanB.text = "$${goodsList[1].chargeMoney}"
|
||||
}
|
||||
|
||||
3 -> {
|
||||
binding.rbPlanA.text = "$${goodsList[0].chargeMoney}"
|
||||
binding.rbPlanB.text = "$${goodsList[1].chargeMoney}"
|
||||
@@ -227,20 +234,19 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
for (bean in goodsList) {
|
||||
productKeys.add(bean.chargeProdId)
|
||||
}
|
||||
billingManager?.querySkuDetailsAsync(
|
||||
BillingClient.SkuType.INAPP, productKeys
|
||||
) { billingResult: BillingResult, skuDetailsList: List<SkuDetails>? ->
|
||||
billingManager?.querySkuDetailsAsync(productKeys) { billingResult: BillingResult, productDetails: MutableList<ProductDetails> ->
|
||||
if (billingResult.responseCode != BillingClient.BillingResponseCode.OK) {
|
||||
Log.w(
|
||||
TAG,
|
||||
"Unsuccessful query for type: " + BillingClient.SkuType.INAPP
|
||||
+ ". Error code: " + billingResult.responseCode
|
||||
"Unsuccessful query for type: " + BillingClient.ProductType.INAPP + ". Error code: " + billingResult.responseCode
|
||||
)
|
||||
} else if (skuDetailsList != null && skuDetailsList.isNotEmpty()) {
|
||||
return@querySkuDetailsAsync
|
||||
}
|
||||
if (productDetails.isNotEmpty()) {
|
||||
for (chargeBean in goodsList) {
|
||||
for (skuDetails in skuDetailsList) {
|
||||
if (skuDetails.sku == chargeBean.chargeProdId) {
|
||||
chargeBean.skuDetails = skuDetails
|
||||
for (skuDetails in productDetails) {
|
||||
if (skuDetails.productId == chargeBean.chargeProdId) {
|
||||
chargeBean.productDetails = skuDetails
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -258,7 +264,7 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
) {
|
||||
PayModel.get().verifyOrder(
|
||||
purchase.accountIdentifiers!!.obfuscatedAccountId,
|
||||
purchase.skus[0],
|
||||
purchase.products[0],
|
||||
purchase.packageName,
|
||||
purchase.purchaseToken
|
||||
)
|
||||
@@ -267,12 +273,12 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
{ token: String? ->
|
||||
//L.i("token=" + token);
|
||||
billingManager?.consumeAsync(token)
|
||||
var skuDetails: SkuDetails? = null
|
||||
var skuDetails: ProductDetails? = null
|
||||
val goodList = goodsList
|
||||
if (goodList != null && goodList.isNotEmpty()) {
|
||||
if (!goodList.isNullOrEmpty()) {
|
||||
for (datum in goodList) {
|
||||
if (datum.chargeProdId == purchase.skus[0]) {
|
||||
skuDetails = datum.skuDetails
|
||||
if (datum.chargeProdId == purchase.products[0]) {
|
||||
skuDetails = datum.productDetails
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -282,12 +288,12 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
HashMap()
|
||||
eventValue[AFInAppEventParameterName.CONTENT_TYPE] = "Gold"
|
||||
eventValue[AFInAppEventParameterName.QUANTITY] = 1
|
||||
eventValue[AFInAppEventParameterName.CONTENT_ID] = purchase.orderId
|
||||
eventValue[AFInAppEventParameterName.CONTENT_ID] = purchase.orderId!!
|
||||
eventValue[AFInAppEventParameterName.REVENUE] =
|
||||
skuDetails.priceAmountMicros / 1000000f
|
||||
eventValue["Price"] = skuDetails.price
|
||||
skuDetails.oneTimePurchaseOfferDetails?.priceAmountMicros!! / 1000000f
|
||||
eventValue["Price"] = skuDetails.oneTimePurchaseOfferDetails?.formattedPrice!!
|
||||
eventValue[AFInAppEventParameterName.CURRENCY] =
|
||||
skuDetails.priceCurrencyCode
|
||||
skuDetails.oneTimePurchaseOfferDetails?.priceCurrencyCode!!
|
||||
AppsFlyerLib.getInstance().logEvent(
|
||||
applicationContext,
|
||||
AFInAppEventType.PURCHASE,
|
||||
@@ -315,10 +321,10 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
|
||||
/*购买商品*/
|
||||
@SuppressLint("CheckResult")
|
||||
fun buyProduct(skuDetails: SkuDetails?) {
|
||||
fun buyProduct(skuDetails: ProductDetails?) {
|
||||
if (skuDetails != null) {
|
||||
Log.d(TAG, "BuyProduct:" + skuDetails.sku)
|
||||
PayModel.get().placeOrder(skuDetails.sku)
|
||||
Log.d(TAG, "BuyProduct:" + skuDetails.productId)
|
||||
PayModel.get().placeOrder(skuDetails.productId)
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(
|
||||
{ recordId: PayRecordId ->
|
||||
@@ -372,6 +378,7 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
bean.itemType = FirstChargeReward.ONE
|
||||
}
|
||||
}
|
||||
|
||||
2 -> {
|
||||
for (i in firstChargeRewardList.indices) {
|
||||
if (i == 0) {
|
||||
@@ -381,11 +388,13 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
3 -> {
|
||||
for (bean in firstChargeRewardList) {
|
||||
bean.itemType = FirstChargeReward.THREE
|
||||
}
|
||||
}
|
||||
|
||||
4 -> {
|
||||
for (i in firstChargeRewardList.indices) {
|
||||
if ((i + 1) % 2 != 0) {
|
||||
@@ -395,6 +404,7 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
if (firstChargeRewardList.size % 3 == 0) {
|
||||
for (bean in firstChargeRewardList) {
|
||||
|
@@ -11,6 +11,7 @@ import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.KeyEvent
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.ViewStub
|
||||
@@ -20,6 +21,9 @@ import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.CallSuper
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.withResumed
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
@@ -45,7 +49,8 @@ import com.yizhuan.erban.avroom.dialog.RoomFreeGiftDialog
|
||||
import com.yizhuan.erban.avroom.dialog.RoomOperationDialog
|
||||
import com.yizhuan.erban.avroom.firstcharge.FirstChargeDialog
|
||||
import com.yizhuan.erban.avroom.presenter.BaseRoomPresenter
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageSendDialog
|
||||
import com.yizhuan.erban.avroom.redpackage.send.RedPackageSendDialog
|
||||
import com.yizhuan.erban.avroom.room_album.RoomAlbumModel
|
||||
import com.yizhuan.erban.avroom.view.IBaseRoomView
|
||||
import com.yizhuan.erban.avroom.widget.BottomView
|
||||
import com.yizhuan.erban.avroom.widget.MessageView
|
||||
@@ -82,6 +87,7 @@ import com.yizhuan.xchat_android_core.gift.bean.GiftInfo
|
||||
import com.yizhuan.xchat_android_core.gift.event.RoomFreeGiftEvent
|
||||
import com.yizhuan.xchat_android_core.helper.AtProxy
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
|
||||
import com.yizhuan.xchat_android_core.home.event.OpenRoomMessageInputEvent
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomFollowOwnerAttachment
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomFollowOwnerAttachment2
|
||||
import com.yizhuan.xchat_android_core.manager.AudioEngineManager
|
||||
@@ -102,6 +108,8 @@ import com.yizhuan.xchat_android_core.share.bean.SessionType
|
||||
import com.yizhuan.xchat_android_core.super_admin.SaConstant
|
||||
import com.yizhuan.xchat_android_core.super_admin.model.SuperAdminModel
|
||||
import com.yizhuan.xchat_android_core.super_admin.util.SuperAdminUtil
|
||||
import com.yizhuan.xchat_android_core.support.room.RoomView
|
||||
import com.yizhuan.xchat_android_core.support.room.RoomWidget
|
||||
import com.yizhuan.xchat_android_core.user.UserModel
|
||||
import com.yizhuan.xchat_android_core.user.bean.BaseInfo
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfo
|
||||
@@ -114,6 +122,7 @@ import com.yizhuan.xchat_android_library.rxbus.RxBus
|
||||
import com.yizhuan.xchat_android_library.utils.*
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import kotlinx.coroutines.launch
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
@@ -128,7 +137,8 @@ import org.greenrobot.eventbus.ThreadMode
|
||||
*/
|
||||
open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
BaseMvpFragment<V?, P?>(),
|
||||
View.OnClickListener, OnGiftDialogBtnClickListener, IBaseRoomView, OnMicroItemClickListener {
|
||||
View.OnClickListener, OnGiftDialogBtnClickListener, IBaseRoomView, OnMicroItemClickListener,
|
||||
RoomView {
|
||||
private var myUid: Long = 0
|
||||
protected lateinit var messageView: MessageView
|
||||
protected lateinit var bottomView: BottomView
|
||||
@@ -177,6 +187,8 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
|
||||
private var atProxy: AtProxy? = null
|
||||
|
||||
// 房间小组件
|
||||
private var widgets: HashMap<String, RoomWidget> = HashMap()
|
||||
|
||||
@CallSuper
|
||||
override fun onFindViews() {
|
||||
@@ -184,6 +196,14 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
bottomView = mView.findViewById(R.id.bottom_view)
|
||||
inputLayout = mView.findViewById(R.id.input_layout)
|
||||
inputEdit = mView.findViewById(R.id.input_edit)
|
||||
inputEdit.setOnKeyListener { _, keyCode, event ->
|
||||
if (keyCode == KeyEvent.KEYCODE_ENTER && event.action == KeyEvent.ACTION_UP) {
|
||||
sendMsg()
|
||||
return@setOnKeyListener true
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
inputSend = mView.findViewById(R.id.input_send)
|
||||
microView = mView.findViewById(R.id.micro_view)
|
||||
mVsMusicPlayer = mView.findViewById(R.id.vs_music_player)
|
||||
@@ -228,6 +248,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
@SuppressLint("CheckResult")
|
||||
@CallSuper
|
||||
override fun initiate() {
|
||||
initWidget()
|
||||
//如果不需要開麥,並且還沒有權限的情況下,重置狀態為需要去打開麥克風
|
||||
myUid = AuthModel.get().currentUid
|
||||
isCloseScreen = AvRoomDataManager.get().isCloseScreen
|
||||
@@ -275,6 +296,16 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
|
||||
//获取免费礼物详情
|
||||
mvpPresenter?.queryFreeFlower()
|
||||
initRoomAlbum()
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun initRoomAlbum() {
|
||||
RoomAlbumModel.listUnlockRoomPhoto(AvRoomDataManager.get().roomUid)
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe({
|
||||
AvRoomDataManager.get().unlockedRoomAlbumPhotos = it
|
||||
}, { toast(it.message) })
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
@@ -292,18 +323,22 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
GiftValueMrg.get().handleReconnect(false)
|
||||
}
|
||||
}
|
||||
|
||||
RoomEvent.ROOM_EXIT -> {
|
||||
// 退出房間,把標誌置為 false
|
||||
AvRoomDataManager.get().isFromMentoring = false
|
||||
// 退出房間的時候,要停止倒計時
|
||||
EventBus.getDefault().post(MentoringStopCountingEvent())
|
||||
}
|
||||
|
||||
RoomEvent.DOWN_CROWDED_MIC -> if (AvRoomDataManager.get().isOwner(roomEvent.account)) {
|
||||
toast(R.string.crowded_down)
|
||||
}
|
||||
|
||||
RoomEvent.ROOM_MANAGER_ADD, RoomEvent.ROOM_MANAGER_REMOVE -> {
|
||||
updateView()
|
||||
}
|
||||
|
||||
RoomEvent.ROOM_INFO_UPDATE -> {
|
||||
Logger.i(ResUtil.getString(R.string.avroom_fragment_baseroomfragment_01))
|
||||
addOpenDatingTips() //一定要放在updateView之前!!!
|
||||
@@ -313,6 +348,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
updateRemoteMuteBtn()
|
||||
openOrCloseGiftValue(false)
|
||||
}
|
||||
|
||||
RoomEvent.ENTER_ROOM -> {
|
||||
Logger.i(ResUtil.getString(R.string.avroom_fragment_baseroomfragment_02))
|
||||
updateView()
|
||||
@@ -320,6 +356,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
openOrCloseGiftValue(true)
|
||||
GiftValueMrg.get().updateRoomGiftValue(false)
|
||||
}
|
||||
|
||||
RoomEvent.ADD_BLACK_LIST -> onChatRoomMemberBlackAdd(roomEvent.account)
|
||||
RoomEvent.MIC_QUEUE_STATE_CHANGE -> onQueueMicStateChange()
|
||||
RoomEvent.KICK_DOWN_MIC_BY_S_ADMIN, RoomEvent.KICK_DOWN_MIC -> if (event == RoomEvent.KICK_DOWN_MIC) {
|
||||
@@ -335,16 +372,20 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
RoomEvent.DOWN_MIC -> {
|
||||
onDownMicro()
|
||||
}
|
||||
|
||||
RoomEvent.UP_MIC -> {
|
||||
onUpMicro()
|
||||
}
|
||||
|
||||
RoomEvent.INVITE_UP_MIC -> if (AvRoomDataManager.get().isOwner(roomEvent.account)) {
|
||||
//自己的消息
|
||||
onInviteUpMic(roomEvent.micPosition)
|
||||
}
|
||||
|
||||
RoomEvent.KICK_OUT_ROOM -> {
|
||||
val reason = roomEvent.reason
|
||||
if (reason != null && reason.reason == ChatRoomKickOutEvent.ChatRoomKickOutReason.CHAT_ROOM_INVALID) {
|
||||
@@ -362,6 +403,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
AvRoomDataManager.get().removeChatRoomMember(targetUid)
|
||||
}
|
||||
}
|
||||
|
||||
RoomEvent.LEAVE_MODE -> microView.adapter.notifyDataSetChanged()
|
||||
RoomEvent.ROOM_CLEAN_SCREEN -> messageView.clear()
|
||||
}
|
||||
@@ -544,7 +586,10 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
} else {
|
||||
val roomQueueInfo = AvRoomDataManager.get()
|
||||
.getRoomQueueMemberInfoByAccount(myUid.toString())
|
||||
if (roomQueueInfo?.mChatRoomMember != null
|
||||
if (roomQueueInfo?.mChatRoomMember?.isNoProhibitMic == true && roomQueueInfo.mRoomMicInfo?.isMicMute == false) {
|
||||
bottomView.setMicBtnEnable(true)
|
||||
bottomView.setMicBtnOpen(true)
|
||||
} else if (roomQueueInfo?.mChatRoomMember != null
|
||||
&& myUid.toString() == roomQueueInfo.mChatRoomMember.account
|
||||
&& roomQueueInfo.mRoomMicInfo?.isMicMute == true
|
||||
) {
|
||||
@@ -603,6 +648,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
releaseView()
|
||||
unregisterWidgets()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
@@ -632,13 +678,16 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
R.id.input_send -> {
|
||||
sendMsg()
|
||||
}
|
||||
|
||||
R.id.contribute_list -> {
|
||||
DialogWebViewActivity.start(mContext, UriProvider.getRoomRanking())
|
||||
mvpPresenter?.loadRoomRank()
|
||||
}
|
||||
|
||||
R.id.iv_first_charge_enter -> FirstChargeDialog.start(mContext)
|
||||
R.id.iv_treasure_box,
|
||||
R.id.iv_treasure_box_cp -> GoldBoxHelper.handleBoxClick(mContext)
|
||||
|
||||
R.id.iv_radish_entrance -> PullRadishActivity.start(mContext)
|
||||
}
|
||||
}
|
||||
@@ -707,6 +756,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
}
|
||||
.subscribe { _, throwable ->
|
||||
if (throwable != null) {
|
||||
toast(throwable.message)
|
||||
callback.onFail()
|
||||
} else {
|
||||
callback.onSuccess()
|
||||
@@ -983,6 +1033,9 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun toUpMicroPhone(micPosition: Int, currentUid: String, b: Boolean) {
|
||||
if (!lifecycle.currentState.isAtLeast(androidx.lifecycle.Lifecycle.State.CREATED)) {
|
||||
return
|
||||
}
|
||||
if (AvRoomDataManager.get().isSelfGamePlaying) {
|
||||
SingleToastUtil.showToast("遊戲中不可以換麥!")
|
||||
return
|
||||
@@ -1208,7 +1261,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
AudioEngineManager.get().isMute = !AudioEngineManager.get().isMute
|
||||
updateMicBtn()
|
||||
if (AudioEngineManager.get().isMute) {
|
||||
|
||||
AudioEngineManager.get().stopLocalAudio()
|
||||
} else if (AvRoomDataManager.get().isOnMic(myUid)) {
|
||||
AudioEngineManager.get().setRole(Constants.CLIENT_ROLE_BROADCASTER)
|
||||
}
|
||||
@@ -1232,10 +1285,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
}
|
||||
|
||||
override fun onSendMsgBtnClick() {
|
||||
inputLayout.visibility = View.VISIBLE
|
||||
inputEdit.isFocusableInTouchMode = true
|
||||
inputEdit.requestFocus()
|
||||
KeyBoardUtils.showKeyBoard(context, inputEdit)
|
||||
openMessageInput(null)
|
||||
}
|
||||
|
||||
override fun onSendGiftBtnClick() {
|
||||
@@ -1251,7 +1301,10 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
override fun onMoreBtnClick() {
|
||||
val dialog = RoomOperationDialog(mContext)
|
||||
dialog.setOnActionListener {
|
||||
redPackageSendDialog = RedPackageSendDialog()
|
||||
redPackageSendDialog = RedPackageSendDialog.newInstance(AvRoomDataManager.get().redEnvelopeType)
|
||||
redPackageSendDialog?.setOnDismissListener {
|
||||
redPackageSendDialog = null
|
||||
}
|
||||
redPackageSendDialog?.show(activity)
|
||||
}
|
||||
dialog.show()
|
||||
@@ -1261,4 +1314,55 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
RoomMsgActivity.start(mContext)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册组件
|
||||
*/
|
||||
protected fun registerWidget(name: String, widget: RoomWidget) {
|
||||
widgets.put(name, widget)
|
||||
widget.onStart(this)
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消注册组件
|
||||
*/
|
||||
protected fun unregisterWidgets() {
|
||||
widgets.values.forEach {
|
||||
it.onStop()
|
||||
}
|
||||
widgets.clear()
|
||||
}
|
||||
|
||||
override fun getLifecycleOwner(): LifecycleOwner {
|
||||
return this
|
||||
}
|
||||
|
||||
open fun initWidget() {
|
||||
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
open fun onOpenRoomMessageInputEvent(event: OpenRoomMessageInputEvent) {
|
||||
lifecycleScope.launch {
|
||||
lifecycle.withResumed {
|
||||
view?.postDelayed({
|
||||
openMessageInput(event.text)
|
||||
}, 500)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开公屏输入
|
||||
*/
|
||||
fun openMessageInput(text: String?) {
|
||||
inputLayout.visibility = View.VISIBLE
|
||||
if (text != null) {
|
||||
inputEdit.setText(text)
|
||||
inputEdit.setSelection(inputEdit.length())
|
||||
}
|
||||
inputEdit.isFocusableInTouchMode = true
|
||||
inputEdit.requestFocus()
|
||||
KeyBoardUtils.showKeyBoard(context, inputEdit)
|
||||
}
|
||||
}
|
@@ -0,0 +1,201 @@
|
||||
package com.yizhuan.erban.avroom.fragment
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.adapter.GameMicroViewAdapter
|
||||
import com.yizhuan.erban.avroom.adapter.GameMiniMicroViewAdapter
|
||||
import com.yizhuan.erban.avroom.adapter.OnMicroItemClickListener
|
||||
import com.yizhuan.erban.avroom.firstcharge.FirstChargePrizeDialog
|
||||
import com.yizhuan.erban.avroom.game.GameDelegate
|
||||
import com.yizhuan.erban.avroom.game.OnGameStatusChangeListener
|
||||
import com.yizhuan.erban.avroom.presenter.GameRoomPresenter
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageWidget
|
||||
import com.yizhuan.erban.avroom.view.IGameRoomView
|
||||
import com.yizhuan.erban.databinding.FragmentGameRoomBinding
|
||||
import com.yizhuan.erban.ui.widget.GiftDialog.OnGiftDialogBtnClickListener
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.music.model.PlayerModel
|
||||
import com.yizhuan.xchat_android_core.pay.event.FirstChargeEvent
|
||||
import com.yizhuan.xchat_android_core.room.event.FinishAvRoomEvent
|
||||
import com.yizhuan.xchat_android_library.base.factory.CreatePresenter
|
||||
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
|
||||
mvpPresenter?.getBannerList()
|
||||
gameBinding.tvShowMiniMic.setOnClickListener { showMiniMic() }
|
||||
gameBinding.ivShowMic.setOnClickListener { showMic() }
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onShowBanner(dialogInfos: List<BannerInfo>) {
|
||||
initRoomAct(gameBinding.activityImg, dialogInfos)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onFinishAvRoomEvent(event: FinishAvRoomEvent) {
|
||||
gameDelegate.exitGame()
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onFirstRechargeEvent(event: FirstChargeEvent) {
|
||||
FirstChargePrizeDialog(
|
||||
requireContext(),
|
||||
event.chargeProdTitle,
|
||||
event.firstChargeRewardList
|
||||
).openDialog()
|
||||
}
|
||||
|
||||
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(RedPackageWidget::class.java.simpleName, gameBinding.redPackageWidget)
|
||||
}
|
||||
}
|
@@ -32,6 +32,7 @@ import com.yizhuan.erban.avroom.activity.RoomOnlineUserActivity;
|
||||
import com.yizhuan.erban.avroom.adapter.SelectGameAdapter;
|
||||
import com.yizhuan.erban.avroom.dialog.ExitRoomPopupWindow;
|
||||
import com.yizhuan.erban.avroom.widget.GiftV2View;
|
||||
import com.yizhuan.erban.avroom.widget.RoomEffectView;
|
||||
import com.yizhuan.erban.base.BaseFragment;
|
||||
import com.yizhuan.erban.databinding.FragmentChatroomGameMainBinding;
|
||||
import com.yizhuan.erban.friend.view.SelectFriendActivity;
|
||||
@@ -78,6 +79,7 @@ import cn.sharesdk.framework.Platform;
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Action;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
|
||||
/**
|
||||
* 轰趴房
|
||||
@@ -98,6 +100,7 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
private ImageView ivRoomShare;
|
||||
private GiftV2View giftView;
|
||||
private ViewStub mVsGift2View;
|
||||
private RoomEffectView mRoomEffectView;
|
||||
|
||||
private SVGAImageView svgaRoomBg;
|
||||
private String[] bgPicture = new String[]{""};
|
||||
@@ -178,6 +181,7 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
mIvGoodNumber = mView.findViewById(R.id.iv_good_number);
|
||||
ivFollowRoom = mView.findViewById(R.id.iv_follow_room);
|
||||
svgaRoomBg = mView.findViewById(R.id.svga_image_view_bg);
|
||||
mRoomEffectView = mView.findViewById(R.id.room_effect_view);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -209,6 +213,13 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
ivRoomShare.setOnClickListener(this);
|
||||
gameMainBinding.llRoomInfo.setOnClickListener(this);
|
||||
gameMainBinding.ivBack.setOnClickListener(this);
|
||||
|
||||
mRoomEffectView.setOnPlayAnimCallback(new Function0<Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke() {
|
||||
return getIsAnim();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@@ -344,6 +355,24 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取礼物飘屏是否展示
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean getIsAnim() {
|
||||
if (giftView != null) {
|
||||
return giftView.getIsPlayAnim();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取玩法飘屏是否展示
|
||||
*/
|
||||
private boolean getIsPlayAnim() {
|
||||
return mRoomEffectView.getIsPlayAnim();
|
||||
}
|
||||
|
||||
private void onReceiveLuckyGiftToMultiMsg(LuckyBagGifts giftMultiReceiverInfo) {
|
||||
if (giftMultiReceiverInfo == null || !isResumed()) return;
|
||||
@@ -405,7 +434,9 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
Fragment tempFragment = roomFragment;
|
||||
switch (currentRoomInfo.getType()) {
|
||||
case RoomInfo.ROOMTYPE_GAME:
|
||||
toast(getString(R.string.room_game_is_not_open_yet));
|
||||
if (!(tempFragment instanceof GameRoomFragment)) {
|
||||
tempFragment = GameRoomFragment.newInstance();
|
||||
}
|
||||
break;
|
||||
case RoomInfo.ROOM_TYPE_SINGLE:
|
||||
if (!(tempFragment instanceof SingleRoomFragment)) {
|
||||
|
@@ -26,6 +26,7 @@ import com.yizhuan.erban.avroom.dialog.PKScoreBoardDialog;
|
||||
import com.yizhuan.erban.avroom.firstcharge.FirstChargePrizeDialog;
|
||||
import com.yizhuan.erban.avroom.giftvalue.GiftValueDialogUiHelper;
|
||||
import com.yizhuan.erban.avroom.presenter.HomePartyPresenter;
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageWidget;
|
||||
import com.yizhuan.erban.avroom.view.IHomePartyView;
|
||||
import com.yizhuan.erban.avroom.widget.PKBoardView;
|
||||
import com.yizhuan.erban.base.BaseMvpActivity;
|
||||
@@ -60,7 +61,6 @@ import com.yizhuan.xchat_android_core.room.queuing_mic.bean.RespQueuingMicListIn
|
||||
import com.yizhuan.xchat_android_core.room.queuing_mic.event.QueuingMicEmptyEvent;
|
||||
import com.yizhuan.xchat_android_core.room.queuing_mic.event.QueuingMicNotEmptyEvent;
|
||||
import com.yizhuan.xchat_android_core.super_admin.util.SuperAdminUtil;
|
||||
import com.yizhuan.xchat_android_core.user.UserModel;
|
||||
import com.yizhuan.xchat_android_core.utils.CurrentTimeUtils;
|
||||
import com.yizhuan.xchat_android_library.base.factory.CreatePresenter;
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil;
|
||||
@@ -134,6 +134,12 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
bottomView.setBottomViewListener(new PartyRoomBottomViewWrapper());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initWidget() {
|
||||
super.initWidget();
|
||||
registerWidget(RedPackageWidget.class.getSimpleName(), gameBinding.redPackageWidget);
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@Override
|
||||
public void initiate() {
|
||||
@@ -453,7 +459,7 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
if (!microType.equals(BaseMicroViewAdapter.MICRO_TYPE_CP)) {
|
||||
microView.bindAdapter(new CpMicroViewAdapter(mContext));
|
||||
}
|
||||
} else if (AvRoomDataManager.get().isDatingMode()) {
|
||||
} else if (AvRoomDataManager.get().isDatingMode()) {
|
||||
if (!microType.equals(BaseMicroViewAdapter.MICRO_TYPE_DATING)) {
|
||||
microView.bindAdapter(new DatingMicroViewAdapter(mContext));
|
||||
}
|
||||
@@ -527,7 +533,6 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (mDisposable != null) {
|
||||
@@ -809,7 +814,6 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
} else {
|
||||
gameBinding.ivTreasureBoxCp.setVisibility(View.GONE);
|
||||
gameBinding.ivTreasureBox.setVisibility(View.VISIBLE);
|
||||
|
||||
GlideApp.with(BasicConfig.INSTANCE.getAppContext())
|
||||
.load(GoldBoxHelper.getBoxIcon())
|
||||
.error(R.drawable.icon_room_treasure_box)
|
||||
@@ -965,9 +969,6 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
@Override
|
||||
public void onShowBanner(List<BannerInfo> bannerInfos) {
|
||||
initRoomAct(gameBinding.activityImg, bannerInfos, 11f);
|
||||
AvRoomModel.get().getRoomActTimer(AvRoomDataManager.get().getRoomUid())
|
||||
.compose(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -16,6 +16,7 @@ import com.yizhuan.erban.avroom.adapter.SingleRoomPKMicroViewAdapter
|
||||
import com.yizhuan.erban.avroom.dialog.RequestUpMicDialog
|
||||
import com.yizhuan.erban.avroom.firstcharge.FirstChargePrizeDialog
|
||||
import com.yizhuan.erban.avroom.presenter.SingleRoomPresenter
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageWidget
|
||||
import com.yizhuan.erban.avroom.singleroompk.SingleRoomPkFinishDialog
|
||||
import com.yizhuan.erban.avroom.singleroompk.SingleRoomPkForceFinishDialog
|
||||
import com.yizhuan.erban.avroom.singleroompk.SingleRoomPkReceivedDialog
|
||||
@@ -262,4 +263,8 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
|
||||
).openDialog()
|
||||
}
|
||||
|
||||
override fun initWidget() {
|
||||
super.initWidget()
|
||||
registerWidget(RedPackageWidget::class.java.simpleName, gameBinding.redPackageWidget)
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
Copyright © Sud.Tech
|
||||
https://sud.tech
|
||||
*/
|
||||
package com.yizhuan.erban.avroom.game;
|
||||
|
||||
import com.yizhuan.xchat_android_library.BuildConfig;
|
||||
|
||||
public class AppConfig {
|
||||
|
||||
protected static final String APP_ID = "1578948593831571457";
|
||||
protected static final String APP_KEY = "J9lHOXvFWkAZiTfl4SK7IGt0wDnW3fWd";
|
||||
protected static boolean isTestEnv = BuildConfig.DEBUG;
|
||||
|
||||
}
|
673
app/src/main/java/com/yizhuan/erban/avroom/game/GameDelegate.kt
Normal file
@@ -0,0 +1,673 @@
|
||||
package com.yizhuan.erban.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.yizhuan.erban.R
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.room.game.GameCfg
|
||||
import com.yizhuan.xchat_android_core.room.game.GameModel
|
||||
import com.yizhuan.xchat_android_core.room.game.GameStatus
|
||||
import com.yizhuan.xchat_android_core.room.model.HomePartyModel
|
||||
import com.yizhuan.xchat_android_core.user.UserModel
|
||||
import com.yizhuan.xchat_android_core.utils.LogUtils
|
||||
import com.yizhuan.xchat_android_core.utils.net.RxHelper
|
||||
import com.yizhuan.xchat_android_library.net.rxnet.callback.CallBack
|
||||
import com.yizhuan.xchat_android_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 = AvRoomDataManager.get().roomUid.toString()
|
||||
private val 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
|
||||
login(loginCallback)
|
||||
}
|
||||
|
||||
fun updateGame(mgId: Long?) {
|
||||
if (mgId == null || mgId == 0L || 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) {
|
||||
showToast("初始化遊戲SDK失敗:$code--errInfo:$errInfo")
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
|
||||
/**
|
||||
* 遊戲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.yizhuan.erban.avroom.game
|
||||
|
||||
interface OnGameStatusChangeListener {
|
||||
/**
|
||||
* 游戏开始
|
||||
*/
|
||||
fun onGameStart()
|
||||
|
||||
/**
|
||||
* 游戏结束
|
||||
*/
|
||||
fun onGameEnd()
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
Copyright © Sud.Tech
|
||||
https://sud.tech
|
||||
*/
|
||||
package com.yizhuan.erban.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";
|
||||
|
||||
}
|
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
Copyright © Sud.Tech
|
||||
https://sud.tech
|
||||
*/
|
||||
package com.yizhuan.erban.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";
|
||||
|
||||
}
|
@@ -20,6 +20,8 @@ import com.netease.nimlib.sdk.chatroom.model.EnterChatRoomResultData;
|
||||
import com.netease.nimlib.sdk.util.Entry;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.avroom.activity.AVRoomActivity;
|
||||
import com.yizhuan.erban.avroom.core.AudioRoomContext;
|
||||
import com.yizhuan.xchat_android_core.support.room.RoomContext;
|
||||
import com.yizhuan.erban.avroom.view.IAvRoomView;
|
||||
import com.yizhuan.erban.base.BaseMvpPresenter;
|
||||
import com.yizhuan.xchat_android_core.Constants;
|
||||
@@ -128,6 +130,8 @@ public class AvRoomPresenter extends BaseMvpPresenter<IAvRoomView> {
|
||||
.subscribe(roomQueueInfoSparseArray -> {
|
||||
long uid = AuthModel.get().getCurrentUid();
|
||||
AudioEngineManager.get().startRtcEngine(uid, roomInfo.getAudioSdkType());
|
||||
// TODO 临时方案:后续逐步完善整个房间的RoomContext替换计划
|
||||
new AudioRoomContext(roomInfo.getUid()).run();
|
||||
if (getMvpView() != null) {
|
||||
getMvpView().enterRoomSuccess();
|
||||
}
|
||||
@@ -482,7 +486,6 @@ public class AvRoomPresenter extends BaseMvpPresenter<IAvRoomView> {
|
||||
public void onNext(Long aLong) {
|
||||
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (roomInfo == null) return;
|
||||
Log.d(TAG, "onNext: roomInfo in startGetOnlineMemberNumberJob: " + roomInfo);
|
||||
Log.d(TAG, "onNext: has login in IM: " + AuthModel.get().isImLogin());
|
||||
Disposable subscribe = mAvRoomModel.startGetOnlineMemberNumberJob(roomInfo.getRoomId())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
@@ -1,20 +0,0 @@
|
||||
package com.yizhuan.erban.avroom.redpackage
|
||||
|
||||
import android.widget.TextView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtils
|
||||
import com.yizhuan.xchat_android_core.redpackage.RedEnvelopeGiftItemVO
|
||||
|
||||
class RedPackageGiftAdapter(layoutId: Int = R.layout.item_red_package_gift) :
|
||||
BaseQuickAdapter<RedEnvelopeGiftItemVO, BaseViewHolder>(layoutId) {
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: RedEnvelopeGiftItemVO) {
|
||||
ImageLoadUtils.loadAvatar(mContext, item.giftVo?.giftUrl, helper.getView(R.id.iv_gift))
|
||||
helper.setText(R.id.tv_gift_num, "x${item.giftNum}")
|
||||
helper.getView<TextView>(R.id.tv_gift_name)?.let {
|
||||
it.text = item.giftVo?.giftName
|
||||
}
|
||||
}
|
||||
}
|
@@ -42,15 +42,15 @@ class RedPackageGoRoomDialog : BaseDialog<DialogRedPackageGoRoomBinding>() {
|
||||
|
||||
override fun init() {
|
||||
AnimationUtils.loadAnimation(context, R.anim.anim_all_red_package).apply {
|
||||
binding.clRed.animation = this
|
||||
binding?.clRed?.animation = this
|
||||
start()
|
||||
}
|
||||
AnimationUtils.loadAnimation(context, R.anim.anim_all_red_package_in_btn).let {
|
||||
binding.ivGoRoom.animation = it
|
||||
binding?.ivGoRoom?.animation = it
|
||||
it.start()
|
||||
}
|
||||
binding.ivClose.setOnClickListener { dismissAllowingStateLoss() }
|
||||
binding.ivGoRoom.setOnClickListener {
|
||||
binding?.ivClose?.setOnClickListener { dismissAllowingStateLoss() }
|
||||
binding?.ivGoRoom?.setOnClickListener {
|
||||
val jump = {
|
||||
AVRoomActivity.start(context, redPackageNotifyInfo.roomUid,
|
||||
AVRoomActivity.FROM_TYPE_ALL_RED, redPackageNotifyInfo.sendUserNick, redPackageNotifyInfo)
|
||||
@@ -69,10 +69,10 @@ class RedPackageGoRoomDialog : BaseDialog<DialogRedPackageGoRoomBinding>() {
|
||||
|
||||
}
|
||||
redPackageNotifyInfo.let {
|
||||
ImageLoadUtils.loadAvatar(context, it.sendUserAvatar, binding.ivAvatar)
|
||||
binding.tvContent.text = it.redEnvelopeMessage
|
||||
binding.tvNickname.text = it.sendUserNick.subAndReplaceDot()
|
||||
binding.tvRoomName.text = it.roomTitle.subAndReplaceDot()
|
||||
ImageLoadUtils.loadAvatar(context, it.sendUserAvatar, binding?.ivAvatar)
|
||||
binding?.tvContent?.text = it.redEnvelopeMessage
|
||||
binding?.tvNickname?.text = it.sendUserNick.subAndReplaceDot()
|
||||
binding?.tvRoomName?.text = it.roomTitle.subAndReplaceDot()
|
||||
}
|
||||
// StatUtil.onEvent("gethongbao", ResUtil.getString(R.string.avroom_redpackage_redpackagegoroomdialog_03))
|
||||
}
|
||||
|
@@ -0,0 +1,169 @@
|
||||
package com.yizhuan.erban.avroom.redpackage
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.yizhuan.erban.avroom.activity.AVRoomActivity
|
||||
import com.yizhuan.erban.avroom.redpackage.open.RedPackageOpenDialog
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RedPackageAttachment
|
||||
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager
|
||||
import com.yizhuan.xchat_android_core.manager.RoomEvent
|
||||
import com.yizhuan.xchat_android_core.redpackage.RedPackageModel
|
||||
import com.yizhuan.xchat_android_core.redpackage.RedPackageNotifyInfo
|
||||
import com.yizhuan.xchat_android_core.support.room.RoomContext
|
||||
import com.yizhuan.xchat_android_core.support.room.RoomHandler
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/10/26 11:26
|
||||
* Desc:红包处理器
|
||||
**/
|
||||
class RedPackageHandler : RoomHandler() {
|
||||
|
||||
// 入口图标-数据
|
||||
val iconLiveData: MutableLiveData<RedPackageNotifyInfo?> = MutableLiveData()
|
||||
|
||||
/**
|
||||
* 红包相关操作计数;目前的红包操作为:【正在打开当前房间的红包弹窗】。
|
||||
* 展示时+1,销毁时-1,以此来判断是否正在进行红包操作)
|
||||
*/
|
||||
private var operationCount: Int = 0
|
||||
|
||||
val inOperation get() = operationCount > 0
|
||||
|
||||
override fun onStart(context: RoomContext) {
|
||||
super.onStart(context)
|
||||
registerSignaling()
|
||||
}
|
||||
|
||||
override fun onStop(context: RoomContext) {
|
||||
super.onStop(context)
|
||||
}
|
||||
|
||||
override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
|
||||
super.onStateChanged(source, event)
|
||||
if (event == Lifecycle.Event.ON_RESUME) {
|
||||
requestLatestRoomRedPackage()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 尝试展示红包
|
||||
* PS:目前这个方法仅为了解决:通过房间外的红包入口进入房间后,需要查询该红包,展示出来。
|
||||
*/
|
||||
fun tryShowRedPackage(redPackageId: Long) {
|
||||
val disposable = RedPackageModel.getRedPackage(redPackageId)
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe({ item ->
|
||||
if (item.state != 3 && item.state != 6 && item.state != 4) {
|
||||
roomView?.getActivity().let {
|
||||
RedPackageOpenDialog.newInstance(item).show(it)
|
||||
}
|
||||
}
|
||||
}, {})
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听房间信令
|
||||
*/
|
||||
private fun registerSignaling() {
|
||||
// TODO 临时方案:不应在这里直接监听IM,后续会统一分发出口
|
||||
// 信令来源:新/旧版的厅内红包,非全服红包
|
||||
IMNetEaseManager.get().chatRoomEventObservable
|
||||
.compose<RoomEvent>(bindToLifecycle<RoomEvent>())
|
||||
.filter {
|
||||
it?.event == RoomEvent.RECEIVE_RED_PACKAGE && it?.chatRoomMessage?.attachment is RedPackageAttachment
|
||||
}.map {
|
||||
(it.chatRoomMessage.attachment as RedPackageAttachment).getRedPackageNotifyInfo()
|
||||
}
|
||||
.subscribe { data: RedPackageNotifyInfo ->
|
||||
handleRoomRedPackage(data, true)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找最新的厅内红包(新/旧版的厅内红包,非全服红包)
|
||||
*/
|
||||
private fun requestLatestRoomRedPackage() {
|
||||
val roomId = roomContext?.roomId ?: return
|
||||
RedPackageModel.getLatestRoomRedPackage(roomId)
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe({ data ->
|
||||
handleRoomRedPackage(data, false)
|
||||
}, {
|
||||
if (it.message == "No RedPackage") {
|
||||
updateIcon(null)
|
||||
} else {
|
||||
// 网络等原因的失败,不处理就好
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理厅内红包,非全服红包
|
||||
* @param isSignaling 是否来自信令?
|
||||
*/
|
||||
private fun handleRoomRedPackage(data: RedPackageNotifyInfo, isSignaling: Boolean) {
|
||||
tryShowOpenDialog(data, isSignaling)
|
||||
updateIcon(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新红包入口图标
|
||||
*/
|
||||
private fun updateIcon(data: RedPackageNotifyInfo?) {
|
||||
iconLiveData.postValue(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 尝试展示红包领取弹窗
|
||||
*/
|
||||
private fun tryShowOpenDialog(data: RedPackageNotifyInfo, isSignaling: Boolean) {
|
||||
val activity = roomView?.getActivity() ?: return
|
||||
if (activity.isFinishing) {
|
||||
return
|
||||
}
|
||||
if (!isSignaling) {
|
||||
return
|
||||
}
|
||||
if (data.kind == 0 || (data.kind == 1 && data.validityType == 0)) {
|
||||
//【旧版本-厅内红包:kind=0】、【新版本-厅内无门槛-立即生效红包:kind=1&validityType=0】
|
||||
RedPackageOpenDialog.newInstance(data).show(activity)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求刷新Icon(数据已过期)
|
||||
*/
|
||||
fun requestRefreshIcon() {
|
||||
// updateIcon(null)
|
||||
requestLatestRoomRedPackage()
|
||||
}
|
||||
|
||||
fun startOperation() {
|
||||
operationCount++
|
||||
}
|
||||
|
||||
fun stopOperation() {
|
||||
operationCount--
|
||||
}
|
||||
|
||||
/**
|
||||
* 全服红包信令(之前是在BaseActivity中处理的;现在为了红包的一个需求,暂且拦截到这里处理)
|
||||
*/
|
||||
fun onAllServiceSignaling(context: Context, data: RedPackageNotifyInfo) {
|
||||
if (context is AVRoomActivity) {
|
||||
if (roomContext?.roomId == data.roomUid) {
|
||||
RedPackageOpenDialog.newInstance(data).show(context)
|
||||
} else {
|
||||
if (!inOperation) {
|
||||
RedPackageGoRoomDialog.newInstance(data).show(context)
|
||||
} else {
|
||||
// 需求:正在房间中领取红包时,不展示其他房间的全服红包
|
||||
}
|
||||
}
|
||||
} else {
|
||||
RedPackageGoRoomDialog.newInstance(data).show(context)
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
package com.yizhuan.erban.avroom.redpackage
|
||||
|
||||
import android.graphics.Color
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtils
|
||||
import com.yizhuan.erban.utils.UserUtils
|
||||
import com.yizhuan.xchat_android_core.redpackage.RedEnvelopeItemVO
|
||||
import com.yizhuan.xchat_android_core.utils.subAndReplaceDot
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
class RedPackageOpenAdapter : BaseQuickAdapter<RedEnvelopeItemVO, BaseViewHolder>(R.layout.item_red_package_diamond) {
|
||||
private val dateFormat = SimpleDateFormat(ResUtil.getString(R.string.avroom_redpackage_redpackageopenadapter_01), Locale.CHINA)
|
||||
override fun convert(helper: BaseViewHolder, item: RedEnvelopeItemVO) {
|
||||
ImageLoadUtils.loadAvatar(mContext, item.userVO.avatar, helper.getView(R.id.iv_avatar))
|
||||
val isSelf = item.userVO.uid == UserUtils.getUserUid()
|
||||
helper.setText(R.id.tv_nickname, if (isSelf) ResUtil.getString(R.string.avroom_redpackage_redpackageopenadapter_02) else item.userVO.nick.subAndReplaceDot(6))
|
||||
.setTextColor(R.id.tv_nickname, Color.parseColor(if (isSelf) "#FDCD00" else "#FFFFFF"))
|
||||
.setText(R.id.tv_time, dateFormat.format(item.createTime))
|
||||
.setText(R.id.tv_diamond_num, item.amount.substringBefore("."))
|
||||
|
||||
item.redEnvelopeGiftItemVOs?.let {
|
||||
if (it.isNotEmpty()) {
|
||||
helper.setGone(R.id.tv_diamond_num, false)
|
||||
val rvGift = helper.getView<RecyclerView>(R.id.rv_gift)
|
||||
val adapter = RedPackageGiftAdapter()
|
||||
rvGift.visibility = View.VISIBLE
|
||||
rvGift.layoutManager = LinearLayoutManager(mContext, RecyclerView.HORIZONTAL, false)
|
||||
rvGift.adapter = adapter
|
||||
adapter.setNewData(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,188 +0,0 @@
|
||||
package com.yizhuan.erban.avroom.redpackage
|
||||
|
||||
|
||||
import android.animation.Animator
|
||||
import android.animation.AnimatorListenerAdapter
|
||||
import android.animation.ObjectAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.view.animation.AccelerateDecelerateInterpolator
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.widget.MessageView
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.databinding.DialogRedPackageOpenBinding
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtils
|
||||
import com.yizhuan.erban.utils.UserUtils
|
||||
import com.yizhuan.xchat_android_core.DemoCache
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.home.event.FollowRoomEvent
|
||||
import com.yizhuan.xchat_android_core.home.model.CollectionRoomModel
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.pay.PayModel
|
||||
import com.yizhuan.xchat_android_core.redpackage.*
|
||||
import com.yizhuan.xchat_android_core.redpackage.RedEnvelopeState.Companion.REMAIN_ZERO
|
||||
import com.yizhuan.xchat_android_core.redpackage.RedEnvelopeState.Companion.SUCCESS
|
||||
import com.yizhuan.xchat_android_core.redpackage.RedEnvelopeState.Companion.TIME_OUT
|
||||
import com.yizhuan.xchat_android_core.redpackage.RedEnvelopeState.Companion.TIME_OUT_BACK
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
class RedPackageOpenDialog : BaseDialog<DialogRedPackageOpenBinding>() {
|
||||
|
||||
private var mObjectAnimator: ObjectAnimator? = null
|
||||
|
||||
private val redPackageNotifyInfo by lazy { arguments?.getSerializable(KEY_NOTIFY_INFO) as RedPackageNotifyInfo }
|
||||
|
||||
private var isOpened = false
|
||||
private var redPackageInfo: RedPackageInfo? = null
|
||||
|
||||
companion object {
|
||||
private const val KEY_NOTIFY_INFO = "redPackageNotifyInfo"
|
||||
fun newInstance(redPackageNotifyInfo: RedPackageNotifyInfo): RedPackageOpenDialog {
|
||||
return RedPackageOpenDialog().apply {
|
||||
arguments = Bundle().apply {
|
||||
putSerializable(KEY_NOTIFY_INFO, redPackageNotifyInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
super.onStart()
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
dialog?.setCanceledOnTouchOutside(false)
|
||||
binding.ivClose.setOnClickListener { dismissAllowingStateLoss() }
|
||||
binding.ivOpen.setOnClickListener {
|
||||
startRedPacketAnim(it)
|
||||
it.isEnabled = false
|
||||
}
|
||||
redPackageNotifyInfo.let {
|
||||
ImageLoadUtils.loadAvatar(context, it.sendUserAvatar, binding.ivAvatar)
|
||||
binding.tvContent.text = it.redEnvelopeMessage
|
||||
binding.tvNickname.text = it.sendUserNick
|
||||
}
|
||||
// StatUtil.onEvent("openhongbao", ResUtil.getString(R.string.avroom_redpackage_redpackageopendialog_01))
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun startRedPacketAnim(v: View) {
|
||||
RedPackageModel.openRedPackage(redPackageNotifyInfo.redEnvelopeId)
|
||||
.subscribe({
|
||||
redPackageInfo = it
|
||||
if (mObjectAnimator?.isRunning == false) {
|
||||
openRedPackage()
|
||||
}
|
||||
}
|
||||
, {
|
||||
binding.ivOpen.isEnabled = true
|
||||
mObjectAnimator?.cancel()
|
||||
SingleToastUtil.showToast(it.message)
|
||||
})
|
||||
|
||||
mObjectAnimator = ObjectAnimator.ofFloat(v, "rotationY", 0f, 360f)
|
||||
mObjectAnimator?.let {
|
||||
it.duration = 1500
|
||||
it.interpolator = AccelerateDecelerateInterpolator()
|
||||
it.addListener(object : AnimatorListenerAdapter() {
|
||||
|
||||
var isCanceled = false
|
||||
override fun onAnimationCancel(animation: Animator?) {
|
||||
isCanceled = true
|
||||
}
|
||||
|
||||
override fun onAnimationEnd(animation: Animator?) {
|
||||
if (!isCanceled) {
|
||||
openRedPackage()
|
||||
}
|
||||
}
|
||||
})
|
||||
it.start()
|
||||
}
|
||||
// StatUtil.onEvent("openhongbao_open", ResUtil.getString(R.string.avroom_redpackage_redpackageopendialog_02))
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun openRedPackage() {
|
||||
if (isOpened) return
|
||||
redPackageInfo?.let { packageInfo ->
|
||||
isOpened = true
|
||||
binding.clOpened.visibility = View.VISIBLE
|
||||
binding.clRed.visibility = View.GONE
|
||||
binding.tvNicknameOpened.text = redPackageNotifyInfo.sendUserNick
|
||||
ImageLoadUtils.loadAvatar(context, redPackageNotifyInfo.sendUserAvatar, binding.ivAvatarOpened)
|
||||
packageInfo.redEnvelopeVO?.apply {
|
||||
binding.tvContentOpened.text = message
|
||||
when (packageInfo.redEnvelopeState) {
|
||||
SUCCESS -> {
|
||||
packageInfo.redEnvelopeItemVOs?.firstOrNull { item -> item.userVO.uid == UserUtils.getUserUid() }?.let {
|
||||
it.redEnvelopeGiftItemVOs?.apply {
|
||||
if (!isEmpty()) {
|
||||
val adapter = RedPackageGiftAdapter(R.layout.item_red_package_gift_top)
|
||||
binding.rvGift.visibility = View.VISIBLE
|
||||
binding.tvDiamondNum.visibility = View.GONE
|
||||
binding.rvGift.layoutManager = LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
|
||||
binding.rvGift.adapter = adapter
|
||||
adapter.setNewData(this)
|
||||
binding.tvTips.setTextColor(Color.WHITE)
|
||||
binding.tvTips.text = MessageView.SpannableBuilder(binding.tvTips)
|
||||
.append(ResUtil.getString(R.string.avroom_redpackage_redpackageopendialog_03))
|
||||
.append(it.amount, ForegroundColorSpan(Color.parseColor("#FDCD00")))
|
||||
.append(ResUtil.getString(R.string.avroom_redpackage_redpackageopendialog_04))
|
||||
.build()
|
||||
}
|
||||
}
|
||||
binding.tvDiamondNum.text = it.amount.substringBefore(".")
|
||||
}
|
||||
if (!AvRoomDataManager.get().isRoomFans){
|
||||
AvRoomDataManager.get().roomUid.let {
|
||||
CollectionRoomModel.get().followRoom("1", it)
|
||||
.subscribe { _: String? ->
|
||||
AvRoomDataManager.get().isRoomFans = true
|
||||
EventBus.getDefault().post(FollowRoomEvent())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
TIME_OUT, REMAIN_ZERO, TIME_OUT_BACK -> {
|
||||
binding.clOpened.setBackgroundResource(R.drawable.room_red_package_get_bg)
|
||||
binding.tvDiamondNum.visibility = View.GONE
|
||||
binding.tvTips.visibility = View.GONE
|
||||
binding.tvNoGet.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
binding.tvRedNum.text = "已領取${pickNum}/${totalNum}個"
|
||||
if (type == ALL_GIFT || type == ALL_DIAMOND) {
|
||||
DemoCache.saveRedPackage(id)
|
||||
}
|
||||
}
|
||||
val adapter = RedPackageOpenAdapter()
|
||||
binding.rvUsers.adapter = adapter
|
||||
binding.rvUsers.layoutManager = LinearLayoutManager(context)
|
||||
adapter.setNewData(packageInfo.redEnvelopeItemVOs)
|
||||
PayModel.get().getWalletInfo(AuthModel.get().currentUid).subscribe()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
mObjectAnimator?.cancel()
|
||||
mObjectAnimator = null
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
}
|
@@ -1,274 +0,0 @@
|
||||
package com.yizhuan.erban.avroom.redpackage
|
||||
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.Paint
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.common.widget.dialog.DialogManager
|
||||
import com.yizhuan.erban.databinding.DialogRedPackageSendBinding
|
||||
import com.yizhuan.erban.pay.password.GiveGoldPassWordFragment
|
||||
import com.yizhuan.erban.pay.widget.GridPasswordNoFocusView
|
||||
import com.yizhuan.erban.ui.pay.ChargeActivity
|
||||
import com.yizhuan.erban.ui.setting.ModifyPwdActivity
|
||||
import com.yizhuan.erban.ui.webview.CommonWebViewActivity
|
||||
import com.yizhuan.erban.ui.webview.DialogWebViewActivity
|
||||
import com.yizhuan.xchat_android_core.Constants
|
||||
import com.yizhuan.xchat_android_core.UriProvider
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.initial.InitialModel
|
||||
import com.yizhuan.xchat_android_core.initial.bean.InitInfo
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.pay.PayModel
|
||||
import com.yizhuan.xchat_android_core.pay.event.UpdateWalletInfoEvent
|
||||
import com.yizhuan.xchat_android_core.redpackage.*
|
||||
import com.yizhuan.xchat_android_core.user.UserModel
|
||||
import com.yizhuan.xchat_android_core.utils.toIntOrDef
|
||||
import com.yizhuan.xchat_android_library.annatation.ActLayoutRes
|
||||
import com.yizhuan.xchat_android_library.common.util.DeviceUtil
|
||||
import com.yizhuan.xchat_android_library.utils.AppMetaDataUtil
|
||||
import com.yizhuan.xchat_android_library.utils.CommonUtils
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
|
||||
import com.yizhuan.xchat_android_library.utils.codec.DESUtils
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
@ActLayoutRes(R.layout.dialog_red_package_send)
|
||||
class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPasswordNoFocusView.OnPasswordChangedListener, TextWatcher {
|
||||
|
||||
private var passWordFragment: GiveGoldPassWordFragment? = null
|
||||
private val dialogManager by lazy { DialogManager(context) }
|
||||
private var isAll = false
|
||||
private var isGift = false
|
||||
|
||||
override fun onStart() {
|
||||
width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
super.onStart()
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun init() {
|
||||
|
||||
EventBus.getDefault().register(this)
|
||||
PayModel.get().currentWalletInfo?.let {
|
||||
binding.tvBalanceNum.text = it.diamondNum.toInt().toString()
|
||||
}
|
||||
if (InitialModel.get().cacheInitInfo == null) {
|
||||
InitialModel.get().init(true)
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_redpackage_redpackagesenddialog_01))
|
||||
dismissAllowingStateLoss()
|
||||
return
|
||||
}
|
||||
val initInfo = InitialModel.get().cacheInitInfo ?: InitInfo()
|
||||
|
||||
/**
|
||||
* 廳內
|
||||
*/
|
||||
fun changeToNotAll() {
|
||||
isAll = false
|
||||
binding.tvAllRed.alpha = 0.5f
|
||||
binding.tvRoomRed.alpha = 1f
|
||||
binding.indicatorAllRed.visibility = View.GONE
|
||||
binding.indicatorRoomRed.visibility = View.VISIBLE
|
||||
binding.tvGoldNumHint.text = "紅包總金額不低於${initInfo.redEnvelopeConfig.roomRedEnvelopeMinAmount}鉆石,且必須為10的倍數"
|
||||
binding.editRedNum.hint = "${initInfo.redEnvelopeConfig.roomRedEnvelopeMinNum}-${initInfo.redEnvelopeConfig.roomRedEnvelopeMaxNum}"
|
||||
}
|
||||
|
||||
/**
|
||||
* 全服
|
||||
*/
|
||||
fun changeToAll() {
|
||||
isAll = true
|
||||
binding.tvAllRed.alpha = 1f
|
||||
binding.tvRoomRed.alpha = 0.5f
|
||||
binding.indicatorAllRed.visibility = View.VISIBLE
|
||||
binding.indicatorRoomRed.visibility = View.GONE
|
||||
binding.tvGoldNumHint.text = "紅包總金額不低於${initInfo.redEnvelopeConfig.serverRedEnvelopeMinAmount}鉆石,且必須為100的倍數"
|
||||
binding.editRedNum.hint = "${initInfo.redEnvelopeConfig.serverRedEnvelopeMinNum}-${initInfo.redEnvelopeConfig.serverRedEnvelopeMaxNum}"
|
||||
}
|
||||
|
||||
when (initInfo.redEnvelopedPosition) {
|
||||
2 -> changeToAll()
|
||||
else -> changeToNotAll()
|
||||
}
|
||||
binding.tvCharge.paint.flags = Paint.UNDERLINE_TEXT_FLAG
|
||||
binding.tvCharge.paint.isAntiAlias = true
|
||||
binding.tvChangeType.paint.flags = Paint.UNDERLINE_TEXT_FLAG
|
||||
binding.tvChangeType.paint.isAntiAlias = true
|
||||
binding.tvChangeType.setOnClickListener {
|
||||
if (isGift) {
|
||||
isGift = false
|
||||
binding.tvRedTypeHint.text = "當前為手氣紅包,"
|
||||
binding.tvChangeType.text = "改為禮物紅包"
|
||||
} else {
|
||||
isGift = true
|
||||
binding.tvRedTypeHint.text = "當前為禮物紅包,"
|
||||
binding.tvChangeType.text = "改為手氣紅包"
|
||||
}
|
||||
}
|
||||
//默認就已經是手氣紅包,如果後臺配置為了禮物紅包就在這裏改下
|
||||
if (initInfo.redEnvelopeType == 2 && !isGift) {
|
||||
binding.tvChangeType.callOnClick()
|
||||
}
|
||||
|
||||
binding.tvCharge.setOnClickListener {
|
||||
if (!CommonUtils.isFastDoubleClick(800)) {
|
||||
if (AppMetaDataUtil.getChannelID() == Constants.GOOGLE) {
|
||||
ChargeActivity.start(context)
|
||||
} else {
|
||||
CommonWebViewActivity.start(
|
||||
context, UriProvider.getOfficialPay(
|
||||
4,
|
||||
DeviceUtil.getDeviceId(context)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
binding.ivClose.setOnClickListener { dismissAllowingStateLoss() }
|
||||
binding.ivHelp.setOnClickListener { DialogWebViewActivity.start(context, UriProvider.getRedPacketRule()) }
|
||||
binding.ivSend.setOnClickListener {
|
||||
UserModel.get().cacheLoginUserInfo?.let {
|
||||
if (!it.isBindPaymentPwd) {
|
||||
ModifyPwdActivity.start(context, ModifyPwdActivity.PAY_PWD)
|
||||
return@setOnClickListener
|
||||
}
|
||||
}
|
||||
val minNum = if (isAll) initInfo.redEnvelopeConfig.serverRedEnvelopeMinNum else initInfo.redEnvelopeConfig.roomRedEnvelopeMinNum
|
||||
val maxNum = if (isAll) initInfo.redEnvelopeConfig.serverRedEnvelopeMaxNum else initInfo.redEnvelopeConfig.roomRedEnvelopeMaxNum
|
||||
val minGold = if (isAll) initInfo.redEnvelopeConfig.serverRedEnvelopeMinAmount else initInfo.redEnvelopeConfig.roomRedEnvelopeMinAmount
|
||||
val maxGold = if (isAll) initInfo.redEnvelopeConfig.serverRedEnvelopeMaxAmount else initInfo.redEnvelopeConfig.roomRedEnvelopeMaxAmount
|
||||
val rate = if (initInfo.redEnvelopeConfig.exchangeDiamondsRate == 0.0) 0.68 else initInfo.redEnvelopeConfig.exchangeDiamondsRate
|
||||
|
||||
val redNum = binding.editRedNum.text.toString().toIntOrDef()
|
||||
if (redNum < minNum || redNum > maxNum) {
|
||||
SingleToastUtil.showToast("紅包數量不能小於${minNum}或大於${maxNum}!")
|
||||
return@setOnClickListener
|
||||
}
|
||||
val goldNum = binding.editGoldNum.text.toString().toIntOrDef()
|
||||
|
||||
if (isAll) {
|
||||
if (goldNum % 100 != 0) {
|
||||
SingleToastUtil.showToast("鉆石數必須為100的倍數!")
|
||||
return@setOnClickListener
|
||||
}
|
||||
} else {
|
||||
if (goldNum % 10 != 0) {
|
||||
SingleToastUtil.showToast("鉆石數必須為10的倍數!")
|
||||
return@setOnClickListener
|
||||
}
|
||||
}
|
||||
|
||||
if (goldNum < minGold || goldNum > maxGold) {
|
||||
SingleToastUtil.showToast("鉆石數量不能小於${minGold}或大於${maxGold}!")
|
||||
return@setOnClickListener
|
||||
}
|
||||
if (isGift && goldNum.toFloat() / redNum < 1) {//單個禮物紅包價值不低於1鉆石
|
||||
SingleToastUtil.showToast("單個紅包金額過低")
|
||||
return@setOnClickListener
|
||||
}
|
||||
if (!isGift && goldNum.toFloat() / redNum * rate < 0.1) {//單個手氣紅包價值不低於0.1水晶
|
||||
SingleToastUtil.showToast("單個紅包金額過低")
|
||||
return@setOnClickListener
|
||||
}
|
||||
GiveGoldPassWordFragment.newInstance(childFragmentManager, binding.editGoldNum.text.toString()).apply {
|
||||
setListener(this@RedPackageSendDialog)
|
||||
passWordFragment = this
|
||||
}
|
||||
};
|
||||
binding.tvAllRed.setOnClickListener {
|
||||
if (isAll) return@setOnClickListener
|
||||
changeToAll()
|
||||
}
|
||||
binding.tvRoomRed.setOnClickListener {
|
||||
if (!isAll) return@setOnClickListener
|
||||
changeToNotAll()
|
||||
}
|
||||
binding.editRedText.addTextChangedListener(this)
|
||||
|
||||
binding.editRedText.setOnEditorActionListener { _, _, event ->
|
||||
event.keyCode == KeyEvent.KEYCODE_ENTER
|
||||
}
|
||||
|
||||
// StatUtil.onEvent("room_sendhongbao", "進入發紅包頁面")
|
||||
}
|
||||
|
||||
private fun getRedType(): Int {
|
||||
return if (isAll) {
|
||||
if (isGift) ALL_GIFT else ALL_DIAMOND
|
||||
} else {
|
||||
if (isGift) ROOM_GIFT else ROOM_DIAMOND
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
binding.editRedText.removeTextChangedListener(this)
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun onTextChanged(psw: String) {
|
||||
val password = passWordFragment?.password?.password ?: ""
|
||||
if (password.length == 6) {
|
||||
dialogManager.showProgressDialog(context)
|
||||
RedPackageModel.sendRedPackage(binding.editGoldNum.text.toString(),
|
||||
binding.editRedText.text.toString().ifEmpty { "恭喜發財,大吉大利!" },
|
||||
binding.editRedNum.text.toString(),
|
||||
AvRoomDataManager.get().mCurrentRoomInfo?.uid.toString(), getRedType(), DESUtils.DESAndBase64(password))
|
||||
.doOnError {
|
||||
dialogManager.dismissDialog()
|
||||
SingleToastUtil.showToast(it.message)
|
||||
passWordFragment?.password?.clearPassword()
|
||||
}
|
||||
.subscribe { _ ->
|
||||
PayModel.get().getWalletInfo(AuthModel.get().currentUid).subscribe()
|
||||
dialogManager.dismissDialog()
|
||||
SingleToastUtil.showToast("發送成功")
|
||||
passWordFragment?.dismissAllowingStateLoss()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onWalletInfoUpdate(event: UpdateWalletInfoEvent?) {
|
||||
binding.tvBalanceNum.text = PayModel.get().currentWalletInfo?.diamondNum?.toString()
|
||||
?: "0"
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
override fun onInputFinish(psw: String) {
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun afterTextChanged(s: Editable) {
|
||||
binding.tvRedTextLimit.text = "${s.length}/20"
|
||||
}
|
||||
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun handleRedPackageDialog(event: RedPackageEvent?) {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,253 @@
|
||||
package com.yizhuan.erban.avroom.redpackage
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.util.TypedValue
|
||||
import android.view.LayoutInflater
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.chuhai.utils.ServiceTime
|
||||
import com.chuhai.utils.ktx.singleClick
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.redpackage.open.RedPackageOpenDialog
|
||||
import com.yizhuan.erban.common.widget.dialog.DialogManager
|
||||
import com.yizhuan.erban.databinding.RedPackageWidgetBinding
|
||||
import com.yizhuan.xchat_android_core.redpackage.RedPackageModel
|
||||
import com.yizhuan.xchat_android_core.redpackage.RedPackageNotifyInfo
|
||||
import com.yizhuan.xchat_android_core.support.room.FrameLayoutRoomWidget
|
||||
import com.yizhuan.xchat_android_core.support.room.RoomContext
|
||||
import com.yizhuan.xchat_android_core.support.room.RoomView
|
||||
import com.yizhuan.xchat_android_core.support.room.RoomWidget
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.disposables.Disposable
|
||||
import okhttp3.internal.toLongOrDefault
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.TimeZone
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/10/24 16:37
|
||||
* Desc:房间内的红包入口
|
||||
**/
|
||||
class RedPackageWidget : FrameLayoutRoomWidget, RoomWidget {
|
||||
private var countDownDisposable: Disposable? = null
|
||||
private var data: RedPackageNotifyInfo? = null
|
||||
private val redPackageHandler: RedPackageHandler?
|
||||
get() = RoomContext.get()
|
||||
?.findAbility<RedPackageHandler>(RedPackageHandler::class.java.simpleName)
|
||||
|
||||
// 临时这样实现,后续优化进度弹窗
|
||||
private var dialogManager: DialogManager? = null
|
||||
|
||||
// 倒计时格式(分:秒)
|
||||
private val mmssFormat by lazy(LazyThreadSafetyMode.NONE) {
|
||||
SimpleDateFormat("mm:ss").apply {
|
||||
timeZone = TimeZone.getTimeZone("GMT+00:00")
|
||||
}
|
||||
}
|
||||
|
||||
private val binding: RedPackageWidgetBinding =
|
||||
DataBindingUtil.inflate(
|
||||
LayoutInflater.from(
|
||||
context
|
||||
), R.layout.red_package_widget, this, true
|
||||
)
|
||||
|
||||
private var compositeDisposable: CompositeDisposable? = 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 {
|
||||
// 默认不可见
|
||||
this.isVisible = false
|
||||
this.setBackgroundResource(R.drawable.red_package_widget_bg)
|
||||
singleClick {
|
||||
data?.let {
|
||||
tryShowRedPackage(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始倒计时
|
||||
* @param time 开抢时间
|
||||
*/
|
||||
private fun startCountDown(time: Long) {
|
||||
val count = time - ServiceTime.time
|
||||
if (count <= 0) {
|
||||
switchUI(false)
|
||||
return
|
||||
}
|
||||
countDownDisposable =
|
||||
Observable.intervalRange(0, count / 1000, 0, 1000L, TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doOnNext {
|
||||
val gap = time - ServiceTime.time
|
||||
if (gap >= 0) {
|
||||
binding.tvText.text = mmssFormat.format(gap)
|
||||
}
|
||||
}
|
||||
.doOnComplete {
|
||||
switchUI(false)
|
||||
}
|
||||
.subscribe()
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换UI
|
||||
* @param isCountDown 是否倒计时模式?否则为可抢红包模式
|
||||
*/
|
||||
private fun switchUI(isCountDown: Boolean) {
|
||||
if (isCountDown) {
|
||||
binding.tvText.setBackgroundResource(R.drawable.shape_99292929_8)
|
||||
binding.tvText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10f)
|
||||
} else {
|
||||
binding.tvText.setBackgroundResource(R.drawable.red_package_widget_bg_text)
|
||||
binding.tvText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 9f)
|
||||
binding.tvText.setText(R.string.red_package_widget_get)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart(roomView: RoomView) {
|
||||
super.onStart(roomView)
|
||||
roomView.getActivity()?.let {
|
||||
this.dialogManager = DialogManager(it)
|
||||
this.dialogManager?.setCanceledOnClickOutside(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInitialize(roomView: RoomView, roomContext: RoomContext) {
|
||||
super.onInitialize(roomView, roomContext)
|
||||
val lifecycleOwner = roomView.getLifecycleOwner()
|
||||
redPackageHandler?.iconLiveData?.observe(lifecycleOwner) {
|
||||
loadData(it)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
*/
|
||||
private fun loadData(data: RedPackageNotifyInfo?) {
|
||||
this.data = data
|
||||
stopCountDown()
|
||||
if (data != null) {
|
||||
val num = data.redEnvelopeNum
|
||||
if (num > 0) {
|
||||
if (num > 99) {
|
||||
binding.tvNum.text = "99+"
|
||||
} else {
|
||||
binding.tvNum.text = num.toString()
|
||||
}
|
||||
binding.tvNum.isVisible = true
|
||||
} else {
|
||||
binding.tvNum.isVisible = false
|
||||
}
|
||||
if (data.validityType == 1) {
|
||||
// 限时生效
|
||||
switchUI(true)
|
||||
startCountDown(data.beginTime)
|
||||
} else {
|
||||
// 立即生效
|
||||
switchUI(false)
|
||||
}
|
||||
this.isVisible = true
|
||||
} else {
|
||||
this.isVisible = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 尝试展示红包
|
||||
*/
|
||||
private fun tryShowRedPackage(data: RedPackageNotifyInfo) {
|
||||
dialogManager?.context?.let {
|
||||
dialogManager?.showProgressDialog(it, false)
|
||||
}
|
||||
val disposable = RedPackageModel.getRedPackage(data.redEnvelopeId.toLongOrDefault(0))
|
||||
.subscribe({ item ->
|
||||
dialogManager?.dismissDialog()
|
||||
when (item.state) {
|
||||
3 -> {
|
||||
redPackageHandler?.requestRefreshIcon()
|
||||
SingleToastUtil.showToast(R.string.red_package_result_empty_tips)
|
||||
}
|
||||
|
||||
4 -> {
|
||||
val newData = item.result?.redEnvelopeVO
|
||||
if (newData != null && newData.pickNum == newData.totalNum) {
|
||||
redPackageHandler?.requestRefreshIcon()
|
||||
SingleToastUtil.showToast(R.string.red_package_result_empty_tips)
|
||||
} else {
|
||||
roomView?.getActivity().let {
|
||||
RedPackageOpenDialog.newInstance(item).show(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2, 6 -> {
|
||||
redPackageHandler?.requestRefreshIcon()
|
||||
SingleToastUtil.showToast(R.string.red_package_disabled_tips)
|
||||
}
|
||||
|
||||
else -> {
|
||||
roomView?.getActivity().let {
|
||||
RedPackageOpenDialog.newInstance(item).show(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
SingleToastUtil.showToast(it.message)
|
||||
dialogManager?.dismissDialog()
|
||||
})
|
||||
getCompositeDisposable().add(disposable)
|
||||
}
|
||||
|
||||
private fun getCompositeDisposable(): CompositeDisposable {
|
||||
var disposable = compositeDisposable
|
||||
if (disposable == null) {
|
||||
disposable = CompositeDisposable()
|
||||
compositeDisposable = disposable
|
||||
}
|
||||
return disposable
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
this.dialogManager?.dismissDialog()
|
||||
this.dialogManager = null
|
||||
this.roomView = null
|
||||
}
|
||||
|
||||
override fun onUnbindContext() {
|
||||
super.onUnbindContext()
|
||||
compositeDisposable?.dispose()
|
||||
compositeDisposable = null
|
||||
loadData(null)
|
||||
}
|
||||
|
||||
override fun onBindContext(roomContext: RoomContext) {
|
||||
super.onBindContext(roomContext)
|
||||
}
|
||||
|
||||
private fun stopCountDown() {
|
||||
if (countDownDisposable?.isDisposed == false) {
|
||||
countDownDisposable?.dispose()
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,557 @@
|
||||
package com.yizhuan.erban.avroom.redpackage.open
|
||||
|
||||
|
||||
import android.animation.Animator
|
||||
import android.animation.AnimatorListenerAdapter
|
||||
import android.animation.ObjectAnimator
|
||||
import android.animation.ValueAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.view.animation.LinearInterpolator
|
||||
import androidx.core.view.isVisible
|
||||
import com.chuhai.utils.ServiceTime
|
||||
import com.chuhai.utils.ktx.getColorById
|
||||
import com.chuhai.utils.ktx.singleClick
|
||||
import com.chuhai.utils.ktx.toStringRes
|
||||
import com.chuhai.utils.log.ILog
|
||||
import com.chuhai.utils.spannable.spannableBuilder
|
||||
import com.trello.rxlifecycle3.android.FragmentEvent
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageHandler
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.databinding.RedPackageOpenDialogBinding
|
||||
import com.yizhuan.erban.ui.utils.loadAvatar
|
||||
import com.yizhuan.erban.ui.widget.UserInfoDialog
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.home.event.FollowRoomEvent
|
||||
import com.yizhuan.xchat_android_core.home.event.OpenRoomMessageInputEvent
|
||||
import com.yizhuan.xchat_android_core.home.event.ShareRoomEvent
|
||||
import com.yizhuan.xchat_android_core.home.model.CollectionRoomModel
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.pay.PayModel
|
||||
import com.yizhuan.xchat_android_core.redpackage.*
|
||||
import com.yizhuan.xchat_android_core.support.config.Constants
|
||||
import com.yizhuan.xchat_android_core.support.room.RoomContext
|
||||
import com.yizhuan.xchat_android_library.annatation.ActLayoutRes
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.TimeZone
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/10/24 10:14
|
||||
* Desc:领取红包
|
||||
**/
|
||||
@ActLayoutRes(R.layout.red_package_open_dialog)
|
||||
class RedPackageOpenDialog : BaseDialog<RedPackageOpenDialogBinding>(), ILog {
|
||||
|
||||
private var btnAnimator: ObjectAnimator? = null
|
||||
|
||||
private var countDownDisposable: Disposable? = null
|
||||
|
||||
// 倒计时格式(分:秒)
|
||||
private val mmssFormat by lazy(LazyThreadSafetyMode.NONE) {
|
||||
SimpleDateFormat("mm:ss").apply {
|
||||
timeZone = TimeZone.getTimeZone("GMT+00:00")
|
||||
}
|
||||
}
|
||||
|
||||
private val data by lazy(LazyThreadSafetyMode.NONE) {
|
||||
arguments?.getSerializable(Constants.KEY_INTENT) as? RedPackageData
|
||||
}
|
||||
|
||||
// 打开红包的结果
|
||||
private var openResultRunnable: (() -> Unit)? = null
|
||||
|
||||
// 按钮动画是否有效(至少转过了一周期)
|
||||
private var isValidOfBtnAnimator: Boolean = false
|
||||
|
||||
// 按钮执行函数
|
||||
private var btnRunnable: (() -> Unit)? = null
|
||||
|
||||
// 打开红包接口请求中
|
||||
private var opening = false
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* 此入口来源仅限:【全服红包信令】、【厅内无门槛-立即生效红包信令】
|
||||
*/
|
||||
fun newInstance(data: RedPackageNotifyInfo): RedPackageOpenDialog {
|
||||
/**
|
||||
* 收到这两种信令直接展示即可,无需再次请求接口查询状态,
|
||||
* 但由于信令和接口查询的数据格式不一致,所以这里做下转换,达到逻辑共用
|
||||
*/
|
||||
val item = RedPackageData(
|
||||
amount = null,
|
||||
avatar = data.sendUserAvatar,
|
||||
beginTime = data.beginTime,
|
||||
commissionAmount = null,
|
||||
createTime = null,
|
||||
duration = null,
|
||||
endTime = null,
|
||||
finish = true,
|
||||
id = data.redEnvelopeId.toLongOrNull(),
|
||||
kind = data.kind,
|
||||
message = data.redEnvelopeMessage,
|
||||
nick = data.sendUserNick,
|
||||
num = null,
|
||||
originalAmount = null,
|
||||
position = null,
|
||||
roomTitle = null,
|
||||
roomUid = data.roomUid,
|
||||
//红包状态 1 开抢中 2 过时 3 抢光了 4 抢到了 5 将要开始 6 超时已退还
|
||||
state = null,
|
||||
type = null,
|
||||
updateTime = null,
|
||||
userId = null,
|
||||
validityType = data.validityType,
|
||||
result = null
|
||||
)
|
||||
return newInstance(item)
|
||||
}
|
||||
|
||||
fun newInstance(data: RedPackageData): RedPackageOpenDialog {
|
||||
return RedPackageOpenDialog().apply {
|
||||
arguments = Bundle().apply {
|
||||
putSerializable(Constants.KEY_INTENT, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
super.onStart()
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
val data = this.data
|
||||
if (data == null) {
|
||||
dismissAllowingStateLoss()
|
||||
return
|
||||
}
|
||||
dialog?.setCanceledOnTouchOutside(false)
|
||||
|
||||
binding.ivClose.singleClick {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
binding.layoutBtn.singleClick {
|
||||
btnRunnable?.invoke()
|
||||
}
|
||||
loadData(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载红包数据
|
||||
*/
|
||||
private fun loadData(data: RedPackageData) {
|
||||
//红包状态 1 开抢中 2 过时 3 抢光了 4 抢到了 5 将要开始 6 超时已退还
|
||||
if (data.state == 4) {
|
||||
loadResult(data.result)
|
||||
} else {
|
||||
// else简单理解为可领取状态,正常情况下在RedPackageWidget点击时有异常状态过滤
|
||||
loadOpen(data)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载可领取数据
|
||||
*/
|
||||
private fun loadOpen(data: RedPackageData) {
|
||||
switchResultViewVisible(false)
|
||||
switchOpenViewVisible(true)
|
||||
binding.ivSendAvatar.loadAvatar(data.avatar)
|
||||
binding.tvSendName.text = data.nick
|
||||
loadTips(data)
|
||||
loadBtnState(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载红包提示
|
||||
*/
|
||||
private fun loadTips(data: RedPackageData) {
|
||||
binding.tvOpenTips.isVisible = false
|
||||
when (data.kind) {
|
||||
0 -> {
|
||||
loadTips(data.message)
|
||||
}
|
||||
|
||||
1 -> {
|
||||
binding.tvOpenTips.setText(R.string.red_package_quick_tips)
|
||||
binding.tvOpenTips.isVisible = true
|
||||
}
|
||||
|
||||
2 -> {
|
||||
if (data.finish == true) {
|
||||
binding.tvOpenTips.setText(R.string.red_package_complete_tips)
|
||||
} else {
|
||||
binding.tvOpenTips.spannableBuilder()
|
||||
.appendText(
|
||||
text = R.string.red_package_open_tips_follow.toStringRes(),
|
||||
textColor = getColorById(R.color.color_FFF87A)
|
||||
)
|
||||
.appendText(text = R.string.red_package_open_tips_msg_end.toStringRes())
|
||||
.apply()
|
||||
}
|
||||
binding.tvOpenTips.isVisible = true
|
||||
}
|
||||
|
||||
3 -> {
|
||||
if (data.finish == true) {
|
||||
binding.tvOpenTips.setText(R.string.red_package_complete_tips)
|
||||
} else {
|
||||
binding.tvOpenTips.spannableBuilder()
|
||||
.appendText(
|
||||
text = R.string.red_package_open_tips_share.toStringRes(),
|
||||
textColor = getColorById(R.color.color_FFF87A)
|
||||
)
|
||||
.appendText(text = R.string.red_package_open_tips_msg_end.toStringRes())
|
||||
.apply()
|
||||
}
|
||||
binding.tvOpenTips.isVisible = true
|
||||
}
|
||||
|
||||
4 -> {
|
||||
if (data.finish == true) {
|
||||
binding.tvOpenTips.setText(R.string.red_package_complete_tips)
|
||||
} else {
|
||||
binding.tvOpenTips.spannableBuilder()
|
||||
.appendText(text = R.string.red_package_open_tips_msg1.toStringRes())
|
||||
.appendText(
|
||||
text = data.message ?: "",
|
||||
textColor = getColorById(R.color.color_FFF87A)
|
||||
)
|
||||
.appendText(text = R.string.red_package_open_tips_msg_end.toStringRes())
|
||||
.apply()
|
||||
}
|
||||
binding.tvOpenTips.isVisible = true
|
||||
}
|
||||
|
||||
else -> {
|
||||
loadTips(data.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载按钮状态
|
||||
*/
|
||||
private fun loadBtnState(data: RedPackageData) {
|
||||
binding.groupBtnTime.isVisible = false
|
||||
binding.ivBtnGet.isVisible = false
|
||||
binding.tvBtnMsg.isVisible = false
|
||||
btnRunnable = null
|
||||
|
||||
val gap = (data.beginTime ?: 0) - ServiceTime.time
|
||||
// 开始了?
|
||||
val started = gap < 0
|
||||
if (data.kind == 0) {
|
||||
// 旧厅内红包or全服红包
|
||||
switchToOpenState()
|
||||
return
|
||||
}
|
||||
if (data.kind == 1 || data.finish == true) {
|
||||
if (started) {
|
||||
switchToOpenState()
|
||||
} else {
|
||||
startCountDown(data.beginTime ?: 0)
|
||||
}
|
||||
} else {
|
||||
binding.tvBtnMsg.isVisible = true
|
||||
if (started) {
|
||||
binding.tvBtnMsg.setText(R.string.red_package_open_btn_no)
|
||||
btnRunnable = {
|
||||
SingleToastUtil.showToast(R.string.red_package_open_no_tips)
|
||||
}
|
||||
} else {
|
||||
when (data.kind) {
|
||||
2 -> {
|
||||
binding.tvBtnMsg.setText(R.string.red_package_open_btn_follow)
|
||||
btnRunnable = {
|
||||
dismissAllowingStateLoss()
|
||||
showUserDialog(data.userId)
|
||||
}
|
||||
}
|
||||
|
||||
3 -> {
|
||||
binding.tvBtnMsg.setText(R.string.red_package_open_btn_share)
|
||||
btnRunnable = {
|
||||
dismissAllowingStateLoss()
|
||||
EventBus.getDefault().post(ShareRoomEvent())
|
||||
}
|
||||
}
|
||||
|
||||
4 -> {
|
||||
binding.tvBtnMsg.setText(R.string.red_package_open_btn_msg)
|
||||
btnRunnable = {
|
||||
dismissAllowingStateLoss()
|
||||
EventBus.getDefault().post(OpenRoomMessageInputEvent(data.message))
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
binding.tvBtnMsg.text = ""
|
||||
}
|
||||
}
|
||||
startTimerForUncompletedState(gap)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启定时器:未完成状态更新(倒计时结束时,更新对应View状态)
|
||||
*/
|
||||
private fun startTimerForUncompletedState(time: Long) {
|
||||
val d = Observable.timer(time, TimeUnit.MILLISECONDS)
|
||||
.compose(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
binding.tvBtnMsg.setText(R.string.red_package_open_btn_no)
|
||||
btnRunnable = {
|
||||
SingleToastUtil.showToast(R.string.red_package_open_no_tips)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始倒计时
|
||||
* @param time 开抢时间
|
||||
*/
|
||||
private fun startCountDown(time: Long) {
|
||||
stopCountDown()
|
||||
val count = time - ServiceTime.time
|
||||
if (count <= 0) {
|
||||
switchToOpenState()
|
||||
return
|
||||
}
|
||||
binding.groupBtnTime.isVisible = true
|
||||
countDownDisposable =
|
||||
Observable.intervalRange(0, count / 1000, 0, 1000L, TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doOnNext {
|
||||
val gap = time - ServiceTime.time
|
||||
if (gap >= 0) {
|
||||
binding.tvBtnTime.text = mmssFormat.format(gap)
|
||||
}
|
||||
}
|
||||
.doOnComplete {
|
||||
switchToOpenState()
|
||||
}
|
||||
.subscribe()
|
||||
}
|
||||
|
||||
|
||||
private fun stopCountDown() {
|
||||
if (countDownDisposable?.isDisposed == false) {
|
||||
countDownDisposable?.dispose()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 切换为可抢状态
|
||||
*/
|
||||
private fun switchToOpenState() {
|
||||
binding.tvBtnMsg.isVisible = false
|
||||
binding.groupBtnTime.isVisible = false
|
||||
binding.ivBtnGet.isVisible = true
|
||||
btnRunnable = {
|
||||
if (!opening) {
|
||||
this.data?.let {
|
||||
openRedPackage(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadTips(msg: String?) {
|
||||
if (msg.isNullOrEmpty()) {
|
||||
binding.tvOpenTips.isVisible = false
|
||||
} else {
|
||||
binding.tvOpenTips.text = msg
|
||||
binding.tvOpenTips.isVisible = true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开红包
|
||||
*/
|
||||
private fun openRedPackage(data: RedPackageData) {
|
||||
opening = true
|
||||
openResultRunnable = null
|
||||
startRedPacketAnim(binding.layoutBtn)
|
||||
val d = RedPackageModel.openRedPackage(data.id ?: 0)
|
||||
.compose(bindUntilEvent(FragmentEvent.DESTROY_VIEW)).subscribe({
|
||||
if (isValidOfBtnAnimator) {
|
||||
btnAnimator?.cancel()
|
||||
onOpenSuccess(it)
|
||||
} else {
|
||||
openResultRunnable = {
|
||||
onOpenSuccess(it)
|
||||
}
|
||||
}
|
||||
}, {
|
||||
if (isValidOfBtnAnimator) {
|
||||
btnAnimator?.cancel()
|
||||
onOpenFail(it)
|
||||
} else {
|
||||
openResultRunnable = {
|
||||
onOpenFail(it)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载结果
|
||||
*/
|
||||
private fun loadResult(data: RedPackageInfo?) {
|
||||
binding.layoutContent.setBackgroundResource(R.drawable.red_package_result_bg)
|
||||
switchOpenViewVisible(false)
|
||||
switchResultViewVisible(true)
|
||||
binding.groupResultMoney.isVisible = false
|
||||
binding.tvResultEmptyTips.isVisible = false
|
||||
binding.ivResultSendAvatar.loadAvatar(data?.redEnvelopeVO?.userVO?.avatar)
|
||||
binding.tvResultSendName.text = data?.redEnvelopeVO?.userVO?.nick ?: ""
|
||||
val name = data?.redEnvelopeVO?.userVO?.nick ?: ""
|
||||
if (name.length > 8) {
|
||||
binding.tvResultSendName.text = name?.take(8) + "..的紅包"
|
||||
} else {
|
||||
binding.tvResultSendName.text = name + "的紅包"
|
||||
}
|
||||
binding.tvMessage.text = data?.redEnvelopeVO?.message
|
||||
binding.tvCount.text = R.string.red_package_result_count_format.toStringRes()
|
||||
.format(data?.redEnvelopeVO?.pickNum ?: 0, data?.redEnvelopeVO?.totalNum ?: 0)
|
||||
|
||||
val adapter = RedPackageResultAdapter()
|
||||
binding.recyclerView.adapter = adapter
|
||||
adapter.setNewData(data?.redEnvelopeItemVOs)
|
||||
|
||||
when (data?.redEnvelopeState) {
|
||||
RedEnvelopeState.SUCCESS -> {
|
||||
binding.tvMoney.text = data.currentUserAmount.toString().substringBefore(".")
|
||||
binding.groupResultMoney.isVisible = true
|
||||
}
|
||||
|
||||
RedEnvelopeState.TIME_OUT, RedEnvelopeState.REMAIN_ZERO, RedEnvelopeState.TIME_OUT_BACK -> {
|
||||
binding.tvResultEmptyTips.isVisible = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开红包响应成功
|
||||
* @param data 结果
|
||||
*/
|
||||
private fun onOpenSuccess(data: RedPackageInfo) {
|
||||
loadResult(data)
|
||||
RoomContext.get()
|
||||
?.findAbility<RedPackageHandler>(RedPackageHandler::class.simpleName)
|
||||
?.requestRefreshIcon()
|
||||
when (data.redEnvelopeState) {
|
||||
RedEnvelopeState.SUCCESS -> {
|
||||
// 下面这段是延续老代码保留的
|
||||
if (!AvRoomDataManager.get().isRoomFans) {
|
||||
AvRoomDataManager.get().roomUid.let {
|
||||
CollectionRoomModel.get().followRoom("1", it)
|
||||
.subscribe { _: String? ->
|
||||
AvRoomDataManager.get().isRoomFans = true
|
||||
EventBus.getDefault().post(FollowRoomEvent())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
PayModel.get().getWalletInfo(AuthModel.get().currentUid).subscribe()
|
||||
opening = false
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开红包响应失败
|
||||
*/
|
||||
private fun onOpenFail(throwable: Throwable) {
|
||||
switchToOpenState()
|
||||
btnAnimator?.cancel()
|
||||
SingleToastUtil.showToast(throwable.message)
|
||||
opening = false
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun startRedPacketAnim(v: View) {
|
||||
if (btnAnimator?.isRunning == true) {
|
||||
btnAnimator?.cancel()
|
||||
}
|
||||
isValidOfBtnAnimator = false
|
||||
btnAnimator = ObjectAnimator.ofFloat(v, "rotationY", 0f, 360f)
|
||||
btnAnimator?.let {
|
||||
it.duration = 600
|
||||
it.repeatCount = ValueAnimator.INFINITE
|
||||
it.repeatMode = ValueAnimator.RESTART
|
||||
it.interpolator = LinearInterpolator()
|
||||
it.addListener(object : AnimatorListenerAdapter() {
|
||||
override fun onAnimationRepeat(animation: Animator) {
|
||||
super.onAnimationRepeat(animation)
|
||||
isValidOfBtnAnimator = true
|
||||
if (openResultRunnable != null) {
|
||||
animation.cancel()
|
||||
openResultRunnable?.invoke()
|
||||
}
|
||||
}
|
||||
})
|
||||
it.start()
|
||||
}
|
||||
}
|
||||
|
||||
private fun switchResultViewVisible(isVisible: Boolean) {
|
||||
binding.groupResult.isVisible = isVisible
|
||||
binding.groupResultMoney.isVisible = isVisible
|
||||
binding.tvResultEmptyTips.isVisible = isVisible
|
||||
}
|
||||
|
||||
private fun switchOpenViewVisible(isVisible: Boolean) {
|
||||
binding.groupOpen.isVisible = isVisible
|
||||
binding.tvOpenTips.isVisible = isVisible
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
RoomContext.get()
|
||||
?.findAbility<RedPackageHandler>(RedPackageHandler::class.simpleName)
|
||||
?.startOperation()
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
btnAnimator?.cancel()
|
||||
btnAnimator = null
|
||||
stopCountDown()
|
||||
RoomContext.get()
|
||||
?.findAbility<RedPackageHandler>(RedPackageHandler::class.simpleName)
|
||||
?.stopOperation()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
private fun showUserDialog(uid: Long?) {
|
||||
if (uid == null) {
|
||||
return
|
||||
}
|
||||
activity?.let {
|
||||
UserInfoDialog.showNewUserInfoDialog(
|
||||
activity,
|
||||
uid
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
package com.yizhuan.erban.avroom.redpackage.open
|
||||
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import androidx.core.view.isVisible
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.ui.utils.loadAvatar
|
||||
import com.yizhuan.erban.utils.UserUtils
|
||||
import com.yizhuan.xchat_android_core.redpackage.RedEnvelopeItemVO
|
||||
import com.yizhuan.xchat_android_core.utils.subAndReplaceDot
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/10/27 20:24
|
||||
* Desc:红包领取结果
|
||||
**/
|
||||
class RedPackageResultAdapter :
|
||||
BaseQuickAdapter<RedEnvelopeItemVO, BaseViewHolder>(R.layout.red_package_open_item_result) {
|
||||
private val dateFormat = SimpleDateFormat(
|
||||
ResUtil.getString(R.string.avroom_redpackage_redpackageopenadapter_01),
|
||||
Locale.CHINA
|
||||
)
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: RedEnvelopeItemVO) {
|
||||
helper.getView<ImageView>(R.id.iv_avatar).loadAvatar(item.userVO.avatar)
|
||||
val isSelf = item.userVO.uid == UserUtils.getUserUid()
|
||||
helper.setText(
|
||||
R.id.tv_name,
|
||||
if (isSelf) ResUtil.getString(R.string.avroom_redpackage_redpackageopenadapter_02) else item.userVO.nick.subAndReplaceDot(
|
||||
6
|
||||
)
|
||||
)
|
||||
helper.setText(R.id.tv_money, item.amount.substringBefore("."))
|
||||
try {
|
||||
helper.setText(R.id.tv_time, dateFormat.format(item.createTime))
|
||||
} catch (e: Exception) {
|
||||
helper.setText(R.id.tv_time, "")
|
||||
}
|
||||
helper.getView<View>(R.id.v_line).isVisible = helper.bindingAdapterPosition != itemCount - 1
|
||||
}
|
||||
}
|
@@ -0,0 +1,284 @@
|
||||
package com.yizhuan.erban.avroom.redpackage.send
|
||||
|
||||
import android.graphics.Color
|
||||
import androidx.core.view.isVisible
|
||||
import com.chuhai.utils.ktx.addDisableFilter
|
||||
import com.chuhai.utils.ktx.getColorById
|
||||
import com.chuhai.utils.ktx.singleClick
|
||||
import com.chuhai.utils.ktx.toStringRes
|
||||
import com.chuhai.utils.log.ILog
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseBindingFragment
|
||||
import com.yizhuan.erban.databinding.RedPackagePrivateFragmentBinding
|
||||
import com.yizhuan.erban.pay.password.GiveGoldPassWordFragment
|
||||
import com.yizhuan.erban.pay.widget.GridPasswordNoFocusView
|
||||
import com.yizhuan.erban.ui.setting.ModifyPwdActivity
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil
|
||||
import com.yizhuan.erban.ui.widget.recyclerview.decoration.ColorDecoration
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.initial.InitialModel
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.pay.PayModel
|
||||
import com.yizhuan.xchat_android_core.redpackage.RedPackageModel
|
||||
import com.yizhuan.xchat_android_core.user.UserModel
|
||||
import com.yizhuan.xchat_android_core.utils.toIntOrDef
|
||||
import com.yizhuan.xchat_android_library.annatation.ActLayoutRes
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
|
||||
import com.yizhuan.xchat_android_library.utils.codec.DESUtils
|
||||
import okhttp3.internal.toLongOrDefault
|
||||
import java.math.RoundingMode
|
||||
import java.text.NumberFormat
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/10/23 12:14
|
||||
* Desc: 厅内红包
|
||||
**/
|
||||
@ActLayoutRes(R.layout.red_package_private_fragment)
|
||||
class PrivateRedPackageEditorFragment : BaseBindingFragment<RedPackagePrivateFragmentBinding>(),
|
||||
ILog {
|
||||
|
||||
private var passWordFragment: GiveGoldPassWordFragment? = null
|
||||
|
||||
private var typeAdapter: RedPackageTypeItemAdapter? = null
|
||||
|
||||
// 生效时间类型 0 立即生效 1 限时生效
|
||||
private var timeType = 0
|
||||
override fun initiate() {
|
||||
mBinding.etText.addDisableFilter(" ", "\n")
|
||||
initTypeView()
|
||||
updateTimeView(true)
|
||||
initTips()
|
||||
}
|
||||
|
||||
override fun onSetListener() {
|
||||
super.onSetListener()
|
||||
mBinding.tvNow.singleClick {
|
||||
updateTimeView(true)
|
||||
}
|
||||
mBinding.tvDelay.singleClick {
|
||||
updateTimeView(false)
|
||||
}
|
||||
mBinding.tvSend.singleClick {
|
||||
checkSend()
|
||||
}
|
||||
}
|
||||
|
||||
private fun initTips() {
|
||||
val time = InitialModel.get().cacheInitInfo?.redEnvelopeConfig?.endSecond
|
||||
if (time != null) {
|
||||
try {
|
||||
val hour = NumberFormat.getInstance().apply {
|
||||
maximumFractionDigits = 2
|
||||
roundingMode = RoundingMode.FLOOR
|
||||
}.format(time / 3600.0)
|
||||
mBinding.tvTips.text = R.string.red_package_tips_format.toStringRes().format(hour)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initTypeView() {
|
||||
mBinding.recyclerView.addItemDecoration(
|
||||
ColorDecoration(
|
||||
Color.TRANSPARENT, UIUtil.dip2px(context, 6.0), 0, false
|
||||
)
|
||||
)
|
||||
val list = ArrayList<RedPackageTypeItemAdapter.ItemData>()
|
||||
list.add(
|
||||
RedPackageTypeItemAdapter.ItemData(
|
||||
1,
|
||||
R.string.red_package_type_unlimited_name,
|
||||
R.string.red_package_type_unlimited_tips
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RedPackageTypeItemAdapter.ItemData(
|
||||
2,
|
||||
R.string.red_package_type_follow_name,
|
||||
R.string.red_package_type_follow_tips
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RedPackageTypeItemAdapter.ItemData(
|
||||
3,
|
||||
R.string.red_package_type_share_name,
|
||||
R.string.red_package_type_share_tips
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
RedPackageTypeItemAdapter.ItemData(
|
||||
4,
|
||||
R.string.red_package_type_msg_name,
|
||||
R.string.red_package_type_msg_tips
|
||||
)
|
||||
)
|
||||
val adapter = RedPackageTypeItemAdapter(list)
|
||||
typeAdapter = adapter
|
||||
adapter.setOnItemClickListener { _, view, position ->
|
||||
adapter.select(position)
|
||||
updateTypeView(adapter.getSelect()?.type)
|
||||
}
|
||||
mBinding.recyclerView.adapter = adapter
|
||||
// 默认选择第一个
|
||||
adapter.select(0)
|
||||
updateTypeView(adapter.getSelect()?.type)
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新红包类型对应的视图
|
||||
*/
|
||||
private fun updateTypeView(type: Int?) {
|
||||
when (type) {
|
||||
1 -> {
|
||||
mBinding.tvNow.isVisible = true
|
||||
mBinding.tvDelay.isVisible = true
|
||||
mBinding.etText.isVisible = false
|
||||
}
|
||||
|
||||
4 -> {
|
||||
mBinding.tvNow.isVisible = false
|
||||
mBinding.tvDelay.isVisible = false
|
||||
mBinding.etText.isVisible = true
|
||||
}
|
||||
|
||||
else -> {
|
||||
mBinding.tvNow.isVisible = false
|
||||
mBinding.tvDelay.isVisible = false
|
||||
mBinding.etText.isVisible = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新时间选项
|
||||
*/
|
||||
private fun updateTimeView(nowOrDelay: Boolean) {
|
||||
if (nowOrDelay) {
|
||||
timeType = 0
|
||||
mBinding.tvNow.setBackgroundResource(R.drawable.red_package_bg_type_selected)
|
||||
mBinding.tvDelay.setBackgroundResource(R.drawable.shape_f8f8fa_8)
|
||||
mBinding.tvNow.setTextColor(mBinding.root.context.getColorById(R.color.color_FF285C))
|
||||
mBinding.tvDelay.setTextColor(mBinding.root.context.getColorById(R.color.color_767585))
|
||||
} else {
|
||||
timeType = 1
|
||||
mBinding.tvNow.setBackgroundResource(R.drawable.shape_f8f8fa_8)
|
||||
mBinding.tvDelay.setBackgroundResource(R.drawable.red_package_bg_type_selected)
|
||||
mBinding.tvNow.setTextColor(mBinding.root.context.getColorById(R.color.color_767585))
|
||||
mBinding.tvDelay.setTextColor(mBinding.root.context.getColorById(R.color.color_FF285C))
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkSend() {
|
||||
val initInfo = InitialModel.get().cacheInitInfo
|
||||
if (initInfo == null) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_redpackage_redpackagesenddialog_01))
|
||||
return
|
||||
}
|
||||
val typeItem = typeAdapter?.getSelect()
|
||||
if (typeItem?.type == 4) {
|
||||
if (mBinding.etText.text.toString().trim().isEmpty()) {
|
||||
toast(R.string.red_package_msg_empty_tips)
|
||||
return
|
||||
}
|
||||
}
|
||||
val minNum = initInfo.redEnvelopeConfig.roomRedEnvelopeMinNum
|
||||
val maxNum = initInfo.redEnvelopeConfig.roomRedEnvelopeMaxNum
|
||||
val minGold = initInfo.redEnvelopeConfig.roomRedEnvelopeMinAmount
|
||||
val maxGold = initInfo.redEnvelopeConfig.roomRedEnvelopeMaxAmount
|
||||
val rate =
|
||||
if (initInfo.redEnvelopeConfig.exchangeDiamondsRate == 0.0) 0.68 else initInfo.redEnvelopeConfig.exchangeDiamondsRate
|
||||
|
||||
val redNum = mBinding?.etNum?.text.toString().toIntOrDef()
|
||||
if (redNum < minNum || redNum > maxNum) {
|
||||
SingleToastUtil.showToast("紅包數量不能小於${minNum}或大於${maxNum}!")
|
||||
return
|
||||
}
|
||||
val goldNum = mBinding?.etMoney?.text.toString().toIntOrDef()
|
||||
if (goldNum % 10 != 0) {
|
||||
SingleToastUtil.showToast("鉆石數必須為10的倍數!")
|
||||
return
|
||||
}
|
||||
|
||||
if (goldNum < minGold || goldNum > maxGold) {
|
||||
SingleToastUtil.showToast("鉆石數量不能小於${minGold}或大於${maxGold}!")
|
||||
return
|
||||
}
|
||||
if (goldNum.toFloat() / redNum * rate < 0.1) {//單個手氣紅包價值不低於0.1水晶
|
||||
SingleToastUtil.showToast("單個紅包金額過低")
|
||||
return
|
||||
}
|
||||
UserModel.get().cacheLoginUserInfo?.let {
|
||||
if (!it.isBindPaymentPwd) {
|
||||
ModifyPwdActivity.start(context, ModifyPwdActivity.PAY_PWD)
|
||||
return
|
||||
}
|
||||
}
|
||||
GiveGoldPassWordFragment.newInstance(
|
||||
childFragmentManager,
|
||||
mBinding?.etMoney?.text.toString()
|
||||
).apply {
|
||||
setListener(object : GridPasswordNoFocusView.OnPasswordChangedListener {
|
||||
override fun onTextChanged(psw: String?) {
|
||||
val password = passWordFragment?.password?.password ?: ""
|
||||
if (password.length == 6) {
|
||||
send(password)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInputFinish(psw: String?) {
|
||||
}
|
||||
})
|
||||
passWordFragment = this
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 密码输入完成
|
||||
*/
|
||||
private fun send(password: String) {
|
||||
dialogManager.showProgressDialog(context)
|
||||
val kind = typeAdapter?.getSelect()?.type ?: 1
|
||||
val message = if (kind == 4) {
|
||||
mBinding.etText.text.trim().toString()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
val validityType = if (kind == 1) {
|
||||
timeType
|
||||
} else {
|
||||
// 非无门槛红包 默认限时
|
||||
1
|
||||
}
|
||||
RedPackageModel.sendRedPackage(
|
||||
goldNum = mBinding.etMoney.text.trim().toString().toLongOrDefault(0),
|
||||
message = message,
|
||||
num = mBinding.etNum.text.trim().toString().toLongOrDefault(0),
|
||||
roomUId = AvRoomDataManager.get().mCurrentRoomInfo?.uid.toString(),
|
||||
type = 1,
|
||||
kind = kind,
|
||||
validityType = validityType,
|
||||
password = DESUtils.DESAndBase64(password)
|
||||
)
|
||||
.compose(bindToLifecycle())
|
||||
.doOnError {
|
||||
dialogManager.dismissDialog()
|
||||
SingleToastUtil.showToast(it.message)
|
||||
passWordFragment?.password?.clearPassword()
|
||||
}
|
||||
.subscribe { _ ->
|
||||
PayModel.get().getWalletInfo(AuthModel.get().currentUid).subscribe()
|
||||
dialogManager.dismissDialog()
|
||||
SingleToastUtil.showToast("發送成功")
|
||||
passWordFragment?.dismissAllowingStateLoss()
|
||||
(parentFragment as? RedPackageSendDialog)?.dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
passWordFragment?.dismissAllowingStateLoss()
|
||||
passWordFragment = null
|
||||
}
|
||||
}
|
@@ -0,0 +1,157 @@
|
||||
package com.yizhuan.erban.avroom.redpackage.send
|
||||
|
||||
import com.chuhai.utils.ktx.addDisableFilter
|
||||
import com.chuhai.utils.ktx.setOnInputChangedListener
|
||||
import com.chuhai.utils.ktx.singleClick
|
||||
import com.chuhai.utils.ktx.toStringRes
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseBindingFragment
|
||||
import com.yizhuan.erban.databinding.RedPackagePublicFragmentBinding
|
||||
import com.yizhuan.erban.pay.password.GiveGoldPassWordFragment
|
||||
import com.yizhuan.erban.pay.widget.GridPasswordNoFocusView
|
||||
import com.yizhuan.erban.ui.setting.ModifyPwdActivity
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.initial.InitialModel
|
||||
import com.yizhuan.xchat_android_core.initial.bean.InitInfo
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.pay.PayModel
|
||||
import com.yizhuan.xchat_android_core.redpackage.RedPackageModel
|
||||
import com.yizhuan.xchat_android_core.user.UserModel
|
||||
import com.yizhuan.xchat_android_core.utils.toIntOrDef
|
||||
import com.yizhuan.xchat_android_library.annatation.ActLayoutRes
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
|
||||
import com.yizhuan.xchat_android_library.utils.codec.DESUtils
|
||||
import okhttp3.internal.toLongOrDefault
|
||||
import java.math.RoundingMode
|
||||
import java.text.NumberFormat
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/10/23 12:14
|
||||
* Desc:全服红包
|
||||
**/
|
||||
@ActLayoutRes(R.layout.red_package_public_fragment)
|
||||
class PublicRedPackageEditorFragment : BaseBindingFragment<RedPackagePublicFragmentBinding>() {
|
||||
|
||||
private var passWordFragment: GiveGoldPassWordFragment? = null
|
||||
|
||||
override fun initiate() {
|
||||
initTips()
|
||||
mBinding.etText.addDisableFilter("\n")
|
||||
mBinding.etText.setOnInputChangedListener {
|
||||
mBinding.tvTextLength.text =
|
||||
R.string.red_package_result_count_format.toStringRes().format(this, 10)
|
||||
true
|
||||
}
|
||||
|
||||
mBinding.tvSend.singleClick {
|
||||
checkSend()
|
||||
}
|
||||
}
|
||||
|
||||
private fun initTips() {
|
||||
val time = InitialModel.get().cacheInitInfo?.redEnvelopeConfig?.endSecond
|
||||
if (time != null) {
|
||||
try {
|
||||
val hour = NumberFormat.getInstance().apply {
|
||||
maximumFractionDigits = 2
|
||||
roundingMode = RoundingMode.FLOOR
|
||||
}.format(time / 3600.0)
|
||||
mBinding.tvTips.text = R.string.red_package_tips_format.toStringRes().format(hour)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkSend() {
|
||||
val initInfo = InitialModel.get().cacheInitInfo ?: InitInfo()
|
||||
val minNum = initInfo.redEnvelopeConfig.serverRedEnvelopeMinNum
|
||||
val maxNum = initInfo.redEnvelopeConfig.serverRedEnvelopeMaxNum
|
||||
val minGold = initInfo.redEnvelopeConfig.serverRedEnvelopeMinAmount
|
||||
val maxGold = initInfo.redEnvelopeConfig.serverRedEnvelopeMaxAmount
|
||||
val rate =
|
||||
if (initInfo.redEnvelopeConfig.exchangeDiamondsRate == 0.0) 0.68 else initInfo.redEnvelopeConfig.exchangeDiamondsRate
|
||||
|
||||
val redNum = mBinding?.etNum?.text.toString().toIntOrDef()
|
||||
if (redNum < minNum || redNum > maxNum) {
|
||||
SingleToastUtil.showToast("紅包數量不能小於${minNum}或大於${maxNum}!")
|
||||
return
|
||||
}
|
||||
val goldNum = mBinding?.etMoney?.text.toString().toIntOrDef()
|
||||
if (goldNum % 100 != 0) {
|
||||
SingleToastUtil.showToast("鉆石數必須為100的倍數!")
|
||||
return
|
||||
}
|
||||
if (goldNum < minGold || goldNum > maxGold) {
|
||||
SingleToastUtil.showToast("鉆石數量不能小於${minGold}或大於${maxGold}!")
|
||||
return
|
||||
}
|
||||
if (goldNum.toFloat() / redNum * rate < 0.1) {//單個手氣紅包價值不低於0.1水晶
|
||||
SingleToastUtil.showToast("單個紅包金額過低")
|
||||
return
|
||||
}
|
||||
UserModel.get().cacheLoginUserInfo?.let {
|
||||
if (!it.isBindPaymentPwd) {
|
||||
ModifyPwdActivity.start(context, ModifyPwdActivity.PAY_PWD)
|
||||
return
|
||||
}
|
||||
}
|
||||
GiveGoldPassWordFragment.newInstance(
|
||||
childFragmentManager,
|
||||
mBinding?.etMoney?.text.toString()
|
||||
).apply {
|
||||
setListener(object : GridPasswordNoFocusView.OnPasswordChangedListener {
|
||||
override fun onTextChanged(psw: String?) {
|
||||
val password = passWordFragment?.password?.password ?: ""
|
||||
if (password.length == 6) {
|
||||
send(password)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInputFinish(psw: String?) {
|
||||
}
|
||||
})
|
||||
passWordFragment = this
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 密码输入完成
|
||||
*/
|
||||
private fun send(password: String) {
|
||||
dialogManager.showProgressDialog(context)
|
||||
var message = mBinding.etText.text.trim().toString()
|
||||
if (message.isEmpty()) {
|
||||
message = R.string.red_package_msg_def.toStringRes()
|
||||
}
|
||||
RedPackageModel.sendRedPackage(
|
||||
goldNum = mBinding.etMoney.text.trim().toString().toLongOrDefault(0),
|
||||
message = message,
|
||||
num = mBinding.etNum.text.trim().toString().toLongOrDefault(0),
|
||||
roomUId = AvRoomDataManager.get().mCurrentRoomInfo?.uid.toString(),
|
||||
type = 2,
|
||||
kind = 0,
|
||||
validityType = 0,
|
||||
password = DESUtils.DESAndBase64(password)
|
||||
)
|
||||
.compose(bindToLifecycle())
|
||||
.doOnError {
|
||||
dialogManager.dismissDialog()
|
||||
SingleToastUtil.showToast(it.message)
|
||||
passWordFragment?.password?.clearPassword()
|
||||
}
|
||||
.subscribe { _ ->
|
||||
PayModel.get().getWalletInfo(AuthModel.get().currentUid).subscribe()
|
||||
dialogManager.dismissDialog()
|
||||
SingleToastUtil.showToast("發送成功")
|
||||
passWordFragment?.dismissAllowingStateLoss()
|
||||
(parentFragment as? RedPackageSendDialog)?.dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
passWordFragment?.dismissAllowingStateLoss()
|
||||
passWordFragment = null
|
||||
}
|
||||
}
|
@@ -0,0 +1,172 @@
|
||||
package com.yizhuan.erban.avroom.redpackage.send
|
||||
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.WindowManager
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.chuhai.utils.ktx.singleClick
|
||||
import com.chuhai.utils.ktx.toStringRes
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageEvent
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.common.ViewPagerAdapter
|
||||
import com.yizhuan.erban.databinding.RedPackageSendDialogBinding
|
||||
import com.yizhuan.erban.ui.pay.ChargeActivity
|
||||
import com.yizhuan.erban.ui.webview.CommonWebViewActivity
|
||||
import com.yizhuan.erban.ui.webview.DialogWebViewActivity
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.ViewPagerHelper
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
|
||||
import com.yizhuan.xchat_android_core.Constants
|
||||
import com.yizhuan.xchat_android_core.UriProvider
|
||||
import com.yizhuan.xchat_android_core.initial.InitialModel
|
||||
import com.yizhuan.xchat_android_core.pay.PayModel
|
||||
import com.yizhuan.xchat_android_core.pay.event.UpdateWalletInfoEvent
|
||||
import com.yizhuan.xchat_android_core.redpackage.*
|
||||
import com.yizhuan.xchat_android_library.annatation.ActLayoutRes
|
||||
import com.yizhuan.xchat_android_library.common.util.DeviceUtil
|
||||
import com.yizhuan.xchat_android_library.utils.AppMetaDataUtil
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/10/23 12:14
|
||||
* Desc:发红包
|
||||
**/
|
||||
@ActLayoutRes(R.layout.red_package_send_dialog)
|
||||
class RedPackageSendDialog : BaseDialog<RedPackageSendDialogBinding>() {
|
||||
|
||||
private val permissionType: Int
|
||||
get() = arguments?.getInt(com.yizhuan.xchat_android_core.support.config.Constants.KEY_INTENT)
|
||||
?: 0
|
||||
|
||||
/**
|
||||
* 是否有厅内红包权限
|
||||
*/
|
||||
private val haveRoomRedPackagePermission get() = (permissionType and 1) != 0
|
||||
|
||||
/**
|
||||
* 是否有全服红包权限
|
||||
*/
|
||||
private val haveAllServicePackagePermission get() = (permissionType and 2) != 0
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* 红包权限类型
|
||||
*/
|
||||
fun newInstance(permissionType: Int): RedPackageSendDialog {
|
||||
return RedPackageSendDialog().apply {
|
||||
this.arguments = Bundle().apply {
|
||||
putInt(
|
||||
com.yizhuan.xchat_android_core.support.config.Constants.KEY_INTENT,
|
||||
permissionType
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
gravity = Gravity.BOTTOM
|
||||
width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
super.onStart()
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun init() {
|
||||
EventBus.getDefault().register(this)
|
||||
if (!haveRoomRedPackagePermission && !haveAllServicePackagePermission) {
|
||||
SingleToastUtil.showToast(R.string.avroom_presenter_avroompresenter_04)
|
||||
dismissAllowingStateLoss()
|
||||
return
|
||||
}
|
||||
if (InitialModel.get().cacheInitInfo == null) {
|
||||
InitialModel.get().init(true)
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_redpackage_redpackagesenddialog_01))
|
||||
dismissAllowingStateLoss()
|
||||
return
|
||||
}
|
||||
initView()
|
||||
initEvent()
|
||||
PayModel.get().currentWalletInfo?.let {
|
||||
binding.tvBalance.text = it.diamondNum.toLong().toString()
|
||||
}
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
val tabTitles = ArrayList<String>()
|
||||
val fragments = ArrayList<Fragment>()
|
||||
if (haveRoomRedPackagePermission) {
|
||||
tabTitles.add(R.string.red_package_room.toStringRes())
|
||||
fragments.add(PrivateRedPackageEditorFragment())
|
||||
}
|
||||
if (haveAllServicePackagePermission) {
|
||||
tabTitles.add(R.string.red_package_public.toStringRes())
|
||||
fragments.add(PublicRedPackageEditorFragment())
|
||||
}
|
||||
val topMagicIndicatorAdapter = TabIndicatorAdapter(context, tabTitles)
|
||||
topMagicIndicatorAdapter.setOnItemSelectListener {
|
||||
binding.viewPager.currentItem = it
|
||||
}
|
||||
val commonNavigator = CommonNavigator(context)
|
||||
commonNavigator.isAdjustMode = true
|
||||
commonNavigator.adapter = topMagicIndicatorAdapter
|
||||
binding.tabLayout.navigator = commonNavigator
|
||||
binding.viewPager.adapter = ViewPagerAdapter(
|
||||
childFragmentManager,
|
||||
fragments.toList(),
|
||||
null
|
||||
)
|
||||
ViewPagerHelper.bind(binding.tabLayout, binding.viewPager)
|
||||
}
|
||||
|
||||
private fun initEvent() {
|
||||
binding.vTopBlank.singleClick {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
binding.ivHelp.singleClick {
|
||||
DialogWebViewActivity.start(
|
||||
context,
|
||||
UriProvider.getRedPacketRule()
|
||||
)
|
||||
}
|
||||
|
||||
binding.tvBalance.singleClick {
|
||||
if (AppMetaDataUtil.getChannelID() == Constants.GOOGLE) {
|
||||
ChargeActivity.start(context)
|
||||
} else {
|
||||
CommonWebViewActivity.start(
|
||||
context, UriProvider.getOfficialPay(
|
||||
4,
|
||||
DeviceUtil.getDeviceId(context)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onWalletInfoUpdate(event: UpdateWalletInfoEvent?) {
|
||||
if (!isViewLoaded) {
|
||||
return
|
||||
}
|
||||
binding.tvBalance.text = PayModel.get().currentWalletInfo?.diamondNum?.toString()
|
||||
?: "0"
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun handleRedPackageDialog(event: RedPackageEvent?) {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
@@ -0,0 +1,76 @@
|
||||
package com.yizhuan.erban.avroom.redpackage.send
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chuhai.utils.ktx.getColorById
|
||||
import com.yizhuan.erban.R
|
||||
import io.realm.internal.Keep
|
||||
|
||||
/**
|
||||
* Created by Max on 2023/10/23 18:02
|
||||
* Desc:
|
||||
**/
|
||||
class RedPackageTypeItemAdapter(list: List<ItemData>) :
|
||||
BaseQuickAdapter<RedPackageTypeItemAdapter.ItemData, BaseViewHolder>(
|
||||
R.layout.red_package_private_item_type,
|
||||
list
|
||||
) {
|
||||
|
||||
private var selectPosition = -1
|
||||
|
||||
@Keep
|
||||
data class ItemData(
|
||||
/**
|
||||
* 红包种类 0 旧版本 1 无门槛红包 2 关注红包 3 分享红包 4 弹幕红包
|
||||
*/
|
||||
val type: Int, val name: Int, val tips: Int
|
||||
)
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: ItemData) {
|
||||
helper.setText(R.id.tv_name, item.name)
|
||||
helper.setText(R.id.tv_tips, item.tips)
|
||||
convertState(helper, item)
|
||||
}
|
||||
|
||||
override fun convertPayloads(
|
||||
helper: BaseViewHolder,
|
||||
item: ItemData,
|
||||
payloads: MutableList<Any>
|
||||
) {
|
||||
super.convertPayloads(helper, item, payloads)
|
||||
convertState(helper, item)
|
||||
}
|
||||
|
||||
private fun convertState(helper: BaseViewHolder, item: ItemData) {
|
||||
if (helper.bindingAdapterPosition == selectPosition) {
|
||||
helper.setBackgroundRes(R.id.layout_root, R.drawable.red_package_bg_type_selected)
|
||||
helper.setTextColor(
|
||||
R.id.tv_name,
|
||||
helper.itemView.context.getColorById(R.color.color_FF285C)
|
||||
)
|
||||
helper.setTextColor(
|
||||
R.id.tv_tips,
|
||||
helper.itemView.context.getColorById(R.color.color_FF285C)
|
||||
)
|
||||
} else {
|
||||
helper.setBackgroundRes(R.id.layout_root, R.drawable.shape_f8f8fa_8)
|
||||
helper.setTextColor(
|
||||
R.id.tv_name,
|
||||
helper.itemView.context.getColorById(R.color.color_767585)
|
||||
)
|
||||
helper.setTextColor(
|
||||
R.id.tv_tips,
|
||||
helper.itemView.context.getColorById(R.color.color_94959C)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun select(position: Int) {
|
||||
this.selectPosition = position
|
||||
notifyItemRangeChanged(0, itemCount, true)
|
||||
}
|
||||
|
||||
fun getSelect(): ItemData? {
|
||||
return data.getOrNull(selectPosition)
|
||||
}
|
||||
}
|
@@ -0,0 +1,116 @@
|
||||
package com.yizhuan.erban.avroom.redpackage.send;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
|
||||
import com.chuhai.utils.UiUtils;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.common.util.Utils;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.abs.IPagerIndicator;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.abs.IPagerTitleView;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author jack
|
||||
* @Description
|
||||
* @Date 2018/11/1
|
||||
*/
|
||||
public class TabIndicatorAdapter extends CommonNavigatorAdapter {
|
||||
private List<String> mTitleList;
|
||||
private Context mContext;
|
||||
|
||||
public TabIndicatorAdapter(Context mContext, List<String> mTitleList ) {
|
||||
this.mTitleList = mTitleList;
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mTitleList == null ? 0 : mTitleList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPagerTitleView getTitleView(Context context, int index) {
|
||||
ContactsPagerTitleView categoryPagerTitleView = new ContactsPagerTitleView(context, mTitleList.get(index));
|
||||
categoryPagerTitleView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (null != mOnItemSelectListener) {
|
||||
mOnItemSelectListener.onItemSelect(index);
|
||||
}
|
||||
}
|
||||
});
|
||||
return categoryPagerTitleView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPagerIndicator getIndicator(Context context) {
|
||||
LinePagerIndicator indicator = new LinePagerIndicator(context);
|
||||
indicator.setMode(LinePagerIndicator.MODE_EXACTLY);
|
||||
indicator.setLineHeight(UIUtil.dip2px(mContext, 4));
|
||||
indicator.setRoundRadius(UIUtil.dip2px(mContext, 4));
|
||||
indicator.setLineWidth(UIUtil.dip2px(mContext, 12));
|
||||
indicator.setColors(context.getResources().getColor(R.color.color_FF285C));
|
||||
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
lp.topMargin = UIUtil.dip2px(mContext, 2);
|
||||
indicator.setLayoutParams(lp);
|
||||
return indicator;
|
||||
}
|
||||
|
||||
private OnItemSelectListener mOnItemSelectListener;
|
||||
|
||||
public void setOnItemSelectListener(OnItemSelectListener onItemSelectListener) {
|
||||
mOnItemSelectListener = onItemSelectListener;
|
||||
}
|
||||
|
||||
public interface OnItemSelectListener {
|
||||
void onItemSelect(int position);
|
||||
}
|
||||
|
||||
class ContactsPagerTitleView extends AppCompatTextView implements IPagerTitleView {
|
||||
|
||||
|
||||
public ContactsPagerTitleView(Context context, String tabInfo) {
|
||||
super(context);
|
||||
setHeight(Utils.dip2px(getContext(), 25));
|
||||
setTextSize(18);
|
||||
setText(tabInfo);
|
||||
setGravity(Gravity.CENTER);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onSelected(int index, int totalCount) {
|
||||
// setBackgroundResource(R.drawable.shape_bg_contact_indicator_item);
|
||||
setTextColor(getResources().getColor(R.color.color_FF285C));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeselected(int index, int totalCount) {
|
||||
// setBackgroundDrawable(null);
|
||||
setTextColor(getResources().getColor(R.color.color_767585));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLeave(int index, int totalCount, float leavePercent, boolean leftToRight) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnter(int index, int totalCount, float enterPercent, boolean leftToRight) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,84 @@
|
||||
package com.yizhuan.erban.avroom.room_album
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.databinding.DialogChooseGiftRoomAlbumBinding
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2
|
||||
import com.yizhuan.erban.ui.widget.recyclerview.decoration.GridSpacingItemNewDecoration
|
||||
import com.yizhuan.xchat_android_core.gift.GiftModel
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftType
|
||||
|
||||
class ChooseGiftRoomAlbumDialogFragment : BottomSheetDialogFragment() {
|
||||
|
||||
private var _binding: DialogChooseGiftRoomAlbumBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
var onPickedListener: OnPickedListener? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setStyle(STYLE_NO_TITLE, R.style.ErbanBottomSheetDialog)
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val dialog = super.onCreateDialog(savedInstanceState)
|
||||
dialog.window?.attributes?.apply {
|
||||
width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
height = WindowManager.LayoutParams.MATCH_PARENT
|
||||
}
|
||||
|
||||
return dialog
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = DialogChooseGiftRoomAlbumBinding.inflate(layoutInflater, container, false)
|
||||
|
||||
binding.rvGifts.layoutManager = GridLayoutManager(context, 4)
|
||||
binding.rvGifts.addItemDecoration(GridSpacingItemNewDecoration(resources.getDimensionPixelOffset(R.dimen.dp_20), true))
|
||||
|
||||
|
||||
binding.rvGifts.adapter = object : BaseQuickAdapter<GiftInfo, BaseViewHolder>(R.layout.item_gift_room_album){
|
||||
override fun convert(helper: BaseViewHolder, item: GiftInfo) {
|
||||
ImageLoadUtilsV2.loadImage(helper.getView(R.id.iv_gift), item.giftUrl)
|
||||
helper.setText(R.id.tv_gift, item.giftName)
|
||||
helper.setText(R.id.tv_value, item.goldPrice.toString())
|
||||
}
|
||||
}.apply {
|
||||
val gifts = GiftModel.get().getGiftInfoList(GiftType.GIFT_TYPE_NORMAL)
|
||||
setNewData(gifts)
|
||||
|
||||
setOnItemClickListener { _, _, position ->
|
||||
onPickedListener?.onPicked(data[position])
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
binding.ivClose.setOnClickListener { dismiss() }
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
}
|
||||
|
||||
fun interface OnPickedListener {
|
||||
fun onPicked(giftInfo: GiftInfo)
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package com.yizhuan.erban.avroom.room_album
|
||||
|
||||
import com.chad.library.adapter.base.entity.MultiItemEntity
|
||||
|
||||
data class PhotoItem(val path: String, val type: Int) : MultiItemEntity {
|
||||
override fun getItemType(): Int {
|
||||
return type
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TYPE_PHOTO = 0
|
||||
const val TYPE_ADD = 1
|
||||
}
|
||||
}
|
@@ -0,0 +1,114 @@
|
||||
package com.yizhuan.erban.avroom.room_album
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.LinearGradient
|
||||
import android.graphics.Shader
|
||||
import androidx.activity.viewModels
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseViewBindingActivity
|
||||
import com.yizhuan.erban.databinding.ActivityRoomAlbumBinding
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.ViewPagerHelper
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.abs.IPagerIndicator
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.abs.IPagerTitleView
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.indicators.GradientLinePagerIndicator
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.titles.ColorTransitionPagerTitleView
|
||||
|
||||
class RoomAlbumActivity : BaseViewBindingActivity<ActivityRoomAlbumBinding>() {
|
||||
|
||||
val viewModel: RoomAlbumViewModel by viewModels()
|
||||
|
||||
override fun init() {
|
||||
initTitleBar(getString(R.string.room_album))
|
||||
mTitleBar.setBackgroundResource(R.color.white)
|
||||
|
||||
val titles = listOf("我的照片", "普通照片", "解鎖照片")
|
||||
|
||||
binding.indicator.navigator = CommonNavigator(this).apply {
|
||||
isAdjustMode = true
|
||||
|
||||
adapter = object : CommonNavigatorAdapter() {
|
||||
var startColor = ContextCompat.getColor(context, R.color.color_5CF1FF)
|
||||
var endColor = ContextCompat.getColor(context, R.color.color_CF70FF)
|
||||
override fun getCount(): Int {
|
||||
return 3
|
||||
}
|
||||
|
||||
override fun getTitleView(context: Context, index: Int): IPagerTitleView {
|
||||
return ColorTransitionPagerTitleView(context).apply {
|
||||
normalColor = ContextCompat.getColor(context, R.color.color_767585)
|
||||
selectedColor = ContextCompat.getColor(context, R.color.color_1F1B4F)
|
||||
text = titles[index]
|
||||
}.apply {
|
||||
setOnClickListener { binding.vp.currentItem = index }
|
||||
}
|
||||
}
|
||||
|
||||
override fun getIndicator(context: Context?): IPagerIndicator {
|
||||
return object : GradientLinePagerIndicator(context) {
|
||||
@SuppressLint("DrawAllocation")
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
val g = LinearGradient(
|
||||
lineRect.left,
|
||||
lineRect.top,
|
||||
lineRect.right,
|
||||
lineRect.bottom,
|
||||
intArrayOf(startColor, endColor),
|
||||
null,
|
||||
Shader.TileMode.CLAMP
|
||||
)
|
||||
paint.shader = g
|
||||
canvas.drawRoundRect(lineRect, roundRadius, roundRadius, paint)
|
||||
}
|
||||
|
||||
}.apply {
|
||||
lineHeight = resources.getDimensionPixelOffset(R.dimen.dp_4).toFloat()
|
||||
lineWidth = resources.getDimensionPixelOffset(R.dimen.dp_15).toFloat()
|
||||
roundRadius = resources.getDimensionPixelOffset(R.dimen.dp_2).toFloat()
|
||||
mode = LinePagerIndicator.MODE_EXACTLY
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ViewPagerHelper.bind(binding.indicator, binding.vp)
|
||||
|
||||
val fragments = listOf(
|
||||
RoomAlbumFragment.newInstance(RoomAlbumFragment.TYPE_MINE),
|
||||
RoomAlbumFragment.newInstance(RoomAlbumFragment.TYPE_COMMON),
|
||||
RoomAlbumFragment.newInstance(RoomAlbumFragment.TYPE_LOCKED)
|
||||
)
|
||||
|
||||
binding.vp.adapter = object : FragmentStateAdapter(this) {
|
||||
override fun getItemCount(): Int {
|
||||
return fragments.size
|
||||
}
|
||||
|
||||
override fun createFragment(position: Int): Fragment {
|
||||
return fragments[position]
|
||||
}
|
||||
}
|
||||
|
||||
binding.tvUpload.setOnClickListener {
|
||||
UploadRoomAlbumDialogFragment().show(
|
||||
supportFragmentManager,
|
||||
UploadRoomAlbumDialogFragment::class.java.simpleName
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, RoomAlbumActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,201 @@
|
||||
package com.yizhuan.erban.avroom.room_album
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chad.library.adapter.base.diff.BaseQuickDiffCallback
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.bean.RoomAlbumPhotoInfo
|
||||
import com.yizhuan.erban.base.BaseViewBindingFragment
|
||||
import com.yizhuan.erban.community.photo.BigPhotoActivity
|
||||
import com.yizhuan.erban.community.photo.PagerOption
|
||||
import com.yizhuan.erban.community.utils.ObjectTypeHelper
|
||||
import com.yizhuan.erban.databinding.FragmentRoomAlbumBinding
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtils
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2
|
||||
import com.yizhuan.erban.ui.widget.ButtonItem
|
||||
import com.yizhuan.erban.ui.widget.recyclerview.decoration.GridSpacingItemNewDecoration
|
||||
import com.yizhuan.xchat_android_core.Constants
|
||||
|
||||
class RoomAlbumFragment : BaseViewBindingFragment<FragmentRoomAlbumBinding>() {
|
||||
|
||||
private val activityViewModel by activityViewModels<RoomAlbumViewModel>()
|
||||
private val viewModel by viewModels<RoomAlbumFragmentViewModel>()
|
||||
|
||||
private val type: Int by lazy {
|
||||
requireArguments().getInt("type")
|
||||
}
|
||||
|
||||
private var page = 1
|
||||
|
||||
override fun init() {
|
||||
binding.recyclerView.layoutManager = GridLayoutManager(context, 2)
|
||||
val offsetH = resources.getDimensionPixelOffset(R.dimen.dp_7)
|
||||
val offsetV = resources.getDimensionPixelOffset(R.dimen.dp_4)
|
||||
binding.recyclerView.addItemDecoration(
|
||||
GridSpacingItemNewDecoration(
|
||||
offsetV,
|
||||
offsetH,
|
||||
false
|
||||
)
|
||||
)
|
||||
val adapter = object :
|
||||
BaseQuickAdapter<RoomAlbumPhotoInfo, BaseViewHolder>(R.layout.item_room_album) {
|
||||
override fun convert(helper: BaseViewHolder, item: RoomAlbumPhotoInfo) {
|
||||
val ivPhoto = helper.getView<ImageView>(R.id.iv_pic)
|
||||
if (item.status == 1) {
|
||||
ImageLoadUtilsV2.loadImage(ivPhoto, item.photoUrl)
|
||||
helper.setVisible(R.id.iv_lock, false)
|
||||
} else {
|
||||
ImageLoadUtils.loadImageWithBlur(
|
||||
context,
|
||||
item.photoUrl,
|
||||
ivPhoto,
|
||||
25, 4
|
||||
)
|
||||
helper.setVisible(R.id.iv_lock, true)
|
||||
}
|
||||
|
||||
helper.setVisible(R.id.v_action, type == TYPE_MINE)
|
||||
helper.setVisible(R.id.v_bottom_mask, item.type == 2)
|
||||
helper.setVisible(R.id.iv_gift, item.type == 2)
|
||||
helper.setVisible(R.id.iv_diamond, item.type == 2)
|
||||
helper.setVisible(R.id.tv_value, item.type == 2)
|
||||
|
||||
helper.itemView.setOnClickListener {
|
||||
if (item.type != 1) {
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
BigPhotoActivity.start(
|
||||
activity,
|
||||
ObjectTypeHelper.pathToCustomItems(item.photoUrl),
|
||||
0, PagerOption().setSave(true)
|
||||
)
|
||||
}
|
||||
|
||||
if (item.type == 2) {
|
||||
val ivGift = helper.getView<ImageView>(R.id.iv_gift)
|
||||
ImageLoadUtilsV2.loadImage(ivGift, item.giftUrl)
|
||||
helper.setText(R.id.tv_value, item.totalGoldPrice.toString())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onCreateDefViewHolder(
|
||||
parent: ViewGroup?,
|
||||
viewType: Int
|
||||
): BaseViewHolder {
|
||||
val holder = super.onCreateDefViewHolder(parent, viewType)
|
||||
holder.addOnClickListener(R.id.v_action)
|
||||
return holder
|
||||
}
|
||||
|
||||
}.apply {
|
||||
addFooterView(View(context).apply {
|
||||
layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, resources.getDimensionPixelOffset(R.dimen.dp_80))
|
||||
})
|
||||
setEnableLoadMore(true)
|
||||
setOnLoadMoreListener({
|
||||
viewModel.loadPhotos(type, ++page)
|
||||
}, binding.recyclerView)
|
||||
|
||||
setOnItemChildClickListener { _, view, position ->
|
||||
if (view.id == R.id.v_action) {
|
||||
val buttonItems = listOf(
|
||||
ButtonItem("發送到公屏") {
|
||||
dialogManager.showOkCancelDialog("確認將該照片發送至公屏") {
|
||||
viewModel.sendPhoto(data[position].id)
|
||||
}
|
||||
},
|
||||
ButtonItem("刪除照片") {
|
||||
viewModel.deletePhoto(data[position].id)
|
||||
},
|
||||
ButtonItem("查看大圖") {
|
||||
BigPhotoActivity.start(
|
||||
activity,
|
||||
ObjectTypeHelper.pathToCustomItems(data[position].photoUrl),
|
||||
0, PagerOption().setSave(true)
|
||||
)
|
||||
}
|
||||
)
|
||||
dialogManager.showCommonPopupDialog(buttonItems)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
binding.recyclerView.adapter = adapter
|
||||
|
||||
binding.refreshLayout.setOnRefreshListener {
|
||||
page = Constants.PAGE_START
|
||||
viewModel.loadPhotos(type)
|
||||
}
|
||||
|
||||
viewModel.loadPhotos(type)
|
||||
|
||||
activityViewModel.uploadLiveData.observe(this) {
|
||||
page = Constants.PAGE_START
|
||||
viewModel.loadPhotos(type)
|
||||
}
|
||||
|
||||
viewModel.myPhotosLiveData.observe(this@RoomAlbumFragment) {
|
||||
adapter.loadMoreComplete()
|
||||
|
||||
adapter.setNewDiffData(object : BaseQuickDiffCallback<RoomAlbumPhotoInfo>(it) {
|
||||
override fun areItemsTheSame(
|
||||
oldItem: RoomAlbumPhotoInfo,
|
||||
newItem: RoomAlbumPhotoInfo
|
||||
): Boolean {
|
||||
return oldItem.id == newItem.id
|
||||
}
|
||||
|
||||
override fun areContentsTheSame(
|
||||
oldItem: RoomAlbumPhotoInfo,
|
||||
newItem: RoomAlbumPhotoInfo
|
||||
): Boolean {
|
||||
return oldItem.photoUrl === newItem.photoUrl
|
||||
}
|
||||
})
|
||||
|
||||
binding.refreshLayout.finishRefresh()
|
||||
}
|
||||
viewModel.deleteLiveData.observe(this) {
|
||||
viewModel.loadPhotos(type)
|
||||
}
|
||||
viewModel.loadStateLiveData.observe(this) {
|
||||
if (it == true) {
|
||||
adapter.loadMoreComplete()
|
||||
} else {
|
||||
if (page > 1) {
|
||||
page--
|
||||
}
|
||||
adapter.loadMoreFail()
|
||||
}
|
||||
binding.refreshLayout.finishRefresh()
|
||||
}
|
||||
viewModel.noMoreLiveData.observe(this) {
|
||||
if (it == true) {
|
||||
adapter.loadMoreEnd()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TYPE_MINE = 0
|
||||
const val TYPE_COMMON = 1
|
||||
const val TYPE_LOCKED = 2
|
||||
fun newInstance(type: Int) = RoomAlbumFragment().apply {
|
||||
arguments = Bundle().apply {
|
||||
putInt("type", type)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
package com.yizhuan.erban.avroom.room_album
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.yizhuan.erban.avroom.bean.RoomAlbumPhotoInfo
|
||||
import com.yizhuan.erban.base.BaseViewModel
|
||||
import com.yizhuan.xchat_android_core.Constants
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.utils.toast
|
||||
|
||||
class RoomAlbumFragmentViewModel : BaseViewModel() {
|
||||
|
||||
private val _myPhotosLiveData = MutableLiveData<MutableList<RoomAlbumPhotoInfo>?>()
|
||||
val myPhotosLiveData: LiveData<MutableList<RoomAlbumPhotoInfo>?> = _myPhotosLiveData
|
||||
|
||||
private val _deleteLiveData = MutableLiveData<Boolean?>()
|
||||
val deleteLiveData: LiveData<Boolean?> = _deleteLiveData
|
||||
|
||||
private val _loadStateLiveData = MutableLiveData<Boolean?>()
|
||||
val loadStateLiveData: LiveData<Boolean?> = _loadStateLiveData
|
||||
|
||||
private val _noMoreLiveData = MutableLiveData<Boolean?>()
|
||||
val noMoreLiveData: LiveData<Boolean?> = _noMoreLiveData
|
||||
|
||||
fun loadPhotos(type: Int, page: Int = 1) {
|
||||
safeLaunch(block = {
|
||||
val data = RoomAlbumModel.loadPhotos(AvRoomDataManager.get().roomUid, type, page)
|
||||
|
||||
data?.let {
|
||||
val value = _myPhotosLiveData.value
|
||||
if (page == 1) {
|
||||
_myPhotosLiveData.value = it.toMutableList()
|
||||
} else {
|
||||
value?.addAll(it)
|
||||
_myPhotosLiveData.value = value
|
||||
}
|
||||
|
||||
_loadStateLiveData.value = true
|
||||
_noMoreLiveData.value = it.size < Constants.PAGE_SIZE
|
||||
}
|
||||
|
||||
}, onError = {
|
||||
it.message.toast()
|
||||
_loadStateLiveData.value = false
|
||||
})
|
||||
}
|
||||
|
||||
fun sendPhoto(photoId: Int) {
|
||||
safeLaunch(block = {
|
||||
RoomAlbumModel.sendPhoto(AvRoomDataManager.get().roomUid, photoId)
|
||||
}, onComplete = {
|
||||
ToastUtils.show("發送成功")
|
||||
})
|
||||
}
|
||||
|
||||
fun deletePhoto(photoId: Int) {
|
||||
safeLaunch(block = {
|
||||
RoomAlbumModel.deletePhoto(photoId)
|
||||
|
||||
_deleteLiveData.value = true
|
||||
|
||||
}, onComplete = {
|
||||
ToastUtils.show("成功")
|
||||
})
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,100 @@
|
||||
package com.yizhuan.erban.avroom.room_album
|
||||
|
||||
import com.yizhuan.erban.avroom.bean.RoomAlbumPhotoInfo
|
||||
import com.yizhuan.xchat_android_core.Constants
|
||||
import com.yizhuan.xchat_android_core.bean.response.ServiceResult
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftReceiveInfo
|
||||
import com.yizhuan.xchat_android_core.utils.net.RxHelper
|
||||
import com.yizhuan.xchat_android_core.utils.net.launchRequest
|
||||
import com.yizhuan.xchat_android_library.net.rxnet.RxNet
|
||||
import io.reactivex.Single
|
||||
import retrofit2.http.Field
|
||||
import retrofit2.http.FormUrlEncoded
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.POST
|
||||
import retrofit2.http.Query
|
||||
|
||||
object RoomAlbumModel {
|
||||
private val api = RxNet.create(Api::class.java)
|
||||
|
||||
suspend fun loadPhotos(roomUid: Long, type: Int, page: Int): List<RoomAlbumPhotoInfo>? {
|
||||
return launchRequest {
|
||||
api.loadPhotos(roomUid, type, page, Constants.PAGE_SIZE)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun uploadPhotos(roomUid: Long, type: Int, photoUrls: String, giftId: Int?): String? {
|
||||
return launchRequest {
|
||||
api.uploadPhotos(roomUid, type, photoUrls, giftId)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun sendPhoto(roomUid: Long, photoId: Int): String? {
|
||||
return launchRequest {
|
||||
api.sendPhoto(roomUid, photoId)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun deletePhoto(photoId: Int): String? {
|
||||
return launchRequest {
|
||||
api.deletePhoto(photoId)
|
||||
}
|
||||
}
|
||||
|
||||
fun unlockRoomPhoto(roomUid: Long, photoId: Int): Single<GiftReceiveInfo> {
|
||||
return api.unlockRoomPhoto(roomUid, photoId)
|
||||
.compose(RxHelper.handleCommon())
|
||||
.compose(RxHelper.handleSchAndExce())
|
||||
}
|
||||
|
||||
fun listUnlockRoomPhoto(roomUid: Long): Single<List<Int>> {
|
||||
return api.listUnlockRoomPhoto(roomUid)
|
||||
.compose(RxHelper.handleCommon())
|
||||
.compose(RxHelper.handleSchAndExce())
|
||||
}
|
||||
|
||||
private interface Api {
|
||||
|
||||
@GET("roomAlbum/pagePhoto")
|
||||
suspend fun loadPhotos(
|
||||
@Query("roomUid") roomUid: Long,
|
||||
@Query("type") type: Int,
|
||||
@Query("page") page: Int,
|
||||
@Query("pageSize") pageSize: Int,
|
||||
): ServiceResult<List<RoomAlbumPhotoInfo>>
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST("roomAlbum/upload")
|
||||
suspend fun uploadPhotos(
|
||||
@Field("roomUid") roomUid: Long,
|
||||
@Field("type") type: Int,
|
||||
@Field("photoUrls") photoUrls: String,
|
||||
@Field("giftId") giftId: Int?,
|
||||
): ServiceResult<String>
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST("roomAlbum/sendPhoto")
|
||||
suspend fun sendPhoto(
|
||||
@Field("roomUid") roomUid: Long,
|
||||
@Field("id") photoId: Int,
|
||||
): ServiceResult<String>
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST("roomAlbum/delete")
|
||||
suspend fun deletePhoto(
|
||||
@Field("id") photoId: Int,
|
||||
): ServiceResult<String>
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST("roomAlbum/unlockPhoto")
|
||||
fun unlockRoomPhoto(
|
||||
@Field("roomUid") roomUid: Long,
|
||||
@Field("id") photoId: Int
|
||||
): Single<ServiceResult<GiftReceiveInfo>>
|
||||
|
||||
@GET("roomAlbum/listUnlockPhoto")
|
||||
fun listUnlockRoomPhoto(
|
||||
@Query("roomUid") roomUid: Long,
|
||||
): Single<ServiceResult<List<Int>>>
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
package com.yizhuan.erban.avroom.room_album
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.yizhuan.erban.base.BaseViewModel
|
||||
import com.yizhuan.erban.base.Event
|
||||
import com.yizhuan.xchat_android_core.file.FileModel
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.utils.toast
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
class RoomAlbumViewModel : BaseViewModel() {
|
||||
|
||||
|
||||
private val _uploadLiveData = MutableLiveData<Event<Boolean>>()
|
||||
val uploadLiveData: LiveData<Event<Boolean>?> = _uploadLiveData
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
fun upload(list: MutableList<String>, type: Int, unlockedGift: GiftInfo?) {
|
||||
Observable.fromIterable(list)
|
||||
.flatMap {
|
||||
FileModel.get().uploadFile(it).toObservable()
|
||||
}
|
||||
.toList()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
safeLaunch(onError = {
|
||||
_uploadLiveData.value = Event(false)
|
||||
}, block = {
|
||||
RoomAlbumModel.uploadPhotos(
|
||||
AvRoomDataManager.get().roomUid,
|
||||
type,
|
||||
it.joinToString(","),
|
||||
unlockedGift?.giftId
|
||||
)
|
||||
_uploadLiveData.value = Event(true)
|
||||
})
|
||||
}, {
|
||||
it.message.toast()
|
||||
_uploadLiveData.value = Event(false)
|
||||
})
|
||||
}
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
package com.yizhuan.erban.avroom.room_album
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.databinding.DialogLockRoomAlbumPhotoBinding
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftReceiveInfo
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
|
||||
class UnlockRoomAlbumPhotoDialog : BaseDialog<DialogLockRoomAlbumPhotoBinding>(){
|
||||
|
||||
var onUnlockRoomPhotoListener: OnUnlockRoomPhotoListener? = null
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
val arguments = requireArguments()
|
||||
val giftUrl = arguments.getString("giftUrl")
|
||||
val giftName = arguments.getString("giftName")
|
||||
val price = arguments.getInt("price")
|
||||
val photoId = arguments.getInt("photoId")
|
||||
|
||||
ImageLoadUtilsV2.loadImage(binding.ivGift, giftUrl)
|
||||
binding.tvGiftName.text = giftName
|
||||
binding.tvValue.text = price.toString()
|
||||
|
||||
binding.tvAction.setOnClickListener {
|
||||
RoomAlbumModel.unlockRoomPhoto(AvRoomDataManager.get().roomUid, photoId)
|
||||
.subscribe({
|
||||
onUnlockRoomPhotoListener?.onUnlockRoomPhoto(it)
|
||||
dismiss()
|
||||
}, {
|
||||
ToastUtils.show(it.message)
|
||||
})
|
||||
}
|
||||
|
||||
binding.ivClose.setOnClickListener {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
companion object{
|
||||
fun newInstance(photoId:Int, giftUrl: String?, giftName:String, price:Int): UnlockRoomAlbumPhotoDialog {
|
||||
val args = Bundle()
|
||||
args.putInt("photoId", photoId)
|
||||
args.putString("giftUrl", giftUrl)
|
||||
args.putString("giftName", giftName)
|
||||
args.putInt("price", price)
|
||||
val fragment = UnlockRoomAlbumPhotoDialog()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
fun interface OnUnlockRoomPhotoListener{
|
||||
fun onUnlockRoomPhoto(unlockRoomAlbumPhotoInfo: GiftReceiveInfo)
|
||||
}
|
||||
}
|
@@ -0,0 +1,294 @@
|
||||
package com.yizhuan.erban.avroom.room_album
|
||||
|
||||
import android.Manifest
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.app.Dialog
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.common.widget.dialog.DialogManager
|
||||
import com.yizhuan.erban.databinding.DialogRoomAlbumUploadBinding
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2
|
||||
import com.yizhuan.erban.ui.widget.recyclerview.decoration.GridSpacingItemNewDecoration
|
||||
import com.yizhuan.xchat_android_core.Constants
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo
|
||||
import com.yizhuan.xchat_android_library.common.photo.PhotoProvider
|
||||
import com.yizhuan.xchat_android_library.common.photo.PhotoProvider.photoProvider
|
||||
import com.yizhuan.xchat_android_library.common.util.PhotoCompressUtil.compress
|
||||
import com.yizhuan.xchat_android_library.common.util.PhotoCompressUtil.getCompressCachePath
|
||||
import com.yizhuan.xchat_android_library.common.util.PhotosCompressCallback
|
||||
import com.yizhuan.xchat_android_library.easypermisssion.EasyPermissions
|
||||
import kotlinx.coroutines.Job
|
||||
|
||||
class UploadRoomAlbumDialogFragment : BottomSheetDialogFragment() {
|
||||
|
||||
private var _binding: DialogRoomAlbumUploadBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
private val viewModel by activityViewModels<RoomAlbumViewModel>()
|
||||
|
||||
private lateinit var photoAdapter: BaseMultiItemQuickAdapter<PhotoItem, BaseViewHolder>
|
||||
|
||||
private var unlockedGift: GiftInfo? = null
|
||||
|
||||
private var compressJob: Job? = null
|
||||
|
||||
val dialogManager by lazy {
|
||||
DialogManager(context)
|
||||
}
|
||||
|
||||
private val addItem = PhotoItem("", PhotoItem.TYPE_ADD)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setStyle(STYLE_NO_TITLE, R.style.ErbanBottomSheetDialog)
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val dialog = super.onCreateDialog(savedInstanceState)
|
||||
dialog.window?.attributes?.apply {
|
||||
width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
height = WindowManager.LayoutParams.MATCH_PARENT
|
||||
}
|
||||
|
||||
return dialog
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = DialogRoomAlbumUploadBinding.inflate(layoutInflater, container, false)
|
||||
|
||||
binding.rvPhoto.layoutManager = GridLayoutManager(context, 3)
|
||||
binding.rvPhoto.addItemDecoration(
|
||||
GridSpacingItemNewDecoration(
|
||||
resources.getDimensionPixelOffset(
|
||||
R.dimen.dp_18
|
||||
), true
|
||||
)
|
||||
)
|
||||
|
||||
photoAdapter =
|
||||
object : BaseMultiItemQuickAdapter<PhotoItem, BaseViewHolder>(mutableListOf(addItem)) {
|
||||
init {
|
||||
addItemType(PhotoItem.TYPE_PHOTO, R.layout.item_publish_image)
|
||||
addItemType(PhotoItem.TYPE_ADD, R.layout.item_add_picture)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
|
||||
val holder = super.onCreateViewHolder(parent, viewType)
|
||||
if (viewType == PhotoItem.TYPE_PHOTO) {
|
||||
holder.setGone(R.id.iv_gif_tag, false)
|
||||
holder.setImageResource(R.id.iv_delete, R.drawable.ic_delete_room_album)
|
||||
holder.addOnClickListener(R.id.iv_delete)
|
||||
}
|
||||
return holder
|
||||
}
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: PhotoItem) {
|
||||
if (item.type == PhotoItem.TYPE_ADD) {
|
||||
return
|
||||
}
|
||||
|
||||
ImageLoadUtilsV2.loadImage(helper.getView(R.id.iv_photo), item.path, false, 8)
|
||||
}
|
||||
}.apply {
|
||||
setOnItemChildClickListener { _, view, position ->
|
||||
if (view.id == R.id.iv_delete) {
|
||||
remove(position)
|
||||
if (data.last().type != PhotoItem.TYPE_ADD) {
|
||||
addData(addItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
setOnItemClickListener { _, _, position ->
|
||||
if (position == data.size - 1) {
|
||||
checkStoragePermission()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
binding.rvPhoto.adapter = photoAdapter
|
||||
|
||||
binding.vGift.isEnabled = false
|
||||
binding.rgType.setOnCheckedChangeListener { group, checkedId ->
|
||||
if (checkedId == binding.rbCommon.id) {
|
||||
binding.tvNoGift.visibility = View.VISIBLE
|
||||
binding.tvNoGift.text =
|
||||
getString(R.string.room_album_type_no_need_unlocked_gift_tips)
|
||||
binding.groupGift.visibility = View.INVISIBLE
|
||||
unlockedGift = null
|
||||
|
||||
binding.vGift.isEnabled = false
|
||||
binding.tvGiftLabel.setTextColor(
|
||||
ContextCompat.getColor(
|
||||
requireContext(),
|
||||
R.color.color_B3B3C3
|
||||
)
|
||||
)
|
||||
} else {
|
||||
binding.tvNoGift.visibility = View.VISIBLE
|
||||
binding.tvNoGift.text =
|
||||
getString(R.string.room_album_type_choose_unlocked_gift_tips)
|
||||
|
||||
binding.groupGift.visibility = View.INVISIBLE
|
||||
binding.vGift.isEnabled = true
|
||||
binding.tvGiftLabel.setTextColor(
|
||||
ContextCompat.getColor(
|
||||
requireContext(),
|
||||
R.color.color_1F1B4F
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
binding.vGift.setOnClickListener {
|
||||
val chooseGiftRoomAlbumDialogFragment = ChooseGiftRoomAlbumDialogFragment()
|
||||
chooseGiftRoomAlbumDialogFragment.onPickedListener =
|
||||
ChooseGiftRoomAlbumDialogFragment.OnPickedListener {
|
||||
unlockedGift = it
|
||||
|
||||
binding.tvNoGift.visibility = View.INVISIBLE
|
||||
binding.groupGift.visibility = View.VISIBLE
|
||||
|
||||
ImageLoadUtilsV2.loadImage(binding.ivGift, it.giftUrl)
|
||||
binding.tvGiftName.text = it.giftName
|
||||
binding.tvGiftValue.text = it.goldPrice.toString()
|
||||
}
|
||||
chooseGiftRoomAlbumDialogFragment.show(
|
||||
childFragmentManager,
|
||||
UploadRoomAlbumDialogFragment::class.java.simpleName
|
||||
)
|
||||
}
|
||||
|
||||
binding.slConfirm.setOnClickListener {
|
||||
val list = mutableListOf<String>()
|
||||
photoAdapter.data.forEach {
|
||||
if (it.type == PhotoItem.TYPE_PHOTO) {
|
||||
list.add(it.path)
|
||||
}
|
||||
}
|
||||
if (list.size < 1) {
|
||||
ToastUtils.show("未選擇圖片")
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
val type = if (binding.rgType.checkedRadioButtonId == binding.rbCommon.id) 1 else 2
|
||||
if (type == 2 && unlockedGift == null) {
|
||||
ToastUtils.show("未選擇解鎖禮物")
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
dialogManager.showProgressDialog(context)
|
||||
viewModel.upload(
|
||||
list,
|
||||
type,
|
||||
unlockedGift
|
||||
)
|
||||
}
|
||||
|
||||
viewModel.uploadLiveData.observe(this) {
|
||||
it?.getContentIfNotHandled()?.let { success ->
|
||||
dialogManager.hideProgressDialog()
|
||||
|
||||
if (success) {
|
||||
dismiss()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
binding.ivClose.setOnClickListener { dismiss() }
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
private fun checkStoragePermission() {
|
||||
if (!EasyPermissions.hasPermissions(
|
||||
requireContext(),
|
||||
if (Build.VERSION.SDK_INT >= 33) Manifest.permission.READ_MEDIA_IMAGES
|
||||
else Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
)
|
||||
) {
|
||||
EasyPermissions.requestPermissions(
|
||||
this,
|
||||
getString(R.string.permission_storage_rationale),
|
||||
100,
|
||||
if (Build.VERSION.SDK_INT >= 33) Manifest.permission.READ_MEDIA_IMAGES
|
||||
else Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
)
|
||||
} else {
|
||||
photoProvider(
|
||||
this,
|
||||
7 - photoAdapter.data.size,
|
||||
true,
|
||||
200,
|
||||
true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (resultCode != Activity.RESULT_OK) {
|
||||
return
|
||||
}
|
||||
if (requestCode == 200) {
|
||||
PhotoProvider.getResultPathListAsync(data) {
|
||||
it?.let { paths ->
|
||||
compressPhotos(paths.toMutableList())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun compressPhotos(paths: MutableList<String>) {
|
||||
compressJob?.cancel(null)
|
||||
compressJob = compress(
|
||||
requireContext(), paths,
|
||||
getCompressCachePath(),
|
||||
object : PhotosCompressCallback {
|
||||
override fun onSuccess(compressedImgList: ArrayList<String>) {
|
||||
val list = photoAdapter.data
|
||||
val removeLast = list.removeLast()
|
||||
compressedImgList.forEach { item ->
|
||||
list.add(PhotoItem(item, PhotoItem.TYPE_PHOTO))
|
||||
}
|
||||
if (list.size < 6) {
|
||||
list.add(removeLast)
|
||||
}
|
||||
photoAdapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onFail(e: Throwable) {
|
||||
ToastUtils.show(getString(R.string.picker_image_error))
|
||||
}
|
||||
}, 200, false, Constants.UPLOAD_IMAGE_MAX_SIZE, Constants.UPLOAD_IMAGE_MAX_FILE_LENGTH
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
}
|
||||
|
||||
}
|
@@ -33,37 +33,37 @@ class SingleRoomPkFinishDialog : BaseDialog<DialogSingleRoomPkFinishBinding>() {
|
||||
|
||||
@SuppressLint("CheckResult", "SetTextI18n")
|
||||
override fun init() {
|
||||
binding.tvClose.setOnClickListener { dismissAllowingStateLoss() }
|
||||
binding.tvTitleRed.text = roomPkBean.cNick.subAndReplaceDot(7)
|
||||
binding.tvValueRed.text = "${roomPkBean.cAmount}"
|
||||
binding.ivAvatarRed.load(roomPkBean.cAvatar, defaultRes = R.drawable.default_avatar)
|
||||
binding?.tvClose?.setOnClickListener { dismissAllowingStateLoss() }
|
||||
binding?.tvTitleRed?.text = roomPkBean.cNick.subAndReplaceDot(7)
|
||||
binding?.tvValueRed?.text = "${roomPkBean.cAmount}"
|
||||
binding?.ivAvatarRed?.load(roomPkBean.cAvatar, defaultRes = R.drawable.default_avatar)
|
||||
|
||||
roomPkBean.csRank.getOrNull(0)?.let {
|
||||
binding.groupRank1.isVisible = true
|
||||
binding.tvRankNick1.text = it.nick.subAndReplaceDot(7)
|
||||
binding.tvRankValue1.text = "PK值:${it.amount}"
|
||||
binding.ivAvatar1.load(it.avatar, defaultRes = R.drawable.default_avatar)
|
||||
binding?.groupRank1?.isVisible = true
|
||||
binding?.tvRankNick1?.text = it.nick.subAndReplaceDot(7)
|
||||
binding?.tvRankValue1?.text = "PK值:${it.amount}"
|
||||
binding?.ivAvatar1?.load(it.avatar, defaultRes = R.drawable.default_avatar)
|
||||
} ?: run {
|
||||
binding.groupRank1.isVisible = false
|
||||
binding.tvEmptyTip.isVisible = true
|
||||
binding?.groupRank1?.isVisible = false
|
||||
binding?.tvEmptyTip?.isVisible = true
|
||||
}
|
||||
|
||||
roomPkBean.csRank.getOrNull(1)?.let {
|
||||
binding.groupRank2.isVisible = true
|
||||
binding.tvRankNick2.text = it.nick.subAndReplaceDot(7)
|
||||
binding.tvRankValue2.text = "PK值:${it.amount}"
|
||||
binding.ivAvatar2.load(it.avatar, defaultRes = R.drawable.default_avatar)
|
||||
binding?.groupRank2?.isVisible = true
|
||||
binding?.tvRankNick2?.text = it.nick.subAndReplaceDot(7)
|
||||
binding?.tvRankValue2?.text = "PK值:${it.amount}"
|
||||
binding?.ivAvatar2?.load(it.avatar, defaultRes = R.drawable.default_avatar)
|
||||
} ?: run {
|
||||
binding.groupRank2.isVisible = false
|
||||
binding?.groupRank2?.isVisible = false
|
||||
}
|
||||
|
||||
roomPkBean.csRank.getOrNull(2)?.let {
|
||||
binding.groupRank3.isVisible = true
|
||||
binding.tvRankNick3.text = it.nick.subAndReplaceDot(7)
|
||||
binding.tvRankValue3.text = "PK值:${it.amount}"
|
||||
binding.ivAvatar3.load(it.avatar, defaultRes = R.drawable.default_avatar)
|
||||
binding?.groupRank3?.isVisible = true
|
||||
binding?.tvRankNick3?.text = it.nick.subAndReplaceDot(7)
|
||||
binding?.tvRankValue3?.text = "PK值:${it.amount}"
|
||||
binding?.ivAvatar3?.load(it.avatar, defaultRes = R.drawable.default_avatar)
|
||||
} ?: run {
|
||||
binding.groupRank3.isVisible = false
|
||||
binding?.groupRank3?.isVisible = false
|
||||
}
|
||||
|
||||
Observable.intervalRange(0, 6, 0, 1, TimeUnit.SECONDS)
|
||||
@@ -71,24 +71,24 @@ class SingleRoomPkFinishDialog : BaseDialog<DialogSingleRoomPkFinishBinding>() {
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doOnComplete { dismissAllowingStateLoss() }
|
||||
.subscribe {
|
||||
binding.tvClose.text = "關閉(${5 - it})"
|
||||
binding?.tvClose?.text = "關閉(${5 - it})"
|
||||
}
|
||||
|
||||
when (roomPkBean.winUid) {
|
||||
0L -> {
|
||||
binding.viewBg.setBackgroundResource(R.drawable.single_room_pk_bg_finish_deuce)
|
||||
binding.viewBgAvatar.setBackgroundResource(R.drawable.single_room_pk_bg_finish_deuce_avatar)
|
||||
binding.tvContributeTitle.setBackgroundResource(R.drawable.single_room_pk_bg_finish_deuce_contribute)
|
||||
binding?.viewBg?.setBackgroundResource(R.drawable.single_room_pk_bg_finish_deuce)
|
||||
binding?.viewBgAvatar?.setBackgroundResource(R.drawable.single_room_pk_bg_finish_deuce_avatar)
|
||||
binding?.tvContributeTitle?.setBackgroundResource(R.drawable.single_room_pk_bg_finish_deuce_contribute)
|
||||
}
|
||||
roomPkBean.cUid -> {
|
||||
binding.viewBg.setBackgroundResource(R.drawable.single_room_pk_bg_finish_win)
|
||||
binding.viewBgAvatar.setBackgroundResource(R.drawable.single_room_pk_bg_finish_win_avatar)
|
||||
binding.tvContributeTitle.setBackgroundResource(R.drawable.single_room_pk_bg_finish_win_contribute)
|
||||
binding?.viewBg?.setBackgroundResource(R.drawable.single_room_pk_bg_finish_win)
|
||||
binding?.viewBgAvatar?.setBackgroundResource(R.drawable.single_room_pk_bg_finish_win_avatar)
|
||||
binding?.tvContributeTitle?.setBackgroundResource(R.drawable.single_room_pk_bg_finish_win_contribute)
|
||||
}
|
||||
else -> {
|
||||
binding.viewBg.setBackgroundResource(R.drawable.single_room_pk_bg_finish_failed)
|
||||
binding.viewBgAvatar.setBackgroundResource(R.drawable.single_room_pk_bg_finish_failed_avatar)
|
||||
binding.tvContributeTitle.setBackgroundResource(R.drawable.single_room_pk_bg_finish_failed_contribute)
|
||||
binding?.viewBg?.setBackgroundResource(R.drawable.single_room_pk_bg_finish_failed)
|
||||
binding?.viewBgAvatar?.setBackgroundResource(R.drawable.single_room_pk_bg_finish_failed_avatar)
|
||||
binding?.tvContributeTitle?.setBackgroundResource(R.drawable.single_room_pk_bg_finish_failed_contribute)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -29,23 +29,23 @@ class SingleRoomPkForceFinishDialog : BaseDialog<DialogSingleRoomPkForceFinishBi
|
||||
|
||||
@SuppressLint("CheckResult", "SetTextI18n")
|
||||
override fun init() {
|
||||
binding.ivClose.setOnClickListener { dismissAllowingStateLoss() }
|
||||
binding.tvTitleRed.text = roomPkBean.cNick.subAndReplaceDot(7)
|
||||
binding.tvValueRed.text = "${roomPkBean.cAmount}"
|
||||
binding?.ivClose?.setOnClickListener { dismissAllowingStateLoss() }
|
||||
binding?.tvTitleRed?.text = roomPkBean.cNick.subAndReplaceDot(7)
|
||||
binding?.tvValueRed?.text = "${roomPkBean.cAmount}"
|
||||
ImageLoadUtils.loadImage(
|
||||
context,
|
||||
roomPkBean.cAvatar,
|
||||
binding.ivAvatarRed,
|
||||
binding?.ivAvatarRed,
|
||||
R.drawable.default_avatar
|
||||
)
|
||||
|
||||
binding.tvTitleBlue.text = roomPkBean.aNick.subAndReplaceDot(7)
|
||||
binding.tvValueBlue.text = "${roomPkBean.aAmount}"
|
||||
binding?.tvTitleBlue?.text = roomPkBean.aNick.subAndReplaceDot(7)
|
||||
binding?.tvValueBlue?.text = "${roomPkBean.aAmount}"
|
||||
|
||||
ImageLoadUtils.loadImage(
|
||||
context,
|
||||
roomPkBean.aAvatar,
|
||||
binding.ivAvatarBlue,
|
||||
binding?.ivAvatarBlue,
|
||||
R.drawable.default_avatar
|
||||
)
|
||||
|
||||
|
@@ -36,26 +36,26 @@ class SingleRoomPkReceivedDialog : BaseDialog<DialogSingleRoomPkReceivedBinding>
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
binding.tvNick.text = pkBean.inviteRoomTitle.subAndReplaceDot(7)
|
||||
binding.tvTime.text = "${pkBean.pkDuration}分鐘"
|
||||
binding?.tvNick?.text = pkBean.inviteRoomTitle.subAndReplaceDot(7)
|
||||
binding?.tvTime?.text = "${pkBean.pkDuration}分鐘"
|
||||
pkBean.pkDesc.ifNotNullOrEmpty {
|
||||
binding.tvDescTitle.isVisible = true
|
||||
binding.tvDesc.isVisible = true
|
||||
binding.tvDesc.text = it
|
||||
binding?.tvDescTitle?.isVisible = true
|
||||
binding?.tvDesc?.isVisible = true
|
||||
binding?.tvDesc?.text = it
|
||||
}
|
||||
disposable = Observable.intervalRange(0, 10, 0, 1, TimeUnit.SECONDS)
|
||||
.compose(bindToLifecycle())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doOnComplete { dismissAllowingStateLoss() }
|
||||
.subscribe {
|
||||
binding.tvCloseTime.text = "${10 - it}"
|
||||
binding?.tvCloseTime?.text = "${10 - it}"
|
||||
}
|
||||
|
||||
binding.tvReceived.setOnClickListener {
|
||||
binding?.tvReceived?.setOnClickListener {
|
||||
commit(true)
|
||||
}
|
||||
|
||||
binding.tvRefuse.setOnClickListener {
|
||||
binding?.tvRefuse?.setOnClickListener {
|
||||
commit(false)
|
||||
}
|
||||
}
|
||||
|
@@ -17,12 +17,12 @@ class SingleRoomPkRuleDialog : BaseDialog<DialogSingleRoomPkRuleBinding>() {
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
binding.ivClose.setOnClickListener { dismissAllowingStateLoss() }
|
||||
binding.tvContent.movementMethod = ScrollingMovementMethod.getInstance()
|
||||
binding?.ivClose?.setOnClickListener { dismissAllowingStateLoss() }
|
||||
binding?.tvContent?.movementMethod = ScrollingMovementMethod.getInstance()
|
||||
SingleRoomPKModel.getSingleRoomPkRule()
|
||||
.compose(bindToLifecycle())
|
||||
.doOnSuccess {
|
||||
binding.tvContent.text = it.replace("\\n", "\n").replace("\\r", "\r")
|
||||
binding?.tvContent?.text = it.replace("\\n", "\n").replace("\\r", "\r")
|
||||
}
|
||||
.doOnError { it?.message.toast() }
|
||||
.subscribe()
|
||||
|
@@ -4,7 +4,6 @@ import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.graphics.Point;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
@@ -12,9 +11,6 @@ import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
@@ -29,19 +25,14 @@ import com.tencent.qgame.animplayer.AnimView;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.common.widget.CircleImageView;
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadKt;
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.yizhuan.xchat_android_core.bean.RoomQueueInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.GiftModel;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftEffectInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftReceiver;
|
||||
import com.yizhuan.xchat_android_core.initial.InitialModel;
|
||||
import com.yizhuan.xchat_android_core.initial.bean.InitInfo;
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
|
||||
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager;
|
||||
import com.yizhuan.xchat_android_core.manager.RoomEvent;
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil;
|
||||
import com.yizhuan.xchat_android_library.utils.ResolutionUtils;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
@@ -72,9 +63,9 @@ public class GiftEffectView extends RelativeLayout implements SVGACallback {
|
||||
private GiftEffectListener giftEffectListener;
|
||||
private EffectHandler effectHandler;
|
||||
private boolean isAnim;
|
||||
private boolean isPlayAnim;
|
||||
private boolean isHideCarEffect;
|
||||
|
||||
|
||||
public GiftEffectView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
@@ -94,6 +85,10 @@ public class GiftEffectView extends RelativeLayout implements SVGACallback {
|
||||
return isAnim;
|
||||
}
|
||||
|
||||
public boolean isPlayAnim() {
|
||||
return isPlayAnim;
|
||||
}
|
||||
|
||||
public void setGiftEffectListener(GiftEffectListener giftEffectListener) {
|
||||
this.giftEffectListener = giftEffectListener;
|
||||
}
|
||||
@@ -126,60 +121,9 @@ public class GiftEffectView extends RelativeLayout implements SVGACallback {
|
||||
giftInfo = giftEffectInfo.getGift();
|
||||
}
|
||||
if (giftInfo != null) {
|
||||
int totalCoin = giftInfo.getGoldPrice() * giftEffectInfo.getGiftNum() * giftEffectInfo.getTargetUsers().size();
|
||||
if (totalCoin >= 520 &&
|
||||
giftEffectInfo.getGiftReceiveType() != GiftEffectInfo.GIFT_RECEIVE_TYPE_LUCKY
|
||||
&& !AvRoomDataManager.get().isSelfGamePlaying()) {//礼物栏
|
||||
ImageLoadUtils.loadImage(benefactorAvatar.getContext(), giftEffectInfo.getAvatar(), benefactorAvatar);
|
||||
ImageLoadUtils.loadImage(giftImg.getContext(), giftInfo.getGiftUrl(), giftImg);
|
||||
benefactorNick.setText(giftEffectInfo.getNick());
|
||||
giftNumber.setText("X" + giftEffectInfo.getGiftNum());
|
||||
giftName.setText(giftInfo.getGiftName());
|
||||
container.setVisibility(VISIBLE);
|
||||
if (giftEffectInfo.getGiftReceiveType() == GiftEffectInfo.GIFT_RECEIVE_TYPE_SINGLE) {
|
||||
GiftReceiver giftReceiver = giftEffectInfo.getTargetUsers().get(0);
|
||||
ImageLoadUtils.loadAvatar(receiverAvatar.getContext(), giftReceiver.getAvatar(), receiverAvatar);
|
||||
receiverNick.setText(giftReceiver.getNick());
|
||||
} else if (giftEffectInfo.getGiftReceiveType() == GiftEffectInfo.GIFT_RECEIVE_TYPE_ALL) {
|
||||
receiverAvatar.setImageResource(R.drawable.about_logo);
|
||||
receiverNick.setText(ResUtil.getString(R.string.avroom_widget_gifteffectview_01));
|
||||
} else if (giftEffectInfo.getGiftReceiveType() == GiftEffectInfo.GIFT_RECEIVE_TYPE_MULTI) {
|
||||
receiverAvatar.setImageResource(R.drawable.about_logo);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (GiftReceiver targetUser : giftEffectInfo.getTargetUsers()) {
|
||||
RoomQueueInfo roomQueueInfo = AvRoomDataManager.get().getRoomQueueMemberInfoByAccount(targetUser.getUid() + "");
|
||||
if (roomQueueInfo == null) continue;
|
||||
sb.append(roomQueueInfo.mRoomMicInfo.getPosition() + 1).append(ResUtil.getString(R.string.avroom_widget_gifteffectview_02)).append(",");
|
||||
}
|
||||
if (sb.length() > 0) {
|
||||
sb.replace(sb.lastIndexOf(","), sb.length(), "");
|
||||
}
|
||||
receiverNick.setText(sb.toString());
|
||||
}
|
||||
|
||||
Animation operatingAnim = AnimationUtils.loadAnimation(getContext(), R.anim.light_bg_rotate_anim);
|
||||
LinearInterpolator lin = new LinearInterpolator();
|
||||
operatingAnim.setInterpolator(lin);
|
||||
giftLightBg.setAnimation(operatingAnim);
|
||||
|
||||
final Point center = new Point();
|
||||
center.x = ResolutionUtils.getScreenWidth(getContext()) / 2;
|
||||
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(container, "translationX", -UIUtil.dip2px(getContext(), 400), center.x - container.getWidth() / 2).setDuration(500);
|
||||
objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
|
||||
objectAnimator.start();
|
||||
|
||||
ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(container, "alpha", 0.0F, 1.0F).setDuration(500);
|
||||
objectAnimator1.setInterpolator(new AccelerateDecelerateInterpolator());
|
||||
objectAnimator1.start();
|
||||
if (totalCoin < 4999) {
|
||||
imgBg.setImageResource(R.drawable.icon_gift_effect_bg_1);
|
||||
} else if (totalCoin < 9999) {
|
||||
imgBg.setImageResource(R.drawable.icon_gift_effect_bg_2);
|
||||
} else {
|
||||
imgBg.setImageResource(R.drawable.icon_gift_effect_bg_3);
|
||||
}
|
||||
}
|
||||
effectHandler.sendEmptyMessageDelayed(0, 6000);
|
||||
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())) {
|
||||
@@ -209,7 +153,7 @@ public class GiftEffectView extends RelativeLayout implements SVGACallback {
|
||||
svgaImageView.setImageDrawable(drawable);
|
||||
svgaImageView.startAnimation();
|
||||
svgaBg.setVisibility(VISIBLE);
|
||||
ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(svgaBg, "alpha", 0.0F, 2.0F).setDuration(800);
|
||||
ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(svgaBg, "alpha", 0.0F, 2.0F).setDuration(1250);
|
||||
objectAnimator1.setInterpolator(new AccelerateDecelerateInterpolator());
|
||||
objectAnimator1.start();
|
||||
}
|
||||
@@ -230,11 +174,11 @@ public class GiftEffectView extends RelativeLayout implements SVGACallback {
|
||||
}
|
||||
|
||||
private void deleteAnim() {
|
||||
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(container, "translationX", container.getX(), ResolutionUtils.getScreenWidth(getContext())).setDuration(500);
|
||||
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(500);
|
||||
ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(container, "alpha", 1.0F, 0.0F).setDuration(1250);
|
||||
objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
|
||||
objectAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
@@ -246,6 +190,7 @@ public class GiftEffectView extends RelativeLayout implements SVGACallback {
|
||||
}
|
||||
if (giftEffectListener != null) {
|
||||
isAnim = false;
|
||||
isPlayAnim = false;
|
||||
giftEffectListener.onGiftEffectEnd();
|
||||
}
|
||||
}
|
||||
|
@@ -9,9 +9,7 @@ import android.animation.ValueAnimator;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PathMeasure;
|
||||
import android.graphics.Point;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
@@ -36,7 +34,6 @@ import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.common.svga.SimpleSvgaParseCompletion;
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
import com.yizhuan.xchat_android_core.fansteam.FansTeamMsgInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.GiftModel;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftEffectInfo;
|
||||
@@ -53,9 +50,6 @@ import com.yizhuan.xchat_android_core.magic.bean.MagicInfo;
|
||||
import com.yizhuan.xchat_android_core.magic.bean.MagicReceivedInfo;
|
||||
import com.yizhuan.xchat_android_core.magic.bean.MultiMagicReceivedInfo;
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
|
||||
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager;
|
||||
import com.yizhuan.xchat_android_core.manager.RoomEvent;
|
||||
import com.yizhuan.xchat_android_core.monsterhunting.bean.MonsterAttackInfo;
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil;
|
||||
import com.yizhuan.xchat_android_library.utils.ResolutionUtils;
|
||||
@@ -65,9 +59,7 @@ import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -98,8 +90,6 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
private Keyframe[] keyScale;
|
||||
private Keyframe[] keyTrans;
|
||||
private SvgaObjectPool mMagicViewPool;
|
||||
private volatile Hashtable<Integer, MonsterAttackInfo> currentAnimationMap = new Hashtable<>();
|
||||
|
||||
|
||||
public GiftV2View(Context context) {
|
||||
this(context, null);
|
||||
@@ -301,26 +291,33 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
}
|
||||
}
|
||||
|
||||
private void drawLuckyGift(GiftReceiveInfo giftReceiveInfos, int giftReceiveType, boolean isShowAnimation, String svgaUrl) {
|
||||
private void drawLuckyGift(GiftReceiveInfo giftReceiveInfos, int giftReceiveType, boolean isShowAnimation, String svgaUrl, int pos) {
|
||||
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (roomInfo != null) {
|
||||
List<GiftReceiver> targetUsers = new ArrayList<>();
|
||||
int totalCoin = 0;
|
||||
|
||||
boolean isPlaySvga = false;
|
||||
if (AvRoomDataManager.get().mIsNeedGiftEffect &&
|
||||
!AvRoomDataManager.get().isSelfGamePlaying()) {
|
||||
SVGAImageView imageView = playLuckyBagAnim(svgaUrl);
|
||||
handler.postDelayed(() -> {
|
||||
removeView(imageView);
|
||||
imageView.stopAnimation(true);
|
||||
}, 1800);
|
||||
if (svgaUrl != null && !svgaUrl.isEmpty()) {
|
||||
isPlaySvga = true;
|
||||
SVGAImageView imageView = playLuckyBagAnim(svgaUrl);
|
||||
handler.postDelayed(() -> {
|
||||
removeView(imageView);
|
||||
imageView.stopAnimation(true);
|
||||
}, 1800);
|
||||
}
|
||||
}
|
||||
|
||||
handler.postDelayed(() -> drawLuckyGiftAnimation(roomInfo, giftReceiveInfos, totalCoin, targetUsers, giftReceiveType, isShowAnimation), 1200);
|
||||
if (isPlaySvga) {
|
||||
handler.postDelayed(() -> drawLuckyGiftAnimation(roomInfo, giftReceiveInfos, totalCoin, targetUsers, giftReceiveType, isShowAnimation, pos), 1200);
|
||||
} else {
|
||||
drawLuckyGiftAnimation(roomInfo, giftReceiveInfos, totalCoin, targetUsers, giftReceiveType, isShowAnimation, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void drawLuckyGiftAnimation(RoomInfo roomInfo, GiftReceiveInfo giftReceiveInfo, int totalCoin, List<GiftReceiver> targetUsers, int giftReceiveType, boolean isShowAnimation) {
|
||||
private void drawLuckyGiftAnimation(RoomInfo roomInfo, GiftReceiveInfo giftReceiveInfo, int totalCoin, List<GiftReceiver> targetUsers, int giftReceiveType, boolean isShowAnimation, int pos) {
|
||||
SparseArray<Point> micViewPoint = AvRoomDataManager.get().mMicPointMap;
|
||||
GiftInfo giftInfo = GiftModel.get().findGiftInfoById(giftReceiveInfo.getGiftId());
|
||||
if (giftInfo == null || TextUtils.isEmpty(giftInfo.getGiftUrl())) {
|
||||
@@ -363,22 +360,21 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
giftReceiver.setNick(giftReceiveInfo.getTargetNick());
|
||||
targetUsers.add(giftReceiver);
|
||||
if (!isShowAnimation) return;
|
||||
giftInfo = giftReceiveInfo.getDisplayGift().get(0);
|
||||
if (totalCoin >= 520 || (giftInfo != null && giftInfo.isHasEffect())) {
|
||||
giftInfo = giftReceiveInfo.getDisplayGift().get(pos);
|
||||
if (giftInfo != null && giftInfo.isHasEffect()) {
|
||||
Message msg = Message.obtain();
|
||||
msg.what = 0;
|
||||
GiftEffectInfo giftEffectInfo = new GiftEffectInfo();
|
||||
giftEffectInfo.setUid(giftReceiveInfo.getUid());
|
||||
giftEffectInfo.setNick(giftReceiveInfo.getNick());
|
||||
giftEffectInfo.setAvatar(giftReceiveInfo.getAvatar());
|
||||
giftEffectInfo.setGiftId(giftReceiveInfo.getDisplayGift().get(0).getGiftId());
|
||||
giftEffectInfo.setGiftId(giftReceiveInfo.getDisplayGift().get(pos).getGiftId());
|
||||
giftEffectInfo.setGiftNum(giftReceiveInfo.getGiftNum());
|
||||
giftEffectInfo.setGift(giftInfo);
|
||||
giftEffectInfo.setTargetUsers(targetUsers);
|
||||
giftEffectInfo.setGiftReceiveType(giftReceiveType);
|
||||
msg.obj = giftEffectInfo;
|
||||
handler.sendMessageDelayed(msg, 200);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,25 +431,24 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
}
|
||||
|
||||
public void onReceiveLuckyGiftToMultiMsg(LuckyBagGifts giftMultiReceiverInfo) {
|
||||
|
||||
|
||||
if (giftMultiReceiverInfo != null) {
|
||||
setVisibility(VISIBLE);
|
||||
// List<GiftReceiveInfo> giftReceiveInfos = new ArrayList<>();
|
||||
GiftReceiveInfo giftReceiveInfo = new GiftReceiveInfo();
|
||||
giftReceiveInfo.setUid(giftMultiReceiverInfo.getUid());
|
||||
giftReceiveInfo.setTargetNick(giftMultiReceiverInfo.getUser().getNick());
|
||||
giftReceiveInfo.setTargetUid(giftMultiReceiverInfo.getUser().getUid());
|
||||
giftReceiveInfo.setGiftNum(giftMultiReceiverInfo.getGiftNum());
|
||||
giftReceiveInfo.setDisplayGift(giftMultiReceiverInfo.getDisplayGift());
|
||||
giftReceiveInfo.setNick(giftMultiReceiverInfo.getNick());
|
||||
giftReceiveInfo.setGiftId(giftMultiReceiverInfo.getGiftList().get(0).getGiftId());
|
||||
giftReceiveInfo.setGift(giftMultiReceiverInfo.getDisplayGift().get(0));
|
||||
//礼物值
|
||||
giftReceiveInfo.setGiftValueVos(giftMultiReceiverInfo.getGiftValueVos());
|
||||
giftReceiveInfo.setCurrentTime(giftMultiReceiverInfo.getCurrentTime());
|
||||
// giftReceiveInfos.add(giftReceiveInfo);
|
||||
drawLuckyGift(giftReceiveInfo, GiftEffectInfo.GIFT_RECEIVE_TYPE_LUCKY, giftMultiReceiverInfo.isShowAnimation(), giftMultiReceiverInfo.getLuckyGiftSvgaUrl());
|
||||
int size = Math.min(giftMultiReceiverInfo.getDisplayGift().size(), 6);
|
||||
for (int i = 0; i < size; i++) {
|
||||
GiftReceiveInfo giftReceiveInfo = new GiftReceiveInfo();
|
||||
giftReceiveInfo.setUid(giftMultiReceiverInfo.getUid());
|
||||
giftReceiveInfo.setTargetNick(giftMultiReceiverInfo.getUser().getNick());
|
||||
giftReceiveInfo.setTargetUid(giftMultiReceiverInfo.getUser().getUid());
|
||||
giftReceiveInfo.setGiftNum(giftMultiReceiverInfo.getGiftNum());
|
||||
giftReceiveInfo.setDisplayGift(giftMultiReceiverInfo.getDisplayGift());
|
||||
giftReceiveInfo.setNick(giftMultiReceiverInfo.getNick());
|
||||
giftReceiveInfo.setGiftId(giftMultiReceiverInfo.getGiftList().get(0).getGiftId());
|
||||
giftReceiveInfo.setGift(giftMultiReceiverInfo.getDisplayGift().get(i));
|
||||
//礼物值
|
||||
giftReceiveInfo.setGiftValueVos(giftMultiReceiverInfo.getGiftValueVos());
|
||||
giftReceiveInfo.setCurrentTime(giftMultiReceiverInfo.getCurrentTime());
|
||||
drawLuckyGift(giftReceiveInfo, GiftEffectInfo.GIFT_RECEIVE_TYPE_LUCKY, giftMultiReceiverInfo.isShowAnimation(), giftMultiReceiverInfo.getLuckyGiftSvgaUrl(), i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -471,13 +466,6 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
return magicInfo.getPathAnim();
|
||||
}
|
||||
|
||||
// private boolean isCenter(MonsterAttackReceiveInfo monsterAttackReceiveInfo) {
|
||||
// int magicId = Integer.parseInt(monsterAttackReceiveInfo.getMagicId());
|
||||
// MagicInfo magicInfo = MagicModel.get().getMagicInfo(magicId);
|
||||
// if (magicInfo == null) return monsterAttackReceiveInfo.getPosition() == MagicInfo.POS_CENTER;
|
||||
// return magicInfo.getPosition() == MagicInfo.POS_CENTER;
|
||||
// }
|
||||
|
||||
private String getValidExplodeAnimationUrl(int magicId, String url) {
|
||||
if (!TextUtils.isEmpty(url)) return url;
|
||||
MagicInfo magicInfo = MagicModel.get().getMagicInfo(magicId);
|
||||
@@ -497,13 +485,6 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
drawMagicAnimation(magicReceivedInfos);
|
||||
}
|
||||
|
||||
public void onReceiveMonsterAttackMsg(MonsterAttackInfo monsterAttackReceiveInfo, View monsterView) {
|
||||
drawMonsterMagicView(monsterAttackReceiveInfo, monsterView);
|
||||
// List<MonsterAttackInfo> monsterAttackReceiveInfos = new ArrayList<>();
|
||||
// monsterAttackReceiveInfos.add(monsterAttackReceiveInfo);
|
||||
// drawMonsterAttackAnimation(monsterAttackReceiveInfos, monsterView);
|
||||
}
|
||||
|
||||
public void onReceiveMultiMagicMsg(MultiMagicReceivedInfo multiMagicReceivedInfo) {
|
||||
if (multiMagicReceivedInfo != null) {
|
||||
setVisibility(VISIBLE);
|
||||
@@ -576,70 +557,12 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
}
|
||||
|
||||
/**
|
||||
* 打怪兽时使用的动画效果
|
||||
* 获取当前是否有飘屏正在显示
|
||||
*
|
||||
* @param monsterAttackReceiveInfo
|
||||
* @param monsterView
|
||||
* @return
|
||||
*/
|
||||
private void drawMonsterMagicView(MonsterAttackInfo monsterAttackReceiveInfo, View monsterView) {
|
||||
Point senderPoint = null;
|
||||
if (Objects.equals(Long.valueOf(monsterAttackReceiveInfo.getUid()), AuthModel.get().getCurrentUid())) {
|
||||
senderPoint = new Point(mScreenWidth - giftWidth, mScreenHeight - UIUtil.dip2px(context, 50));
|
||||
} else {
|
||||
senderPoint = new Point(new Random().nextInt(mScreenWidth), mScreenHeight);
|
||||
}
|
||||
SVGAImageView imageView = mMagicViewPool.borrowGiftObject(senderPoint);
|
||||
imageView.setVisibility(GONE);
|
||||
ImageLoadUtils.loadImage(context, monsterAttackReceiveInfo.getMagicIcon(), imageView);
|
||||
int[] location = new int[2];
|
||||
monsterView.getLocationInWindow(location);
|
||||
int x = (location[0] + monsterView.getWidth() / 2) - giftWidth / 2;
|
||||
int y = (location[1] + monsterView.getHeight() / 2) - giftHeight / 2;
|
||||
Point receivePoint = new Point(x, y);
|
||||
|
||||
Path path = getBezierCurvePath(senderPoint, receivePoint, false);
|
||||
ValueAnimator pathAnimator;
|
||||
// 当前版本小于21,需要
|
||||
if (Build.VERSION_CODES.LOLLIPOP > Build.VERSION.SDK_INT) {
|
||||
pathAnimator = ObjectAnimator.ofFloat(0.0f, 1.0f);
|
||||
pathAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
float[] point = new float[2];
|
||||
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
float val = animation.getAnimatedFraction();
|
||||
PathMeasure pathMeasure = new PathMeasure(path, false);
|
||||
pathMeasure.getPosTan(pathMeasure.getLength() * val, point, null);
|
||||
imageView.setTranslationX(point[0]);
|
||||
imageView.setTranslationY(point[1]);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
pathAnimator = ObjectAnimator.ofFloat(imageView, View.TRANSLATION_X, View.TRANSLATION_Y, path);
|
||||
}
|
||||
pathAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
imageView.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mMagicViewPool.returnObject(imageView);
|
||||
currentAnimationMap.remove(monsterAttackReceiveInfo.getSequence());
|
||||
IMNetEaseManager.get().getChatRoomEventObservable().onNext(new RoomEvent()
|
||||
.setEvent(RoomEvent.MONSTER_HUNTING_ANIMATION_FINISHED)
|
||||
.setMonsterAttackReceiveInfo(monsterAttackReceiveInfo));
|
||||
}
|
||||
});
|
||||
pathAnimator.setDuration(1000);
|
||||
currentAnimationMap.put(monsterAttackReceiveInfo.getSequence(), monsterAttackReceiveInfo);
|
||||
if (currentAnimationMap.size() >= 10) {
|
||||
postDelayed(pathAnimator::start, 500);
|
||||
} else {
|
||||
pathAnimator.start();
|
||||
}
|
||||
public boolean getIsPlayAnim() {
|
||||
return giftEffectView.isPlayAnim();
|
||||
}
|
||||
|
||||
private void drawMagicView(Point senderPoint, Point receivePoint, MagicReceivedInfo magicReceivedInfo) {
|
||||
@@ -675,24 +598,8 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
Path path = getBezierCurvePath(senderPoint, receivePoint, isCenter(magicReceivedInfo));
|
||||
ValueAnimator pathAnimator;
|
||||
// 当前版本小于21,需要
|
||||
if (Build.VERSION_CODES.LOLLIPOP > Build.VERSION.SDK_INT) {
|
||||
pathAnimator = ObjectAnimator.ofFloat(0.0f, 1.0f);
|
||||
pathAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
float[] point = new float[2];
|
||||
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
float val = animation.getAnimatedFraction();
|
||||
PathMeasure pathMeasure = new PathMeasure(path, false);
|
||||
pathMeasure.getPosTan(pathMeasure.getLength() * val, point, null);
|
||||
imageView.setTranslationX(point[0]);
|
||||
imageView.setTranslationY(point[1]);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
pathAnimator = ObjectAnimator.ofFloat(imageView, View.TRANSLATION_X, View.TRANSLATION_Y, path);
|
||||
}
|
||||
pathAnimator.setDuration(1000);
|
||||
pathAnimator = ObjectAnimator.ofFloat(imageView, View.TRANSLATION_X, View.TRANSLATION_Y, path);
|
||||
pathAnimator.setDuration(1250);
|
||||
pathAnimator.start();
|
||||
}
|
||||
|
||||
@@ -754,7 +661,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
PropertyValuesHolder p2 = PropertyValuesHolder.ofKeyframe("scaleX", keyScale);
|
||||
PropertyValuesHolder p3 = PropertyValuesHolder.ofKeyframe("scaleY", keyScale);
|
||||
ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(imageView, p2, p3, p1, p0);
|
||||
objectAnimator.setDuration(3200);
|
||||
objectAnimator.setDuration(4000);
|
||||
objectAnimator.start();
|
||||
objectAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
@@ -898,10 +805,6 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
if (mImageView == null) return;
|
||||
mImageView.stopAnimation(true);
|
||||
giftV2View.mMagicViewPool.returnObject(mImageView);
|
||||
// ViewParent parent = this.mImageView.getParent();
|
||||
// if (parent != null && parent instanceof ViewGroup) {
|
||||
// ((ViewGroup) parent).removeView(mImageView);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -911,10 +814,6 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
if (mImageView == null) return;
|
||||
mImageView.stopAnimation(true);
|
||||
giftV2View.mMagicViewPool.returnObject(mImageView);
|
||||
// ViewParent parent = this.mImageView.getParent();
|
||||
// if (parent != null && parent instanceof ViewGroup) {
|
||||
// ((ViewGroup) parent).removeViewInLayout(mImageView);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -3,6 +3,7 @@ package com.yizhuan.erban.avroom.widget;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAIRY;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GIFT_COMPOUND;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_RED_PACKAGE;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ROOM_ALBUM;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ME;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_CONVERT_L1;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_CONVERT_L2;
|
||||
@@ -23,6 +24,7 @@ import static com.yizhuan.xchat_android_core.redpackage.RedPackageTypeKt.ROOM_DI
|
||||
import static com.yizhuan.xchat_android_core.redpackage.RedPackageTypeKt.ROOM_GIFT;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
@@ -42,6 +44,7 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -52,6 +55,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.SimpleItemAnimator;
|
||||
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
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;
|
||||
@@ -59,6 +63,7 @@ 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.MsgAttachment;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
|
||||
import com.netease.nimlib.sdk.msg.constant.NotificationType;
|
||||
import com.netease.nimlib.sdk.msg.model.IMMessage;
|
||||
@@ -67,13 +72,18 @@ import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.UIHelper;
|
||||
import com.yizhuan.erban.avroom.activity.AVRoomActivity;
|
||||
import com.yizhuan.erban.avroom.dialog.PKResultDialog;
|
||||
import com.yizhuan.erban.avroom.room_album.UnlockRoomAlbumPhotoDialog;
|
||||
import com.yizhuan.erban.common.util.Utils;
|
||||
import com.yizhuan.erban.common.widget.CustomAutoWidthImageSpan;
|
||||
import com.yizhuan.erban.common.widget.CustomImageSpan;
|
||||
import com.yizhuan.erban.common.widget.OriginalDrawStatusClickSpan;
|
||||
import com.yizhuan.erban.community.photo.BigPhotoActivity;
|
||||
import com.yizhuan.erban.community.photo.PagerOption;
|
||||
import com.yizhuan.erban.community.utils.ObjectTypeHelper;
|
||||
import com.yizhuan.erban.treasure_box.widget.GoldBoxHelper;
|
||||
import com.yizhuan.erban.treasurefairy.HomeFairyActivity;
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2;
|
||||
import com.yizhuan.erban.ui.widget.DividerItemDecoration;
|
||||
import com.yizhuan.erban.ui.widget.MyItemAnimator;
|
||||
import com.yizhuan.erban.ui.widget.RecyclerViewNoViewpagerScroll;
|
||||
@@ -93,6 +103,7 @@ import com.yizhuan.xchat_android_core.gift.bean.GiftReceiveInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftReceiver;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagGifts;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagNoticeInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.toolbox.GiftToolbox;
|
||||
import com.yizhuan.xchat_android_core.helper.ImHelperUtils;
|
||||
import com.yizhuan.xchat_android_core.home.event.FollowRoomEvent;
|
||||
import com.yizhuan.xchat_android_core.home.model.CollectionRoomModel;
|
||||
@@ -119,16 +130,20 @@ import com.yizhuan.xchat_android_core.im.custom.bean.MultiGiftAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.MultiLuckyGiftAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.NobleAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RedPackageRoomMsgAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomAlbumAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomAlbumMsgInfo;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomFollowOwnerAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomFollowOwnerAttachment2;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomLuckySeaAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomLuckySeaMsgBean;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomNoticeAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomPhoto;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomReceivedLuckyGiftAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomTipAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.TarotAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.TarotMsgBean;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.User;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.VipMessageAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.WelcomeAttachment;
|
||||
import com.yizhuan.xchat_android_core.level.UserLevelResourceType;
|
||||
@@ -162,7 +177,7 @@ import com.yizhuan.xchat_android_core.room.pk.bean.RoomPKInvitedUpMicMember;
|
||||
import com.yizhuan.xchat_android_core.room.pk.bean.RoomPkData;
|
||||
import com.yizhuan.xchat_android_core.room.queuing_mic.attachment.QueuingMicAttachment;
|
||||
import com.yizhuan.xchat_android_core.room.queuing_mic.bean.QueuingMicInfo;
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.FairyMsgInfo;
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.FairyMsgInfoBean;
|
||||
import com.yizhuan.xchat_android_core.user.UserModel;
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfo;
|
||||
import com.yizhuan.xchat_android_core.utils.ExtensionUtil;
|
||||
@@ -296,9 +311,9 @@ public class MessageView extends FrameLayout {
|
||||
sysIconHeight = Utils.dip2px(context, 14);
|
||||
smallFace = Utils.dip2px(context, 22);
|
||||
bigFace = Utils.dip2px(context, 30);
|
||||
//經驗等級圖片後臺已經更換尺寸了,公屏同步下,尺寸是26:20
|
||||
expLevelHeight = Utils.dip2px(context, 20);
|
||||
expLevelWidth = expLevelHeight * 26 / 20;//expLevelHeight * 114 / 45
|
||||
//經驗等級圖片後臺已經更換尺寸了,公屏同步下,尺寸是36:18
|
||||
expLevelHeight = Utils.dip2px(context, 18);
|
||||
expLevelWidth = expLevelHeight * 36 / 18;//expLevelHeight * 114 / 45
|
||||
giftLength = Utils.dip2px(context, 35);
|
||||
// 內容區域
|
||||
layoutManger = new LinearLayoutManager(context, RecyclerView.VERTICAL, false);
|
||||
@@ -735,8 +750,28 @@ public class MessageView extends FrameLayout {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
ChatRoomMessage chatRoomMessage = data.get(position);
|
||||
if (chatRoomMessage.getMsgType() == MsgTypeEnum.custom) {
|
||||
MsgAttachment attachment = chatRoomMessage.getAttachment();
|
||||
if (attachment instanceof CustomAttachment) {
|
||||
if (((CustomAttachment) attachment).getFirst() == CustomAttachment.CUSTOM_MSG_ROOM_ALBUM) {
|
||||
return CustomAttachment.CUSTOM_MSG_ROOM_ALBUM;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.getItemViewType(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if (viewType == CustomAttachment.CUSTOM_MSG_ROOM_ALBUM) {
|
||||
return new MessageViewHolder(LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.layout_msg_view_holder_room_album, parent, false));
|
||||
|
||||
}
|
||||
return new MessageViewHolder(LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.list_item_chatrrom_msg, parent, false));
|
||||
}
|
||||
@@ -995,6 +1030,8 @@ public class MessageView extends FrameLayout {
|
||||
setGiftCompoundMsg(chatRoomMessage, tvContent);
|
||||
} else if (first == CUSTOM_MSG_FAIRY) {
|
||||
setFairyMsg(chatRoomMessage, tvContent);
|
||||
} else if (first == CUSTOM_MSG_ROOM_ALBUM) {
|
||||
setRoomAlbumMsg(chatRoomMessage, baseViewHolder);
|
||||
} else {
|
||||
tvContent.setTextColor(Color.WHITE);
|
||||
tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip));
|
||||
@@ -1008,10 +1045,107 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
|
||||
private void setRoomAlbumMsg(ChatRoomMessage chatRoomMessage, MessageViewHolder baseViewHolder) {
|
||||
RoomAlbumAttachment attachment = (RoomAlbumAttachment) chatRoomMessage.getAttachment();
|
||||
RoomAlbumMsgInfo mRoomAlbumMsgInfo = attachment.getMRoomAlbumMsgInfo();
|
||||
|
||||
if (mRoomAlbumMsgInfo == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
RoomPhoto roomPhoto = mRoomAlbumMsgInfo.getRoomPhoto();
|
||||
User user = mRoomAlbumMsgInfo.getUser();
|
||||
boolean isMyself = UserModel.get().isMyseft(user.getUid());
|
||||
|
||||
ImageView ivUserLevel = baseViewHolder.itemView.findViewById(R.id.iv_user_level);
|
||||
ImageView ivUserCharm = baseViewHolder.itemView.findViewById(R.id.iv_user_charm);
|
||||
ImageView ivPhoto = baseViewHolder.itemView.findViewById(R.id.iv_photo);
|
||||
ImageView ivGift = baseViewHolder.itemView.findViewById(R.id.iv_gift);
|
||||
ImageView ivDiamond = baseViewHolder.itemView.findViewById(R.id.iv_diamond);
|
||||
TextView tvNick = baseViewHolder.itemView.findViewById(R.id.tv_nick);
|
||||
TextView tvValue = baseViewHolder.itemView.findViewById(R.id.tv_value);
|
||||
TextView tvUnlock = baseViewHolder.itemView.findViewById(R.id.tv_unlock);
|
||||
View vBottomMask = baseViewHolder.itemView.findViewById(R.id.v_bottom_mask);
|
||||
|
||||
ImageLoadUtilsV2.loadImage2(ivUserLevel, mRoomAlbumMsgInfo.getUserLevel().getExperUrl(), Target.SIZE_ORIGINAL);
|
||||
ImageLoadUtilsV2.loadImage2(ivUserCharm, mRoomAlbumMsgInfo.getUserLevel().getCharmUrl(), Target.SIZE_ORIGINAL);
|
||||
tvNick.setText(user.getNick());
|
||||
tvUnlock.setText("解鎖");
|
||||
tvUnlock.setBackgroundResource(R.drawable.bg_9168fa_6);
|
||||
|
||||
if (roomPhoto.getType() == 1) {
|
||||
vBottomMask.setVisibility(View.INVISIBLE);
|
||||
ivGift.setVisibility(View.INVISIBLE);
|
||||
ivDiamond.setVisibility(View.INVISIBLE);
|
||||
tvValue.setVisibility(View.INVISIBLE);
|
||||
tvUnlock.setVisibility(View.INVISIBLE);
|
||||
ImageLoadUtilsV2.loadImage(ivPhoto, roomPhoto.getPhotoUrl());
|
||||
} else {
|
||||
vBottomMask.setVisibility(View.VISIBLE);
|
||||
ivGift.setVisibility(View.VISIBLE);
|
||||
ivDiamond.setVisibility(View.VISIBLE);
|
||||
tvValue.setVisibility(View.VISIBLE);
|
||||
tvUnlock.setVisibility(View.VISIBLE);
|
||||
|
||||
if (isMyself) {
|
||||
tvUnlock.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
if (isMyself || hadUnlock(roomPhoto.getId())) {
|
||||
ImageLoadUtilsV2.loadImage(ivPhoto, roomPhoto.getPhotoUrl());
|
||||
tvUnlock.setText("已解鎖");
|
||||
tvUnlock.setBackgroundResource(R.drawable.bg_9e9ea8_6);
|
||||
} else {
|
||||
ImageLoadUtils.loadImageWithBlur(mContext, roomPhoto.getPhotoUrl(), ivPhoto, 25, 4);
|
||||
}
|
||||
|
||||
ImageLoadUtilsV2.loadImage(ivGift, roomPhoto.getGiftUrl());
|
||||
tvValue.setText(String.valueOf(roomPhoto.getTotalGoldPrice()));
|
||||
}
|
||||
|
||||
ivPhoto.setOnClickListener(v -> {
|
||||
if (roomPhoto.getType() == 2 && !isMyself && !hadUnlock(roomPhoto.getId())) {
|
||||
unlockRoomPhoto(baseViewHolder.getAbsoluteAdapterPosition(), roomPhoto);
|
||||
return;
|
||||
}
|
||||
|
||||
BigPhotoActivity.start((Activity) mContext, ObjectTypeHelper.pathToCustomItems(roomPhoto.getPhotoUrl()),
|
||||
0, new PagerOption());
|
||||
});
|
||||
|
||||
baseViewHolder.itemView.setOnClickListener(v -> {
|
||||
if (roomPhoto.getType() == 2 && !isMyself && !hadUnlock(roomPhoto.getId())) {
|
||||
unlockRoomPhoto(baseViewHolder.getAbsoluteAdapterPosition(), roomPhoto);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
tvUnlock.setOnClickListener(v -> unlockRoomPhoto(baseViewHolder.getAbsoluteAdapterPosition(), roomPhoto));
|
||||
}
|
||||
|
||||
private void unlockRoomPhoto(int position, RoomPhoto roomPhoto) {
|
||||
UnlockRoomAlbumPhotoDialog unlockRoomAlbumPhotoDialog = UnlockRoomAlbumPhotoDialog.Companion
|
||||
.newInstance(roomPhoto.getId(), roomPhoto.getGiftUrl(), roomPhoto.getGiftName(), roomPhoto.getTotalGoldPrice());
|
||||
unlockRoomAlbumPhotoDialog.setOnUnlockRoomPhotoListener(giftReceiveInfo -> {
|
||||
giftReceiveInfo.setRoomAlbum(true);
|
||||
GiftToolbox.sendGiftRoomMessage(giftReceiveInfo);
|
||||
|
||||
AvRoomDataManager.get().addUnlockedRoomAlbumPhoto(roomPhoto.getId());
|
||||
notifyItemChanged(position);
|
||||
});
|
||||
unlockRoomAlbumPhotoDialog.show(mContext);
|
||||
|
||||
}
|
||||
|
||||
private boolean hadUnlock(int photoId) {
|
||||
List<Integer> unlockedIds= AvRoomDataManager.get().getUnlockedRoomAlbumPhotos();
|
||||
return unlockedIds.contains(photoId);
|
||||
}
|
||||
|
||||
private void setFairyMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) {
|
||||
if (chatRoomMessage.getAttachment() instanceof FairyMsgAttachment) {
|
||||
FairyMsgAttachment attachment = (FairyMsgAttachment) chatRoomMessage.getAttachment();
|
||||
FairyMsgInfo fairyMsgInfo = attachment.getFairyMsgInfo();
|
||||
FairyMsgInfoBean fairyMsgInfo = attachment.getFairyMsgInfo();
|
||||
if (fairyMsgInfo == null) return;
|
||||
SpannableBuilder builder = null;
|
||||
switch (attachment.getSecond()) {
|
||||
@@ -1055,7 +1189,7 @@ public class MessageView extends FrameLayout {
|
||||
|
||||
}
|
||||
|
||||
private SpannableBuilder builderConvertMsg(TextView textView, @NonNull FairyMsgInfo fairyMsgInfo, String type) {
|
||||
private SpannableBuilder builderConvertMsg(TextView textView, @NonNull FairyMsgInfoBean fairyMsgInfo, String type) {
|
||||
return new SpannableBuilder(textView)
|
||||
.append("厲害了!", new ForegroundColorSpan(whiteColor))
|
||||
.append(StringExtensionKt.subAndReplaceDot(fairyMsgInfo.getNick(), 7), new OriginalDrawStatusClickSpan(roomTipNickColor, false) {
|
||||
@@ -1069,7 +1203,7 @@ public class MessageView extends FrameLayout {
|
||||
.append(fairyMsgInfo.getRewardShowValue() + "鉆" + fairyMsgInfo.getRewardName(), new ForegroundColorSpan(roomTipColor));
|
||||
}
|
||||
|
||||
private SpannableBuilder builderDrawMsg(TextView textView, @NonNull FairyMsgInfo fairyMsgInfo, String desc) {
|
||||
private SpannableBuilder builderDrawMsg(TextView textView, @NonNull FairyMsgInfoBean fairyMsgInfo, String desc) {
|
||||
SpannableBuilder builder = new SpannableBuilder(textView)
|
||||
.append(desc, new ForegroundColorSpan(whiteColor))
|
||||
.append(StringExtensionKt.subAndReplaceDot(fairyMsgInfo.getNick(), 7), new OriginalDrawStatusClickSpan(roomTipNickColor, false) {
|
||||
@@ -1310,15 +1444,26 @@ public class MessageView extends FrameLayout {
|
||||
|
||||
private void setTarotMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) {
|
||||
TarotAttachment attachment = (TarotAttachment) chatRoomMessage.getAttachment();
|
||||
if (attachment.getSecond() == CustomAttachment.CUSTOM_MESS_TAROT_SUCCESS) {
|
||||
TarotMsgBean tarotMsgBean = attachment.getTarotMsgBean();
|
||||
String nickName = RegexUtil.getPrintableString(tarotMsgBean.getNick());
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_026), new ForegroundColorSpan(textColor))
|
||||
.append(nickName, new ForegroundColorSpan(roomTipNickColor))
|
||||
.append(" " + tarotMsgBean.getDrawMsgText(), new ForegroundColorSpan(textColor))
|
||||
.append(tarotMsgBean.getDrawGoldNum() + ResUtil.getString(R.string.avroom_widget_messageview_027), new ForegroundColorSpan(roomTipColor));
|
||||
tvContent.setText(text.build());
|
||||
TarotMsgBean tarotMsgBean = attachment.getTarotMsgBean();
|
||||
String nickName = RegexUtil.getPrintableString(tarotMsgBean.getNick());
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent);
|
||||
switch (attachment.getSecond()) {
|
||||
case CustomAttachment.CUSTOM_MESS_TAROT_SUCCESS:
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_026), new ForegroundColorSpan(textColor))
|
||||
.append(nickName, new ForegroundColorSpan(roomTipNickColor))
|
||||
.append(" " + tarotMsgBean.getDrawMsgText(), new ForegroundColorSpan(textColor))
|
||||
.append(tarotMsgBean.getDrawGoldNum() + ResUtil.getString(R.string.avroom_widget_messageview_027), new ForegroundColorSpan(roomTipColor));
|
||||
tvContent.setText(text.build());
|
||||
break;
|
||||
case CustomAttachment.CUSTOM_MESS_TAROT_JUNIOR_PRIZE_WINNING:
|
||||
case CustomAttachment.CUSTOM_MESS_TAROT_INTERMEDIATE_PRIZE_WINNING:
|
||||
case CustomAttachment.CUSTOM_MESS_TAROT_SENIOR_PRIZE_WINNING:
|
||||
text.append(ResUtil.getString(R.string.avroom_widget_messageview_026), new ForegroundColorSpan(textColor))
|
||||
.append(nickName, new ForegroundColorSpan(roomTipNickColor))
|
||||
.append(ResUtil.getString(R.string.avroom_widget_messageview_0160), new ForegroundColorSpan(textColor))
|
||||
.append(tarotMsgBean.getDrawGoldNum() + ResUtil.getString(R.string.avroom_widget_messageview_027), new ForegroundColorSpan(roomTipColor));
|
||||
tvContent.setText(text.build());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2101,7 +2246,7 @@ public class MessageView extends FrameLayout {
|
||||
builder.append(ivOfficialMask, SizeUtils.dp2px(tvContent.getContext(), 62), expLevelHeight);
|
||||
}
|
||||
//等級
|
||||
builder.append(userLevel, expLevelWidth, expLevelHeight);
|
||||
builder.append(userLevel, expLevelHeight);
|
||||
//銘牌
|
||||
String tvNamePlate = NobleUtil.getNamePlate(UserInfo.NAMEPLATE_WORD, chatRoomMessage).trim();
|
||||
String ivNamePlate = NobleUtil.getNamePlate(UserInfo.NAMEPLATE_PIC, chatRoomMessage);
|
||||
|
@@ -65,7 +65,7 @@ public class MicroView extends LinearLayout implements View.OnLayoutChangeListen
|
||||
private boolean isNeedResetMicCenterPoint = true;
|
||||
|
||||
private DatingItemDecoration datingItemDecoration;
|
||||
private OnMicroItemClickListener onMicroItemClickListener;
|
||||
private OnMicroItemClickListener onMicroItemClickListener = null;
|
||||
|
||||
public MicroView(Context context) {
|
||||
this(context, null);
|
||||
@@ -116,6 +116,9 @@ public class MicroView extends LinearLayout implements View.OnLayoutChangeListen
|
||||
}
|
||||
|
||||
private void subMsg() {
|
||||
if (isInEditMode()) {
|
||||
return;
|
||||
}
|
||||
subscribe = IMNetEaseManager.get()
|
||||
.getChatRoomEventObservable().subscribe(
|
||||
roomEvent -> onReceiveRoomEvent(roomEvent),
|
||||
@@ -224,7 +227,7 @@ public class MicroView extends LinearLayout implements View.OnLayoutChangeListen
|
||||
}
|
||||
if (isNeedSetBackground) {
|
||||
AnimFactory.getSpeakingAnimation(mContext, speakState.getWidth(), speakState.getHeight(),
|
||||
NobleUtil.getColor(halo), speakState.getWidth() * 3 / 4)
|
||||
NobleUtil.getColor(halo), speakState.getWidth() * 3 / 4)
|
||||
.subscribe((animationDrawable, throwable) -> {
|
||||
speakState.setBackground(animationDrawable);
|
||||
animationDrawable.start();
|
||||
|
@@ -424,6 +424,8 @@ public class PKBoardView extends RelativeLayout implements View.OnClickListener
|
||||
pkScoreBoardDialog.show();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -41,9 +41,12 @@ import com.yizhuan.xchat_android_constants.XChatConstants
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.decoration.car.bean.CarInfo
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.*
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager
|
||||
import com.yizhuan.xchat_android_core.manager.RoomEvent
|
||||
import com.yizhuan.xchat_android_core.monsterhunting.SimpleAnimationListener
|
||||
import com.yizhuan.xchat_android_core.room.bean.DatingNotifyInfo
|
||||
import com.yizhuan.xchat_android_core.super_admin.util.SuperAdminUtil
|
||||
import com.yizhuan.xchat_android_core.user.UserModel
|
||||
@@ -51,6 +54,7 @@ import com.yizhuan.xchat_android_core.user.bean.UserInfo
|
||||
import com.yizhuan.xchat_android_core.utils.subAndReplaceDot
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil
|
||||
import com.yizhuan.xchat_android_library.utils.StringUtils
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.ObservableEmitter
|
||||
import io.reactivex.ObservableOnSubscribe
|
||||
@@ -72,7 +76,8 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
private val mCarEffectList: MutableList<CarInfo?> by lazy { ArrayList() }
|
||||
|
||||
//頂部飄屏總展示時間
|
||||
private val SHOW_TIME = 3500
|
||||
private val SHOW_TIME = 4500
|
||||
private val CLOSE_TIME = 5000
|
||||
|
||||
//頂部飄屏周期
|
||||
private val PERIOD = 1000
|
||||
@@ -85,9 +90,6 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
private var boxDisposable: Disposable? = null
|
||||
private val messagesBox: MutableList<ChatRoomMessage> by lazy { ArrayList() }
|
||||
|
||||
private var boxSVGADisposable: Disposable? = null
|
||||
private val messagesBoxSVGA: MutableList<ChatRoomMessage> by lazy { ArrayList() }
|
||||
|
||||
private var animationLuckyGift: Animation? = null
|
||||
private var disposableLuckyGift: Disposable? = null
|
||||
private val messagesLuckyGift: MutableList<ChatRoomMessage> by lazy { ArrayList() }
|
||||
@@ -150,21 +152,21 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
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.DATING_ALL_NOTIFY -> addDatingAllNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.BOX_NOTIFY_SVGA -> addBoxNotifyBySVGA(roomEvent.chatRoomMessage)
|
||||
RoomEvent.RADISH_NOTIFY,
|
||||
RoomEvent.RADISH_NOTIFY_SVGA -> addRadishNotify(roomEvent.chatRoomMessage)
|
||||
|
||||
RoomEvent.ROOM_GIFT_COMPOUND -> addGiftCompoundNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.RECEIVE_ROOM_LUCKY_BAG_NOTICE, RoomEvent.RECEIVE_SERVICE_LUCKY_BAG_NOTICE -> //全服福袋
|
||||
//廳內福袋
|
||||
addLuckyBagNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.DATING_PUBLISH_RESULT -> showHandAnim((roomEvent.chatRoomMessage.attachment as DatingAttachment).datingNotifyInfo)
|
||||
RoomEvent.RECEIVE_MEMBER_IN_NOTICE -> //進入房間
|
||||
addMemberInNotify(roomEvent.chatRoomMessage)
|
||||
|
||||
RoomEvent.RECEIVE_EXPER_LEVEL_UP_NOTICE -> addLevelUpNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.ENTER_ROOM -> if (!SuperAdminUtil.isSuperAdmin()) {
|
||||
playCarSvga(AuthModel.get().currentUid.toString(), null, true)
|
||||
}
|
||||
|
||||
RoomEvent.CAR_MEMBER_IN -> if (roomEvent.mRoomCarMsgAttachment != null) {
|
||||
playCarSvga(
|
||||
null,
|
||||
@@ -176,17 +178,20 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
false
|
||||
)
|
||||
}
|
||||
|
||||
RoomEvent.ROOM_PK_NOTIFY -> addRoomPKNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.SINGLE_ROOM_PK_NOTIFY -> addSingleRoomPKNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.SINGLE_ROOM_RANK_TOP_NOTIFY -> showSingleRoomRankNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.SINGLE_ROOM_RANK_TOP_NOTIFY -> showRoomRankNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.ROOM_RANK_TOP_NOTIFY -> showRoomRankNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.ROOM_CAR_EFFECT_HIDE -> {
|
||||
isHideCarEffect = true
|
||||
loopCarAnim()
|
||||
}
|
||||
|
||||
RoomEvent.ROOM_CAR_EFFECT_SHOW -> {
|
||||
isHideCarEffect = false
|
||||
}
|
||||
|
||||
RoomEvent.DRAW_GIFT_EFFECT -> {
|
||||
val drawGiftAttachment =
|
||||
(roomEvent.chatRoomMessage?.attachment as? DrawGiftAttachment)
|
||||
@@ -197,6 +202,7 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
false
|
||||
)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
@@ -225,11 +231,13 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
if (disposableDatingAll == null || messagesDatingAll.size == 1) {
|
||||
disposableDatingAll = Observable.interval(0, 3, TimeUnit.SECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.takeWhile { messagesDatingAll.size > 0 }
|
||||
.takeWhile { messagesDatingAll.size > 0 && !mContext.isDestroyed() }
|
||||
.subscribe {
|
||||
showDatingAllNotify(
|
||||
messagesDatingAll.removeAt(0)
|
||||
)
|
||||
if (binding.flDatingAllNotify.childCount == 0) {
|
||||
showDatingAllNotify(
|
||||
messagesDatingAll.removeAt(0)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -292,115 +300,6 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
) + "…"
|
||||
}
|
||||
|
||||
/**
|
||||
* 開福袋飄屏
|
||||
*
|
||||
* @param chatRoomMessage
|
||||
*/
|
||||
private fun addLuckyBagNotify(chatRoomMessage: ChatRoomMessage) {
|
||||
if (binding.clNotify.visibility == GONE) {
|
||||
binding.clNotify.visibility = VISIBLE
|
||||
}
|
||||
messagesLuckyGift.add(chatRoomMessage)
|
||||
if (disposableLuckyGift == null || messagesLuckyGift.size == 1) {
|
||||
disposableLuckyGift = Observable.interval(0, PERIOD.toLong(), TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.takeWhile { messagesLuckyGift.size > 0 }
|
||||
.subscribe {
|
||||
showLuckyBagNotify(
|
||||
messagesLuckyGift.removeAt(0)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showLuckyBagNotify(message: ChatRoomMessage?) {
|
||||
val attachment = message?.attachment as? RoomReceivedLuckyGiftAttachment ?: return
|
||||
val noticeInfo = attachment.luckyBagNoticeInfo ?: return
|
||||
val text = SpannableBuilder()
|
||||
.append(
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_04),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
noticeInfo.nick.subAndReplaceDot(6) + " ",
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_05),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
noticeInfo.luckyBagName + " ",
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_06),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
noticeInfo.goldPrice + " ",
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_07),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
noticeInfo.giftName,
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
|
||||
val svgaImageView = SVGAImageView(mContext)
|
||||
svgaImageView.loops = 1
|
||||
svgaImageView.clearsAfterStop = true
|
||||
shareParser().decodeFromAssets(
|
||||
"svga/lucky_gift_notify.svga",
|
||||
object : SVGAParser.ParseCompletion {
|
||||
override fun onComplete(videoItem: SVGAVideoEntity) {
|
||||
binding.flLuckyGiftNotify.addView(svgaImageView)
|
||||
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
|
||||
), "fdpp_copywriting"
|
||||
)
|
||||
if (AvRoomDataManager.get().roomUid == noticeInfo.roomUid) {
|
||||
dynamicEntity.setHidden(true, "img_206")
|
||||
} else {
|
||||
svgaImageView.setOnClickListener {
|
||||
//跳轉房間要移除監聽,不然可能NPE
|
||||
svgaImageView.callback = null
|
||||
AVRoomActivity.start(mContext, noticeInfo.roomUid)
|
||||
}
|
||||
}
|
||||
val drawable = SVGADrawable(videoItem, dynamicEntity)
|
||||
svgaImageView.setImageDrawable(drawable)
|
||||
svgaImageView.stepToFrame(0, true)
|
||||
}
|
||||
|
||||
override fun onError() {}
|
||||
})
|
||||
svgaImageView.callback = object : SimpleSvgaCallback() {
|
||||
override fun onFinished() {
|
||||
binding.flLuckyGiftNotify.post {
|
||||
binding.flLuckyGiftNotify.removeView(svgaImageView)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 幸運池飄屏
|
||||
*
|
||||
@@ -414,11 +313,20 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
if (boxDisposable == null || messagesBox.size == 1) {
|
||||
boxDisposable = Observable.interval(0, PERIOD.toLong(), TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.takeWhile { messagesBox.size > 0 }
|
||||
.takeWhile { messagesBox.size > 0 && !mContext.isDestroyed() }
|
||||
.subscribe {
|
||||
showBoxNotify(
|
||||
messagesBox.removeAt(0)
|
||||
)
|
||||
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)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -433,7 +341,7 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
attachment.nick + " ",
|
||||
attachment.nick.subAndReplaceDot(8),
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
.append(
|
||||
@@ -443,7 +351,7 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
)
|
||||
.append(
|
||||
attachment.prizeName,
|
||||
ForegroundColorSpan(resources.getColor(R.color.color_00EAFF))
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
if (attachment.prizeNum > 1) {
|
||||
text.append("x" + attachment.prizeNum, ForegroundColorSpan(Color.WHITE))
|
||||
@@ -453,31 +361,15 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
binding.flBoxNotify.addView(textView)
|
||||
textView.startAnimation(animationBox)
|
||||
binding.flBoxNotify.postDelayed(
|
||||
{ binding.flBoxNotify.removeView(textView) },
|
||||
{
|
||||
animationBox = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
|
||||
textView.startAnimation(animationBox)
|
||||
},
|
||||
SHOW_TIME.toLong()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 幸運池飄屏 五級 SVGA背景的
|
||||
*
|
||||
* @param chatRoomMessage
|
||||
*/
|
||||
private fun addBoxNotifyBySVGA(chatRoomMessage: ChatRoomMessage) {
|
||||
if (binding.clNotify.visibility == GONE) {
|
||||
binding.clNotify.visibility = VISIBLE
|
||||
}
|
||||
messagesBoxSVGA.add(chatRoomMessage)
|
||||
if (boxSVGADisposable == null || messagesBoxSVGA.size == 1) {
|
||||
boxSVGADisposable = Observable.interval(0, PERIOD.toLong(), TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.takeWhile { messagesBoxSVGA.size > 0 }
|
||||
.subscribe {
|
||||
showBoxNotifyBySVGA(
|
||||
messagesBoxSVGA.removeAt(0)
|
||||
)
|
||||
}
|
||||
}
|
||||
binding.flBoxNotify.postDelayed({
|
||||
binding.flBoxNotify.removeView(textView)
|
||||
}, CLOSE_TIME.toLong())
|
||||
}
|
||||
|
||||
private fun showBoxNotifyBySVGA(chatRoomMessage: ChatRoomMessage) {
|
||||
@@ -488,7 +380,7 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
attachment.nick + " ",
|
||||
StringUtils.abbreviate(attachment.nick, 8) + " ",
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
.append(
|
||||
@@ -498,22 +390,31 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
)
|
||||
.append(
|
||||
attachment.prizeName,
|
||||
ForegroundColorSpan(resources.getColor(R.color.color_00EAFF))
|
||||
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.clearsAfterStop = true
|
||||
svgaImageView.clearsAfterDetached = true
|
||||
val params = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
||||
svgaImageView.layoutParams = params
|
||||
svgaImageView.callback = object : SimpleSvgaCallback() {
|
||||
override fun onFinished() {
|
||||
binding.flSvgaBoxNotify.post { binding.flSvgaBoxNotify.removeView(svgaImageView) }
|
||||
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)
|
||||
}
|
||||
}
|
||||
binding.flSvgaBoxNotify.addView(svgaImageView)
|
||||
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()
|
||||
@@ -531,7 +432,7 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
1.0f,
|
||||
0.0f,
|
||||
false
|
||||
), "noble_text_tx"
|
||||
), "bg"
|
||||
)
|
||||
val drawable = SVGADrawable(videoItem, dynamicEntity)
|
||||
svgaImageView.setImageDrawable(drawable)
|
||||
@@ -555,9 +456,11 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
if (radishDisposable == null || messagesRadish.size == 1) {
|
||||
radishDisposable = Observable.interval(0, PERIOD.toLong(), TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.takeWhile { messagesRadish.size > 0 }
|
||||
.takeWhile { messagesRadish.size > 0 && !mContext.isDestroyed() }
|
||||
.subscribe {
|
||||
showRadishNotify(messagesRadish.removeAt(0))
|
||||
if (binding.flRadishNotify.childCount == 0) {
|
||||
showRadishNotify(messagesRadish.removeAt(0))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -633,9 +536,11 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
if (radishSVGADisposable == null || messagesRadishSVGA.size == 1) {
|
||||
radishSVGADisposable = Observable.interval(0, PERIOD.toLong(), TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.takeWhile { messagesRadishSVGA.size > 0 }
|
||||
.takeWhile { messagesRadishSVGA.size > 0 && !mContext.isDestroyed() }
|
||||
.subscribe {
|
||||
showRadishNotifyBySVGA(messagesRadishSVGA.removeAt(0))
|
||||
if (binding.flSvgaRadishNotify.childCount == 0) {
|
||||
showRadishNotifyBySVGA(messagesRadishSVGA.removeAt(0))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -719,11 +624,11 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
if (disposableGiftCompound == null || messagesGiftCompound.size == 1) {
|
||||
disposableGiftCompound = Observable.interval(0, PERIOD.toLong(), TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.takeWhile { messagesGiftCompound.size > 0 }
|
||||
.takeWhile { messagesGiftCompound.size > 0 && !mContext.isDestroyed() }
|
||||
.subscribe {
|
||||
showGiftCompoundNotify(
|
||||
messagesGiftCompound.removeAt(0)
|
||||
)
|
||||
if (binding.flGiftCompoundNotify.childCount == 0) {
|
||||
showGiftCompoundNotify(messagesGiftCompound.removeAt(0))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -795,11 +700,9 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
if (disposableMemberIn == null || messagesMemberIn.size == 1) {
|
||||
disposableMemberIn = Observable.interval(0, 6, TimeUnit.SECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.takeWhile { messagesMemberIn.size > 0 }
|
||||
.takeWhile { messagesMemberIn.size > 0 && !mContext.isDestroyed() }
|
||||
.subscribe {
|
||||
showMemberInNotify(
|
||||
messagesMemberIn.removeAt(0)
|
||||
)
|
||||
showMemberInNotify(messagesMemberIn.removeAt(0))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -929,11 +832,9 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
if (disposableLevelUp == null || messagesLevelUp.size == 1) {
|
||||
disposableLevelUp = Observable.interval(0, 6, TimeUnit.SECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.takeWhile { messagesLevelUp.size > 0 }
|
||||
.takeWhile { messagesLevelUp.size > 0 && !mContext.isDestroyed() }
|
||||
.subscribe {
|
||||
showLevelUpNotify(
|
||||
messagesLevelUp.removeAt(0)
|
||||
)
|
||||
showLevelUpNotify(messagesLevelUp.removeAt(0))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1230,11 +1131,11 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
if (disposableRoomPK == null || messagesRoomPK.size == 1) {
|
||||
disposableRoomPK = Observable.interval(0, 4, TimeUnit.SECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.takeWhile { messagesRoomPK.size > 0 }
|
||||
.takeWhile { messagesRoomPK.size > 0 && !mContext.isDestroyed() }
|
||||
.subscribe {
|
||||
showRoomPKNotify(
|
||||
messagesRoomPK.removeAt(0)
|
||||
)
|
||||
if (binding.flRoomPkNotify.childCount == 0) {
|
||||
showRoomPKNotify(messagesRoomPK.removeAt(0))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1276,11 +1177,11 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
if (disposableSingleRoomPK == null || messagesSingleRoomPK.size == 1) {
|
||||
disposableSingleRoomPK = Observable.interval(0, 4, TimeUnit.SECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.takeWhile { messagesSingleRoomPK.size > 0 }
|
||||
.takeWhile { messagesSingleRoomPK.size > 0 && !mContext.isDestroyed() }
|
||||
.subscribe {
|
||||
showSingleRoomPKNotify(
|
||||
messagesSingleRoomPK.removeAt(0)
|
||||
)
|
||||
if (binding.flSingleRoomPkNotify.childCount == 0) {
|
||||
showSingleRoomPKNotify(messagesSingleRoomPK.removeAt(0))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1310,27 +1211,6 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
)
|
||||
}
|
||||
|
||||
private fun showSingleRoomRankNotify(chatRoomMessage: ChatRoomMessage) {
|
||||
if (binding.clNotify.visibility == GONE) {
|
||||
binding.clNotify.visibility = VISIBLE
|
||||
}
|
||||
val roomPkBean = (chatRoomMessage.attachment as SingleRoomRankAttachment).msgBean
|
||||
val rootView =
|
||||
LayoutInflater.from(mContext).inflate(R.layout.layout_single_room_rank_notify, null)
|
||||
(rootView.findViewById<View>(R.id.tv_nick) as TextView).text =
|
||||
roomPkBean.nick.subAndReplaceDot(6)
|
||||
(rootView.findViewById<View>(R.id.tv_desc) as TextView).text = roomPkBean.desc
|
||||
rootView.findViewById<ImageView>(R.id.iv_avatar).load(roomPkBean.avatar)
|
||||
rootView.setOnClickListener { AVRoomActivity.start(context, roomPkBean.uid) }
|
||||
binding.flSingleRoomRankNotify.addView(rootView)
|
||||
animationLuckyGift = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
rootView.startAnimation(animationLuckyGift)
|
||||
binding.flSingleRoomRankNotify.postDelayed({
|
||||
binding.flSingleRoomRankNotify.removeView(
|
||||
rootView
|
||||
)
|
||||
}, SHOW_TIME.toLong())
|
||||
}
|
||||
|
||||
private fun showRoomRankNotify(chatRoomMessage: ChatRoomMessage) {
|
||||
if (binding.clNotify.visibility == GONE) {
|
||||
|
@@ -4,7 +4,18 @@ import static com.yizhuan.xchat_android_core.Constants.DEBUG_MAX_UID;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MESS_HEAD_NOBLE;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MESS_SUB_OPENNOBLE;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MESS_SUB_RENEWNOBLE;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_BOX;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAIRY;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_NOTIFY_H5_SUB_WHOLE_SERVICE;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_RED_PACKAGE;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_GIFT_L5;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_DIAMOND;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_VIP;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_VIP_USER_ALL_UPGRADE;
|
||||
@@ -12,6 +23,7 @@ import static com.yizhuan.xchat_android_library.utils.UIUtils.getActivityByConte
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.Dialog;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -33,6 +45,7 @@ import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
@@ -56,7 +69,8 @@ import com.yizhuan.erban.application.XChatApplication;
|
||||
import com.yizhuan.erban.avroom.activity.AVRoomActivity;
|
||||
import com.yizhuan.erban.avroom.firstcharge.FirstChargeDialog;
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageGoRoomDialog;
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageOpenDialog;
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageHandler;
|
||||
import com.yizhuan.erban.avroom.redpackage.open.RedPackageOpenDialog;
|
||||
import com.yizhuan.erban.common.LoadingFragment;
|
||||
import com.yizhuan.erban.common.NetworkErrorFragment;
|
||||
import com.yizhuan.erban.common.NoDataFragment;
|
||||
@@ -65,6 +79,8 @@ import com.yizhuan.erban.common.permission.PermissionActivity;
|
||||
import com.yizhuan.erban.common.widget.StatusLayout;
|
||||
import com.yizhuan.erban.common.widget.dialog.DialogManager;
|
||||
import com.yizhuan.erban.common.widget.dialog.DialogUiHelper;
|
||||
import com.yizhuan.erban.treasure_box.activity.TreasureBoxActivity;
|
||||
import com.yizhuan.erban.treasurefairy.HomeFairyActivity;
|
||||
import com.yizhuan.erban.ui.im.avtivity.NimP2PMessageActivity;
|
||||
import com.yizhuan.erban.ui.login.AddUserInfoActivity;
|
||||
import com.yizhuan.erban.ui.login.LoginCodeActivity;
|
||||
@@ -73,6 +89,8 @@ import com.yizhuan.erban.ui.pay.ChargeActivity;
|
||||
import com.yizhuan.erban.ui.setting.ResetPasswordActivity;
|
||||
import com.yizhuan.erban.ui.webview.CommonWebViewActivity;
|
||||
import com.yizhuan.erban.ui.widget.DefaultToolBar;
|
||||
import com.yizhuan.erban.ui.widget.dialog.AllPlayEffectDialog;
|
||||
import com.yizhuan.erban.ui.widget.dialog.AllServiceGiftLevelDialog;
|
||||
import com.yizhuan.erban.ui.widget.dialog.AllServiceVipLevelUPDialog;
|
||||
import com.yizhuan.erban.ui.widget.dialog.OpenNobleGlobalNoticeDialog;
|
||||
import com.yizhuan.erban.utils.UserUtils;
|
||||
@@ -81,12 +99,20 @@ import com.yizhuan.xchat_android_constants.XChatConstants;
|
||||
import com.yizhuan.xchat_android_core.Constants;
|
||||
import com.yizhuan.xchat_android_core.UriProvider;
|
||||
import com.yizhuan.xchat_android_core.bean.BaseProtocol;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagNoticeInfo;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.NotifyH5Info;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.PlayEffectInfo;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeInfo;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomLuckySeaMsgBean;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.TarotMsgBean;
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
|
||||
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager;
|
||||
import com.yizhuan.xchat_android_core.manager.RoomEvent;
|
||||
import com.yizhuan.xchat_android_core.mentoring_relationship.event.GrabApprenticesEvent;
|
||||
import com.yizhuan.xchat_android_core.newbie.NewbieHelloInfo;
|
||||
import com.yizhuan.xchat_android_core.newbie.event.NewbieHelloDialogEvent;
|
||||
import com.yizhuan.xchat_android_core.noble.AllServiceGiftProtocol;
|
||||
import com.yizhuan.xchat_android_core.noble.NobleInfo;
|
||||
import com.yizhuan.xchat_android_core.noble.NobleProtocol;
|
||||
import com.yizhuan.xchat_android_core.pay.PayModel;
|
||||
@@ -94,6 +120,8 @@ import com.yizhuan.xchat_android_core.pay.bean.WalletInfo;
|
||||
import com.yizhuan.xchat_android_core.redpackage.RedPackageNotifyInfo;
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
|
||||
import com.yizhuan.xchat_android_core.room.model.AvRoomModel;
|
||||
import com.yizhuan.xchat_android_core.support.room.RoomContext;
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.FairyMsgInfoBean;
|
||||
import com.yizhuan.xchat_android_core.user.UserModel;
|
||||
import com.yizhuan.xchat_android_core.utils.net.RxHelper;
|
||||
import com.yizhuan.xchat_android_core.vip.VipMessageInfo;
|
||||
@@ -116,6 +144,7 @@ import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
@@ -147,6 +176,12 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
private OpenNobleGlobalNoticeDialog mNoticeDialog;
|
||||
private boolean isShowingChargeDialog;
|
||||
|
||||
private Dialog giftDialog;
|
||||
private LinkedList<AllServiceGiftProtocol.DataBean> giftList;
|
||||
|
||||
private Dialog playEffectDialog;
|
||||
private LinkedList<PlayEffectInfo> playEffectList;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -160,7 +195,6 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
if (roomEvent == null) return;
|
||||
onReceiveChatRoomEvent(roomEvent);
|
||||
}));
|
||||
registerNimBroadcastMessage(true);
|
||||
}
|
||||
|
||||
protected void onReceiveChatRoomEvent(RoomEvent roomEvent) {
|
||||
@@ -330,24 +364,45 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
registerNimBroadcastMessage(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
registerNimBroadcastMessage(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
registerNimBroadcastMessage(false);
|
||||
if (mCompositeDisposable != null) {
|
||||
mCompositeDisposable.dispose();
|
||||
mCompositeDisposable = null;
|
||||
}
|
||||
|
||||
if (mNoticeDialog != null && mNoticeDialog.isShowing()) {
|
||||
mNoticeDialog.dismiss();
|
||||
mNoticeDialog = null;
|
||||
try {
|
||||
if (mNoticeDialog != null && mNoticeDialog.isShowing()) {
|
||||
mNoticeDialog.dismiss();
|
||||
mNoticeDialog = null;
|
||||
}
|
||||
if (giftDialog != null && giftDialog.isShowing()) {
|
||||
giftDialog.setOnDismissListener(null);
|
||||
giftDialog.dismiss();
|
||||
giftDialog = null;
|
||||
}
|
||||
if (playEffectDialog != null && playEffectDialog.isShowing()) {
|
||||
playEffectDialog.setOnDismissListener(null);
|
||||
playEffectDialog.dismiss();
|
||||
playEffectDialog = null;
|
||||
}
|
||||
if (giftList != null) {
|
||||
giftList.clear();
|
||||
}
|
||||
if(playEffectList != null){
|
||||
playEffectList.clear();
|
||||
}
|
||||
} catch (Exception e){
|
||||
Logger.i("关闭弹窗失败" + e.getMessage());
|
||||
}
|
||||
|
||||
super.onDestroy();
|
||||
@@ -506,6 +561,12 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::onRoomEventReceived);
|
||||
|
||||
if (giftList != null) {
|
||||
giftList.clear();
|
||||
}
|
||||
if(playEffectList != null){
|
||||
playEffectList.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -894,10 +955,19 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
return;
|
||||
RedPackageNotifyInfo notifyInfo = new Gson().fromJson(String.valueOf(baseProtocol.getData()), RedPackageNotifyInfo.class);
|
||||
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (roomInfo != null && roomInfo.getUid() == notifyInfo.getRoomUid() && context instanceof AVRoomActivity) {
|
||||
RedPackageOpenDialog.Companion.newInstance(notifyInfo).show(BaseActivity.this);
|
||||
RoomContext roomContext = RoomContext.Companion.get();
|
||||
RedPackageHandler redPackageHandler = null;
|
||||
if (roomContext != null) {
|
||||
redPackageHandler = roomContext.findAbility(RedPackageHandler.class.getSimpleName());
|
||||
}
|
||||
if (redPackageHandler != null) {
|
||||
redPackageHandler.onAllServiceSignaling(this, notifyInfo);
|
||||
} else {
|
||||
RedPackageGoRoomDialog.Companion.newInstance(notifyInfo).show(this);
|
||||
if (roomInfo != null && roomInfo.getUid() == notifyInfo.getRoomUid() && context instanceof AVRoomActivity) {
|
||||
RedPackageOpenDialog.Companion.newInstance(notifyInfo).show(BaseActivity.this);
|
||||
} else {
|
||||
RedPackageGoRoomDialog.Companion.newInstance(notifyInfo).show(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
case CUSTOM_MSG_VIP:
|
||||
@@ -908,11 +978,266 @@ 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 CustomAttachment.CUSTOM_MESS_TAROT:
|
||||
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<>();
|
||||
}
|
||||
if (baseProtocol.getSecond() == CustomAttachment.CUSTOM_MESS_TAROT_SENIOR_PRIZE_WINNING) {
|
||||
TarotMsgBean tarotMsgBean = JSON.parseObject(String.valueOf(baseProtocol.getData()), TarotMsgBean.class);
|
||||
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
|
||||
playEffectInfo.setSecond(CustomAttachment.CUSTOM_MESS_TAROT_SENIOR_PRIZE_WINNING);
|
||||
playEffectInfo.setTarotMsgBean(tarotMsgBean);
|
||||
if (playEffectList == null) {
|
||||
playEffectList = new LinkedList<>();
|
||||
}
|
||||
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_MSG_NOTIFY_H5:
|
||||
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 (baseProtocol.getSecond() == CustomAttachment.CUSTOM_MSG_NOTIFY_H5_SUB_WHOLE_SERVICE) {
|
||||
NotifyH5Info bean = JSON.parseObject(String.valueOf(baseProtocol.getData()), NotifyH5Info.class);
|
||||
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
|
||||
playEffectInfo.setSecond(CUSTOM_MSG_NOTIFY_H5_SUB_WHOLE_SERVICE);
|
||||
playEffectInfo.setNotifyH5(bean);
|
||||
if (playEffectList == null) {
|
||||
playEffectList = new LinkedList<>();
|
||||
}
|
||||
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_SEA://星级厨房
|
||||
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<>();
|
||||
}
|
||||
RoomLuckySeaMsgBean roomLuckySeaMsgBean = JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomLuckySeaMsgBean.class);
|
||||
if (roomLuckySeaMsgBean == null) return;
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL) {
|
||||
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
|
||||
playEffectInfo.setSecond(CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL);
|
||||
playEffectInfo.setRoomLuckySeaMsgBean(roomLuckySeaMsgBean);
|
||||
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
|
||||
|| this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|
||||
|| UserUtils.getUserInfo() == null)
|
||||
return;
|
||||
if (playEffectList == null) {
|
||||
playEffectList = new LinkedList<>();
|
||||
}
|
||||
FairyMsgInfoBean fairyMsgInfo = JSON.parseObject(String.valueOf(baseProtocol.getData()), FairyMsgInfoBean.class);
|
||||
if (fairyMsgInfo == null) return;
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_SUB_DRAW_GIFT_L5) {
|
||||
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
|
||||
playEffectInfo.setSecond(CUSTOM_MSG_SUB_DRAW_GIFT_L5);
|
||||
playEffectInfo.setFairyMsgInfo(fairyMsgInfo);
|
||||
playEffectList.add(playEffectInfo);
|
||||
if (playEffectDialog != null && playEffectDialog.isShowing()) {
|
||||
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
|
||||
PlayEffectInfo dataBean = playEffectList.peekFirst();
|
||||
if (dataBean != null) {
|
||||
return;
|
||||
} else {
|
||||
playEffectDialog.dismiss();
|
||||
}
|
||||
} else {
|
||||
showPlayEffectDialog();
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void showPlayEffectDialog() {
|
||||
if (playEffectList.size() == 0) return;
|
||||
playEffectDialog = new AllPlayEffectDialog(this, playEffectList.peekFirst());
|
||||
playEffectDialog.setOnDismissListener(dialog -> {
|
||||
playEffectList.pollFirst();
|
||||
PlayEffectInfo dataBean = playEffectList.peekFirst();
|
||||
if (dataBean != null) {
|
||||
if (isValid()) {
|
||||
showPlayEffectDialog();
|
||||
} else {
|
||||
playEffectList.clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
playEffectDialog.show();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void showGiftDialog() {
|
||||
if (giftList.size() == 0) return;
|
||||
AllServiceGiftProtocol.DataBean data = giftList.peekFirst();
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
if (!data.isHomeShow()) {
|
||||
return;
|
||||
}
|
||||
giftDialog = generateAllServiceGiftDialog(this, data);
|
||||
giftDialog.setOnDismissListener(dialog -> {
|
||||
giftList.pollFirst();
|
||||
AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst();
|
||||
if (dataBean != null) {
|
||||
if (isValid()) {
|
||||
showGiftDialog();
|
||||
} else {
|
||||
giftList.clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
giftDialog.show();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private AllServiceGiftLevelDialog generateAllServiceGiftDialog(@NonNull Context context, @NonNull AllServiceGiftProtocol.DataBean dataBean) {
|
||||
return new AllServiceGiftLevelDialog(context, dataBean);
|
||||
}
|
||||
|
||||
public void onGrabApprenticesEvent(GrabApprenticesEvent event) {
|
||||
if (!isTopActivity()) return;
|
||||
if (dialog != null && dialog.isAdded()) {
|
||||
|
@@ -14,6 +14,7 @@ import java.lang.reflect.ParameterizedType
|
||||
|
||||
abstract class BaseDialog<T : ViewBinding> : RxDialogFragment() {
|
||||
|
||||
val isViewLoaded: Boolean get() = _binding != null
|
||||
private var _binding: T? = null
|
||||
private var onDismissListener: (() -> Unit)? = null
|
||||
val binding get() = _binding!!
|
||||
@@ -42,7 +43,7 @@ abstract class BaseDialog<T : ViewBinding> : RxDialogFragment() {
|
||||
val aClass = type.actualTypeArguments[0] as Class<*>
|
||||
val method = aClass.getDeclaredMethod("inflate", LayoutInflater::class.java)
|
||||
_binding = method.invoke(null, layoutInflater) as T
|
||||
return binding.root
|
||||
return binding?.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
@@ -70,6 +71,7 @@ abstract class BaseDialog<T : ViewBinding> : RxDialogFragment() {
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
this.onDismissListener = null
|
||||
}
|
||||
|
||||
abstract fun init()
|
||||
|
@@ -20,6 +20,7 @@ import com.netease.nim.uikit.support.glide.GlideApp;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.yizhuan.erban.view.GenderAgeTextView;
|
||||
import com.yizhuan.xchat_android_core.utils.StarUtils;
|
||||
import com.yizhuan.xchat_android_library.utils.TimeUtils;
|
||||
import com.yizhuan.xchat_android_library.utils.config.BasicConfig;
|
||||
@@ -83,17 +84,6 @@ public class ViewAdapter {
|
||||
ImageLoadUtils.loadImage(imageView.getContext(), url, imageView);
|
||||
}
|
||||
|
||||
@BindingAdapter(value = {"date"}, requireAll = false)
|
||||
public static void setConstellation(TextView textView, long date) {
|
||||
String star = StarUtils.getConstellation(new Date(date));
|
||||
if (null == star) {
|
||||
textView.setVisibility(View.GONE);
|
||||
} else {
|
||||
textView.setText(star);
|
||||
textView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter(value = {"isOn"}, requireAll = false)
|
||||
public static void setIsOn(IOSSwitchView iosSwitchView, boolean isOn) {
|
||||
iosSwitchView.setOn(isOn);
|
||||
@@ -177,4 +167,14 @@ public class ViewAdapter {
|
||||
params.height = (int) height;
|
||||
v.setLayoutParams(params);
|
||||
}
|
||||
|
||||
@BindingAdapter(value = {"birthday"}, requireAll = false)
|
||||
public static void setBirthday(GenderAgeTextView v, long birthday) {
|
||||
v.setBirthDay(birthday);
|
||||
}
|
||||
|
||||
@BindingAdapter(value = {"gender"}, requireAll = false)
|
||||
public static void setGender(GenderAgeTextView v, int gender) {
|
||||
v.setGender(gender);
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,14 @@ public class EmptyViewHelper {
|
||||
return view;
|
||||
}
|
||||
|
||||
public static View createEmptyTextViewHeight(Context context, String text) {
|
||||
if (!NetworkUtils.isNetworkAvailable(context)) text = ResUtil.getString(R.string.erban_common_emptyviewhelper_01);
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.layout_wrap_empty, null);
|
||||
view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
((TextView) view.findViewById(R.id.tv_hint)).setText(text);
|
||||
return view;
|
||||
}
|
||||
|
||||
public static View createEmptyTextViewNoImage(Context context, String text) {
|
||||
if (!NetworkUtils.isNetworkAvailable(context)) text = ResUtil.getString(R.string.erban_common_emptyviewhelper_01);
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.layout_text_empty, null);
|
||||
|
@@ -3,6 +3,7 @@ package com.yizhuan.erban.common.dialog
|
||||
import android.Manifest
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import android.text.TextUtils
|
||||
@@ -73,16 +74,14 @@ class PhotoDialog : BaseDialogFragment<PhotoDialogBinding>(), EasyPermissions.Pe
|
||||
|
||||
private fun checkStoragePermission1() {
|
||||
if (!EasyPermissions.hasPermissions(
|
||||
XChatApplication.gContext, Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
XChatApplication.gContext, if (Build.VERSION.SDK_INT >= 33) Manifest.permission.READ_MEDIA_IMAGES else Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
)
|
||||
) {
|
||||
EasyPermissions.requestPermissions(
|
||||
this,
|
||||
getString(R.string.permission_storage_rationale),
|
||||
PERMISSION_CODE_STORAGE_1,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
if (Build.VERSION.SDK_INT >= 33) Manifest.permission.READ_MEDIA_IMAGES else Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
)
|
||||
} else {
|
||||
PhotoProviderNew.photoProvider(this, resultCode = REQUEST_CODE_OPEN_PHOTO_PROVIDER)
|
||||
@@ -90,7 +89,11 @@ class PhotoDialog : BaseDialogFragment<PhotoDialogBinding>(), EasyPermissions.Pe
|
||||
}
|
||||
|
||||
private fun checkCameraPermission() {
|
||||
if (!EasyPermissions.hasPermissions(XChatApplication.gContext, Manifest.permission.CAMERA)) {
|
||||
if (!EasyPermissions.hasPermissions(
|
||||
XChatApplication.gContext,
|
||||
Manifest.permission.CAMERA
|
||||
)
|
||||
) {
|
||||
EasyPermissions.requestPermissions(
|
||||
this,
|
||||
getString(R.string.permission_camera_rationale),
|
||||
@@ -104,16 +107,15 @@ class PhotoDialog : BaseDialogFragment<PhotoDialogBinding>(), EasyPermissions.Pe
|
||||
|
||||
private fun checkStoragePermission2() {
|
||||
if (!EasyPermissions.hasPermissions(
|
||||
XChatApplication.gContext, Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
XChatApplication.gContext, if (Build.VERSION.SDK_INT >= 33)
|
||||
Manifest.permission.READ_MEDIA_IMAGES else Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
)
|
||||
) {
|
||||
EasyPermissions.requestPermissions(
|
||||
this,
|
||||
getString(R.string.permission_storage_rationale),
|
||||
PERMISSION_CODE_STORAGE_2,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
if (Build.VERSION.SDK_INT >= 33) Manifest.permission.READ_MEDIA_IMAGES else Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
)
|
||||
} else {
|
||||
PhotoProviderNew.photoCamera(this, REQUEST_CODE_OPEN_CAMERA_PROVIDER)
|
||||
|
@@ -13,8 +13,8 @@ import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.chuhai.core.component.SuperBottomSheetDialog;
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.common.util.Utils;
|
||||
import com.yizhuan.erban.ui.widget.ButtonItem;
|
||||
@@ -24,7 +24,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author xiaoyu
|
||||
*/
|
||||
public class CommonPopupDialog extends BottomSheetDialog implements OnClickListener {
|
||||
public class CommonPopupDialog extends SuperBottomSheetDialog implements OnClickListener {
|
||||
private static final int BUTTON_ITEM_ID = 135798642;
|
||||
|
||||
private int mId;
|
||||
|
@@ -40,10 +40,6 @@ class DecorationViewModel : BaseViewModel() {
|
||||
block = {
|
||||
_decorationInfoListLiveData.value =
|
||||
ListResult.success(DecorationModel.getDecorationInfoList(dressType), 1)
|
||||
},
|
||||
onError = {
|
||||
it.message.toast()
|
||||
_decorationInfoListLiveData.value = ListResult.failed(1)
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -54,7 +50,7 @@ class DecorationViewModel : BaseViewModel() {
|
||||
block = {
|
||||
DecorationModel.buyDecoration(dressType, dressId)
|
||||
ResUtil.getString(R.string.decoration_viewmodel_decorationviewmodel_01).toast()
|
||||
},
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
@@ -14,6 +14,7 @@ import com.yizhuan.erban.ui.pay.ChargeActivity
|
||||
import com.yizhuan.erban.ui.webview.CommonWebViewActivity
|
||||
import com.yizhuan.xchat_android_core.Constants
|
||||
import com.yizhuan.xchat_android_core.UriProvider
|
||||
import com.yizhuan.xchat_android_core.earn.bean.RoomTypeInfo
|
||||
import com.yizhuan.xchat_android_library.common.util.DeviceUtil
|
||||
import com.yizhuan.xchat_android_library.utils.AppMetaDataUtil
|
||||
|
||||
@@ -26,6 +27,7 @@ class EarnRecordActivity : BaseViewBindingActivity<ActivityEarnRecordBinding>(),
|
||||
View.OnClickListener {
|
||||
|
||||
private val earnRecordModel: EarnRecordViewModel by viewModels()
|
||||
private var roomTypeInfo: RoomTypeInfo ?= null
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
@@ -58,23 +60,13 @@ class EarnRecordActivity : BaseViewBindingActivity<ActivityEarnRecordBinding>(),
|
||||
|
||||
earnRecordModel.queryRoomTypeLiveData.observe(this) {
|
||||
it?.let {
|
||||
if (it.roomType == 4) {
|
||||
binding.csGoldBg.visibility = View.GONE
|
||||
}
|
||||
roomTypeInfo = it
|
||||
binding.tvDiamondNum.text = String.format(it.diamonds.toString())
|
||||
binding.tvGoldNum.text = String.format(it.golds.toString())
|
||||
if (it.isClanElder) {
|
||||
binding.tvGoldDetail.visibility = View.VISIBLE
|
||||
binding.tvConvertDiamond.visibility = View.GONE
|
||||
binding.csGoldBg.background =
|
||||
ContextCompat.getDrawable(this, R.drawable.bg_gold_detail)
|
||||
} else {
|
||||
binding.tvGoldDetail.visibility = View.GONE
|
||||
if (it.hasGoldExchangeAuth) {
|
||||
binding.tvConvertDiamond.visibility = View.VISIBLE
|
||||
} else {
|
||||
binding.tvConvertDiamond.visibility = View.GONE
|
||||
}
|
||||
binding.csGoldBg.background =
|
||||
ContextCompat.getDrawable(this, R.drawable.bg_earn_gold)
|
||||
}
|
||||
@@ -113,7 +105,7 @@ class EarnRecordActivity : BaseViewBindingActivity<ActivityEarnRecordBinding>(),
|
||||
CommonWebViewActivity.start(context, UriProvider.getDiamondDetail())
|
||||
}
|
||||
R.id.tvGoldDetail -> {//金币明细
|
||||
GoldDetailActivity.start(this)
|
||||
CommonWebViewActivity.start(context, UriProvider.getGoldDetail())
|
||||
}
|
||||
R.id.tvConvertDiamond -> {//兑换钻石
|
||||
earnRecordModel.getGoldToDiamondInfo()
|
||||
|