Compare commits
219 Commits
v2.0.4
...
peko_relea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9096a9b57f | ||
|
|
c46c49715c | ||
|
|
31b785c511 | ||
|
|
6f01c5ddad | ||
|
|
306f15f7f9 | ||
|
|
0babbedeb9 | ||
|
|
d09e60d206 | ||
|
|
e37796286b | ||
|
|
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 | ||
|
|
928857f97d |
@@ -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,13 +2,9 @@ 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'
|
||||
|
||||
configurations.maybeCreate("default")
|
||||
artifacts.add("default", file('SudMGP-v1.1.52.554.aar'))
|
||||
|
||||
def onlyArm64 = Boolean.parseBoolean(only_arm64)
|
||||
|
||||
android {
|
||||
@@ -24,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
|
||||
@@ -51,20 +47,29 @@ android {
|
||||
}
|
||||
|
||||
//在apk文件后边生成版本号信息
|
||||
android.applicationVariants.all {
|
||||
variant ->
|
||||
variant.outputs.all {
|
||||
def date = new Date().format("MMddHHmm", TimeZone.getTimeZone("GMT+08"))
|
||||
outputFileName = "piko_${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
|
||||
}
|
||||
@@ -142,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")) {
|
||||
@@ -172,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"
|
||||
@@ -206,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'
|
||||
|
||||
@@ -290,6 +302,7 @@ dependencies {
|
||||
//wheelView
|
||||
implementation 'com.contrarywind:wheelview:4.1.0'
|
||||
|
||||
implementation 'tech.sud.mgp:SudMGP-static:1.3.3.1158'
|
||||
}
|
||||
|
||||
channel {
|
||||
|
||||
Binary file not shown.
16
app/proguard-rules.pro
vendored
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.** {*;}
|
||||
|
||||
|
||||
#百度统计
|
||||
|
||||
@@ -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"
|
||||
@@ -818,6 +829,10 @@
|
||||
<activity
|
||||
android:name=".ui.webview.DatingRuleWebViewActivity"
|
||||
android:theme="@style/dialog_web_view_activity" />
|
||||
<activity
|
||||
android:name=".ui.webview.room_banner.RoomBannerWebDialogActivity"
|
||||
android:theme="@style/dialog_web_view_activity"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".ui.webview.TarotPayWebViewActivity"
|
||||
android:theme="@style/dialog_web_view_activity" />
|
||||
@@ -1004,6 +1019,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"
|
||||
@@ -1071,6 +1090,8 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".avroom.room_album.RoomAlbumActivity" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
Binary file not shown.
BIN
app/src/main/assets/svga/home_voice_playing.svga
Normal file
BIN
app/src/main/assets/svga/home_voice_playing.svga
Normal file
Binary file not shown.
BIN
app/src/main/assets/svga/svga_home_pk.svga
Normal file
BIN
app/src/main/assets/svga/svga_home_pk.svga
Normal file
Binary file not shown.
BIN
app/src/main/assets/svga/svga_notify_h5.svga
Normal file
BIN
app/src/main/assets/svga/svga_notify_h5.svga
Normal file
Binary file not shown.
BIN
app/src/main/assets/svga/svga_tarot_senior.svga
Normal file
BIN
app/src/main/assets/svga/svga_tarot_senior.svga
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -410,6 +410,7 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
}
|
||||
onParseIntent();
|
||||
handleNimIntent();
|
||||
InitialModel.get().regionCheck();
|
||||
}
|
||||
|
||||
private void onParseIntent() {
|
||||
@@ -519,6 +520,7 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onLoadLoginUserInfoEvent(LoadLoginUserInfoEvent event) {
|
||||
firstLoadedUserInfo();
|
||||
InitialModel.get().regionCheck();
|
||||
}
|
||||
|
||||
public void onLogout() {
|
||||
|
||||
@@ -16,7 +16,10 @@ import android.util.Log;
|
||||
import androidx.multidex.MultiDex;
|
||||
|
||||
import com.bumptech.glide.request.target.ViewTarget;
|
||||
import com.chuhai.utils.LanguageUtils;
|
||||
import com.chuhai.utils.ServiceTime;
|
||||
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;
|
||||
@@ -64,6 +67,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;
|
||||
@@ -112,6 +116,9 @@ import io.realm.RealmConfiguration;
|
||||
public class XChatApplication extends BaseApp {
|
||||
public static final String TAG = "XChatApplication";
|
||||
public static Application gContext;
|
||||
|
||||
// 接收到退出登录事件(跳转到登录页了)
|
||||
private static long logoutEventTime = 0;
|
||||
private static final MessageNotifierCustomization messageNotifierCustomization = new MessageNotifierCustomization() {
|
||||
@Override
|
||||
public String makeNotifyContent(String nick, IMMessage message) {
|
||||
@@ -161,6 +168,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;
|
||||
//生命周期监听
|
||||
@@ -195,10 +207,11 @@ public class XChatApplication extends BaseApp {
|
||||
|
||||
String channel = "";
|
||||
channel = ChannelReaderUtil.getChannel(instance);
|
||||
Log.d(TAG, "localChannel:" + channel);
|
||||
if (TextUtils.isEmpty(channel)) {
|
||||
channel = Constants.GOOGLE;
|
||||
}
|
||||
|
||||
Log.d(TAG, "finalChannel:" + channel);
|
||||
BasicConfig.INSTANCE.setOriginalChannel(channel);
|
||||
|
||||
BasicConfig.INSTANCE.setChannel(channel);
|
||||
@@ -237,6 +250,13 @@ public class XChatApplication extends BaseApp {
|
||||
SingleToastUtil.showToast(serviceResult.getMessage());
|
||||
EventBus.getDefault().post(new NeedCompleteInfoEvent());
|
||||
throw new ServerException(serviceResult.getMessage(), serviceResult.getCode());
|
||||
} else if (serviceResult.getCode() == 401) {
|
||||
if ((ServiceTime.INSTANCE.getTime() - logoutEventTime) > 800) {
|
||||
logoutEventTime = ServiceTime.INSTANCE.getTime();
|
||||
SingleToastUtil.showToast(serviceResult.getMessage());
|
||||
AuthModel.get().cleanLogInfo();
|
||||
}
|
||||
throw new ServerException(serviceResult.getMessage(), serviceResult.getCode());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -247,6 +267,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);
|
||||
|
||||
//生命周期监听
|
||||
@@ -395,11 +416,13 @@ public class XChatApplication extends BaseApp {
|
||||
httpParams.put("deviceId", DeviceUuidFactory.getDeviceId(context));
|
||||
httpParams.put("androidId", MD5Utils.getMD5String(Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID)));
|
||||
httpParams.put("channel", AppMetaDataUtil.getChannelID());
|
||||
httpParams.put("lang", LanguageUtils.INSTANCE.getSystemLanguage().toLanguageTag());
|
||||
RxNet.init(context)
|
||||
.debug(BuildConfig.DEBUG)
|
||||
.setBaseUrl(url)
|
||||
.addInterceptors(new ParamsInterceptor(httpParams))
|
||||
.addInterceptors(new NoParamsInterceptor())//注意:拦截器的添加顺序,请求的拦截顺序
|
||||
.addInterceptors(new TimeSyncInterceptor())
|
||||
.certificates()
|
||||
.build();
|
||||
//单例的model 初始化
|
||||
@@ -538,4 +561,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) {
|
||||
|
||||
@@ -16,6 +16,7 @@ import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUS
|
||||
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;
|
||||
@@ -38,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;
|
||||
@@ -65,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;
|
||||
@@ -81,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;
|
||||
@@ -97,7 +96,10 @@ 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;
|
||||
@@ -105,6 +107,8 @@ 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;
|
||||
@@ -123,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;
|
||||
@@ -135,6 +138,8 @@ 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;
|
||||
@@ -143,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;
|
||||
@@ -155,10 +159,7 @@ 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;
|
||||
|
||||
@@ -175,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;
|
||||
@@ -213,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;
|
||||
/*********************************显示全服礼物***************************************/
|
||||
@@ -221,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);
|
||||
}
|
||||
@@ -408,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 {
|
||||
@@ -506,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) {
|
||||
@@ -611,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:
|
||||
}
|
||||
}
|
||||
@@ -675,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) {
|
||||
@@ -711,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();
|
||||
}
|
||||
@@ -1071,7 +1065,6 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
DemoCache.readNewUserChargeGift() == 0) {
|
||||
DemoCache.saveNewUserChargeGift(1);
|
||||
}
|
||||
showRedPackage(AvRoomDataManager.get().mCurrentRoomInfo);
|
||||
dismissLoadingDialog();
|
||||
}
|
||||
|
||||
@@ -1243,6 +1236,34 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
}
|
||||
}
|
||||
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);
|
||||
@@ -1284,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();
|
||||
@@ -1299,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();
|
||||
@@ -1368,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;
|
||||
|
||||
@@ -1400,5 +1427,4 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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,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()
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ 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;
|
||||
@@ -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), () -> {
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
@@ -471,9 +513,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
//設置透明度
|
||||
rollPagerView.setAnimationDurtion(500)
|
||||
bannerAdapter.notifyDataSetChanged()
|
||||
bannerAdapter.setRoomActClickListener { url ->
|
||||
DialogWebViewActivity.start(mContext, url)
|
||||
}
|
||||
|
||||
// 模擬指示器在viewpager底部效果
|
||||
val viewPager = rollPagerView.viewPager
|
||||
@@ -544,7 +583,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 +645,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
releaseView()
|
||||
unregisterWidgets()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
@@ -632,13 +675,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 +753,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
}
|
||||
.subscribe { _, throwable ->
|
||||
if (throwable != null) {
|
||||
toast(throwable.message)
|
||||
callback.onFail()
|
||||
} else {
|
||||
callback.onSuccess()
|
||||
@@ -983,6 +1030,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
|
||||
@@ -1232,10 +1282,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 +1298,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 +1311,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)
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ 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
|
||||
@@ -193,4 +194,8 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
override fun initWidget() {
|
||||
super.initWidget()
|
||||
registerWidget(RedPackageWidget::class.java.simpleName, gameBinding.redPackageWidget)
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -133,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() {
|
||||
@@ -526,7 +533,6 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (mDisposable != null) {
|
||||
@@ -808,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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import android.view.View
|
||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener
|
||||
import android.widget.FrameLayout
|
||||
import com.google.gson.Gson
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
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
|
||||
@@ -34,7 +34,7 @@ class GameDelegate(val activity: Activity, val container: FrameLayout, var mgId:
|
||||
private val TAG = "GameDelegate"
|
||||
private var APP_CODE = ""
|
||||
|
||||
private val mRoomID = AvRoomDataManager.get().roomUid.toString()
|
||||
private val mRoomID :String get() = AvRoomDataManager.get().roomUid.toString()
|
||||
private val mLanguage = "zh-TW" //語言
|
||||
|
||||
//調用遊戲SDK的接口,成功加載遊戲後可用:
|
||||
@@ -84,7 +84,10 @@ class GameDelegate(val activity: Activity, val container: FrameLayout, var mgId:
|
||||
}
|
||||
|
||||
fun updateGame(mgId: Long?) {
|
||||
if (mgId == null || mgId == 0L || mgId == mMGID || iSudFSTAPP == null) return
|
||||
if (mgId == null || mgId == 0L) return
|
||||
if (mgId == mMGID && iSudFSTAPP != null) {
|
||||
return
|
||||
}
|
||||
mMGID = mgId
|
||||
updateMyMicQueue(GameStatus.STATUS_NOT_JOIN)
|
||||
loadMG(activity, mUid, mRoomID, APP_CODE, mMGID, mLanguage)
|
||||
@@ -165,7 +168,9 @@ class GameDelegate(val activity: Activity, val container: FrameLayout, var mgId:
|
||||
) {
|
||||
iSudFSTAPP?.destroyMG()
|
||||
iSudFSTAPP = SudMGP.loadMG(activity, userID, roomID, code, mgID, language, mISudFSMMG)
|
||||
addGameView(iSudFSTAPP!!.gameView)
|
||||
iSudFSTAPP?.apply {
|
||||
addGameView(gameView)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -317,9 +322,9 @@ class GameDelegate(val activity: Activity, val container: FrameLayout, var mgId:
|
||||
//遊戲安全操作區域
|
||||
val viewGameRect = JSONObject()
|
||||
viewGameRect.put("left", 0)
|
||||
viewGameRect.put("top", ScreenUtil.dip2px(200f))
|
||||
viewGameRect.put("top", container.context.resources.getDimensionPixelOffset(R.dimen.dp_180))
|
||||
viewGameRect.put("right", 0)
|
||||
viewGameRect.put("bottom", ScreenUtil.dip2px(200f))
|
||||
viewGameRect.put("bottom", container.context.resources.getDimensionPixelOffset(R.dimen.dp_150))
|
||||
jsonObject.put("view_game_rect", viewGameRect)
|
||||
|
||||
//通知遊戲
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
@@ -296,17 +296,24 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
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, pos), 1200);
|
||||
if (isPlaySvga) {
|
||||
handler.postDelayed(() -> drawLuckyGiftAnimation(roomInfo, giftReceiveInfos, totalCoin, targetUsers, giftReceiveType, isShowAnimation, pos), 1200);
|
||||
} else {
|
||||
drawLuckyGiftAnimation(roomInfo, giftReceiveInfos, totalCoin, targetUsers, giftReceiveType, isShowAnimation, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,7 +361,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
targetUsers.add(giftReceiver);
|
||||
if (!isShowAnimation) return;
|
||||
giftInfo = giftReceiveInfo.getDisplayGift().get(pos);
|
||||
if (totalCoin >= 520 || (giftInfo != null && giftInfo.isHasEffect())) {
|
||||
if (giftInfo != null && giftInfo.isHasEffect()) {
|
||||
Message msg = Message.obtain();
|
||||
msg.what = 0;
|
||||
GiftEffectInfo giftEffectInfo = new GiftEffectInfo();
|
||||
|
||||
@@ -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;
|
||||
@@ -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,6 +1045,103 @@ 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();
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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
|
||||
@@ -86,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() }
|
||||
@@ -151,18 +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 -> addBoxNotifyBySVGA(roomEvent.chatRoomMessage)
|
||||
RoomEvent.BOX_NOTIFY_SVGA -> addBoxNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.DATING_ALL_NOTIFY -> addDatingAllNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.RADISH_NOTIFY,
|
||||
RoomEvent.RADISH_NOTIFY_SVGA -> addRadishNotify(roomEvent.chatRoomMessage)
|
||||
|
||||
RoomEvent.ROOM_GIFT_COMPOUND -> addGiftCompoundNotify(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,
|
||||
@@ -174,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)
|
||||
@@ -195,6 +202,7 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
false
|
||||
)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
@@ -308,9 +316,16 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
.takeWhile { messagesBox.size > 0 && !mContext.isDestroyed() }
|
||||
.subscribe {
|
||||
if (binding.flBoxNotify.childCount == 0) {
|
||||
showBoxNotify(
|
||||
messagesBox.removeAt(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)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -326,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(
|
||||
@@ -336,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))
|
||||
@@ -357,30 +372,6 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
}, CLOSE_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 && !mContext.isDestroyed() }
|
||||
.subscribe {
|
||||
if (binding.flSvgaBoxNotify.childCount == 0) {
|
||||
showBoxNotifyBySVGA(
|
||||
messagesBoxSVGA.removeAt(0)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showBoxNotifyBySVGA(chatRoomMessage: ChatRoomMessage) {
|
||||
val attachment = chatRoomMessage.attachment as RoomBoxPrizeAttachment
|
||||
val text = SpannableBuilder()
|
||||
@@ -389,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(
|
||||
@@ -399,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()
|
||||
@@ -432,7 +432,7 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
1.0f,
|
||||
0.0f,
|
||||
false
|
||||
), "noble_text_tx"
|
||||
), "bg"
|
||||
)
|
||||
val drawable = SVGADrawable(videoItem, dynamicEntity)
|
||||
svgaImageView.setImageDrawable(drawable)
|
||||
@@ -1211,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) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.text.HtmlCompat
|
||||
import com.coorchice.library.SuperTextView
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage
|
||||
@@ -41,6 +42,7 @@ import com.yizhuan.erban.ui.widget.SimpleAnimListener
|
||||
import com.yizhuan.erban.ui.widget.drawgift.DrawGiftPlayHelper
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil
|
||||
import com.yizhuan.erban.utils.MsgBuilder
|
||||
import com.yizhuan.erban.utils.RegexUtil
|
||||
import com.yizhuan.erban.utils.SpannableBuilder
|
||||
import com.yizhuan.xchat_android_constants.XChatConstants
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
@@ -49,6 +51,7 @@ import com.yizhuan.xchat_android_core.im.custom.bean.*
|
||||
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
|
||||
@@ -56,6 +59,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
|
||||
@@ -164,18 +168,32 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
RoomEvent.BOX_NOTIFY -> {//寻爱
|
||||
addPlayNotify(RoomEvent.BOX_NOTIFY, roomEvent.chatRoomMessage)
|
||||
}
|
||||
|
||||
RoomEvent.BOX_NOTIFY_SVGA -> {//寻爱svga
|
||||
addPlayNotify(RoomEvent.BOX_NOTIFY_SVGA, roomEvent.chatRoomMessage)
|
||||
}
|
||||
|
||||
RoomEvent.TAROT_NOTIFY,
|
||||
RoomEvent.TAROT_NOTIFY_SVGA -> {
|
||||
addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage)
|
||||
}
|
||||
|
||||
RoomEvent.NOTIFY_H5 -> {
|
||||
addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage)
|
||||
}
|
||||
|
||||
RoomEvent.RECEIVE_ROOM_LUCKY_BAG_NOTICE, RoomEvent.RECEIVE_SERVICE_LUCKY_BAG_NOTICE ->//全服福袋
|
||||
//廳內福袋
|
||||
addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage)
|
||||
|
||||
RoomEvent.LUCKY_SEA_GIFT_ROOM_NOTIFY -> {// 星级厨房房间飘屏通知
|
||||
addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage)
|
||||
}
|
||||
|
||||
RoomEvent.LUCKY_SEA_GIFT_SERVER_NOTIFY -> {// 星级厨房全服飘屏通知
|
||||
addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage)
|
||||
}
|
||||
|
||||
RoomEvent.FAIRY_DRAW_GIFT_L4,
|
||||
RoomEvent.FAIRY_DRAW_GIFT_L5,
|
||||
RoomEvent.FAIRY_CONVERT_L1,
|
||||
@@ -183,17 +201,21 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
RoomEvent.FAIRY_CONVERT_L3 -> {
|
||||
addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage)
|
||||
}
|
||||
|
||||
RoomEvent.DATING_ALL_NOTIFY -> addDatingAllNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.RADISH_NOTIFY,
|
||||
RoomEvent.RADISH_NOTIFY_SVGA -> addRadishNotify(roomEvent.chatRoomMessage)
|
||||
|
||||
RoomEvent.ROOM_GIFT_COMPOUND -> addGiftCompoundNotify(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,
|
||||
@@ -205,17 +227,20 @@ class RoomEffectView @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)
|
||||
@@ -226,6 +251,7 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
false
|
||||
)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
@@ -256,111 +282,196 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.takeWhile { messagesPlay.size > 0 && !mContext.isDestroyed() }
|
||||
.subscribe {
|
||||
if (binding.flPlayNotify.childCount == 0) {
|
||||
when (messagesPlay[0].event) {
|
||||
RoomEvent.BOX_NOTIFY -> {//寻爱
|
||||
if ((mContext as AVRoomActivity).isTopActivity) {
|
||||
isPlayAnim = true
|
||||
val isPlay = onPlayAnimCallback?.invoke() ?: false
|
||||
if (isPlay) {
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, 180.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
} else {
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, 60.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
}
|
||||
showBoxNotify(
|
||||
messagesPlay.removeAt(0)
|
||||
if (binding.flPlayNotify.childCount != 0) {
|
||||
return@subscribe
|
||||
}
|
||||
|
||||
when (messagesPlay[0].event) {
|
||||
RoomEvent.BOX_NOTIFY -> {//寻爱
|
||||
if ((mContext as AVRoomActivity).isTopActivity) {
|
||||
isPlayAnim = true
|
||||
val isPlay = onPlayAnimCallback?.invoke() ?: false
|
||||
if (isPlay) {
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, 180.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
} else {
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, 60.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
}
|
||||
}
|
||||
RoomEvent.BOX_NOTIFY_SVGA -> {//寻爱
|
||||
if ((mContext as AVRoomActivity).isTopActivity) {
|
||||
isPlayAnim = true
|
||||
val isPlay = onPlayAnimCallback?.invoke() ?: false
|
||||
if (isPlay) {
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, 180.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
} else {
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, 60.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
}
|
||||
showBoxNotifyBySVGA(messagesPlay.removeAt(0))
|
||||
}
|
||||
}
|
||||
RoomEvent.RECEIVE_ROOM_LUCKY_BAG_NOTICE, RoomEvent.RECEIVE_SERVICE_LUCKY_BAG_NOTICE -> {//福袋
|
||||
isPlayAnim = true
|
||||
val isPlay = onPlayAnimCallback?.invoke() ?: false
|
||||
if (isPlay) {
|
||||
margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0)
|
||||
} else {
|
||||
margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0)
|
||||
}
|
||||
showLuckyBagNotify(
|
||||
showBoxNotify(
|
||||
messagesPlay.removeAt(0)
|
||||
)
|
||||
}
|
||||
RoomEvent.LUCKY_SEA_GIFT_ROOM_NOTIFY -> {//星级厨房
|
||||
}
|
||||
|
||||
RoomEvent.BOX_NOTIFY_SVGA -> {//寻爱
|
||||
if ((mContext as AVRoomActivity).isTopActivity) {
|
||||
isPlayAnim = true
|
||||
val isPlay = onPlayAnimCallback?.invoke() ?: false
|
||||
if (isPlay) {
|
||||
margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0)
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, 180.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
} else {
|
||||
margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0)
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, 60.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
}
|
||||
showLuckySeaNotify(
|
||||
messagesPlay.removeAt(0)
|
||||
)
|
||||
showBoxNotifyBySVGA(messagesPlay.removeAt(0))
|
||||
}
|
||||
RoomEvent.LUCKY_SEA_GIFT_SERVER_NOTIFY -> {//星级厨房
|
||||
}
|
||||
|
||||
RoomEvent.TAROT_NOTIFY -> {
|
||||
if ((mContext as AVRoomActivity).isTopActivity) {
|
||||
isPlayAnim = true
|
||||
val isPlay = onPlayAnimCallback?.invoke() ?: false
|
||||
if (isPlay) {
|
||||
margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0)
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, 180.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
} else {
|
||||
margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0)
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, 60.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
}
|
||||
showLuckySeaNotifyBySVGA(
|
||||
showTarotNotify(
|
||||
messagesPlay.removeAt(0)
|
||||
)
|
||||
}
|
||||
RoomEvent.FAIRY_DRAW_GIFT_L4,
|
||||
RoomEvent.FAIRY_DRAW_GIFT_L5,
|
||||
RoomEvent.FAIRY_CONVERT_L1,
|
||||
RoomEvent.FAIRY_CONVERT_L2,
|
||||
RoomEvent.FAIRY_CONVERT_L3 -> {//夺宝
|
||||
}
|
||||
|
||||
RoomEvent.TAROT_NOTIFY_SVGA -> {
|
||||
if ((mContext as AVRoomActivity).isTopActivity) {
|
||||
isPlayAnim = true
|
||||
val isPlay = onPlayAnimCallback?.invoke() ?: false
|
||||
if (isPlay) {
|
||||
margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0)
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, 180.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
} else {
|
||||
margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0)
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, 60.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
}
|
||||
showFairyNotify(
|
||||
messagesPlay.removeAt(0)
|
||||
)
|
||||
showTarotNotifyBySVGA(messagesPlay.removeAt(0))
|
||||
}
|
||||
}
|
||||
|
||||
RoomEvent.NOTIFY_H5 -> {
|
||||
if (!(mContext as AVRoomActivity).isTopActivity) {
|
||||
return@subscribe
|
||||
}
|
||||
|
||||
isPlayAnim = true
|
||||
val isPlay = onPlayAnimCallback?.invoke() ?: false
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, if (isPlay) 180.0 else 60.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
|
||||
val msg = messagesPlay.removeAt(0)
|
||||
val attachment = msg.chatRoomMessage.attachment as NotifyH5Attachment
|
||||
val bean = attachment.bean ?: return@subscribe
|
||||
if (bean.floatingType == 0) {
|
||||
showNotifyH5(bean)
|
||||
} else {
|
||||
showNotifyH5WithAnim(bean)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RoomEvent.RECEIVE_ROOM_LUCKY_BAG_NOTICE, RoomEvent.RECEIVE_SERVICE_LUCKY_BAG_NOTICE -> {//福袋
|
||||
isPlayAnim = true
|
||||
val isPlay = onPlayAnimCallback?.invoke() ?: false
|
||||
if (isPlay) {
|
||||
margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0)
|
||||
} else {
|
||||
margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0)
|
||||
}
|
||||
showLuckyBagNotify(
|
||||
messagesPlay.removeAt(0)
|
||||
)
|
||||
}
|
||||
|
||||
RoomEvent.LUCKY_SEA_GIFT_ROOM_NOTIFY -> {//星级厨房
|
||||
isPlayAnim = true
|
||||
val isPlay = onPlayAnimCallback?.invoke() ?: false
|
||||
if (isPlay) {
|
||||
margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0)
|
||||
} else {
|
||||
margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0)
|
||||
}
|
||||
showLuckySeaNotify(
|
||||
messagesPlay.removeAt(0)
|
||||
)
|
||||
}
|
||||
|
||||
RoomEvent.LUCKY_SEA_GIFT_SERVER_NOTIFY -> {//星级厨房
|
||||
isPlayAnim = true
|
||||
val isPlay = onPlayAnimCallback?.invoke() ?: false
|
||||
if (isPlay) {
|
||||
margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0)
|
||||
} else {
|
||||
margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0)
|
||||
}
|
||||
showLuckySeaNotifyBySVGA(
|
||||
messagesPlay.removeAt(0)
|
||||
)
|
||||
}
|
||||
|
||||
RoomEvent.FAIRY_DRAW_GIFT_L4,
|
||||
RoomEvent.FAIRY_DRAW_GIFT_L5,
|
||||
RoomEvent.FAIRY_CONVERT_L1,
|
||||
RoomEvent.FAIRY_CONVERT_L2,
|
||||
RoomEvent.FAIRY_CONVERT_L3 -> {//夺宝
|
||||
isPlayAnim = true
|
||||
val isPlay = onPlayAnimCallback?.invoke() ?: false
|
||||
if (isPlay) {
|
||||
margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0)
|
||||
} else {
|
||||
margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0)
|
||||
}
|
||||
showFairyNotify(
|
||||
messagesPlay.removeAt(0)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -389,6 +500,7 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
SHOW_TIME.toLong()
|
||||
)
|
||||
}
|
||||
|
||||
RoomEvent.FAIRY_DRAW_GIFT_L5,
|
||||
RoomEvent.FAIRY_CONVERT_L3 -> {
|
||||
showFairyNotifyBySVGA(roomPlayBean)
|
||||
@@ -759,6 +871,102 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
)
|
||||
}
|
||||
|
||||
private fun showNotifyH5(data: NotifyH5Info) {
|
||||
val textView = LayoutInflater.from(mContext)
|
||||
.inflate(R.layout.layout_notify_h5, null) as TextView
|
||||
textView.text = data.content
|
||||
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
binding.flPlayNotify.addView(textView)
|
||||
textView.startAnimation(animationPlay)
|
||||
binding.flPlayNotify.postDelayed(
|
||||
{
|
||||
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
|
||||
textView.startAnimation(animationPlay)
|
||||
},
|
||||
SHOW_TIME.toLong()
|
||||
)
|
||||
binding.flPlayNotify.postDelayed({
|
||||
binding.flPlayNotify.removeView(textView)
|
||||
isPlayAnim = false
|
||||
}, CLOSE_TIME.toLong())
|
||||
}
|
||||
|
||||
private fun showNotifyH5WithAnim(data: NotifyH5Info) {
|
||||
|
||||
val svgaImageView = SVGAImageView(mContext)
|
||||
svgaImageView.loops = 1
|
||||
svgaImageView.clearsAfterStop = true
|
||||
val params = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
||||
svgaImageView.layoutParams = params
|
||||
svgaImageView.callback = object : SimpleSvgaCallback() {
|
||||
override fun onFinished() {
|
||||
binding.flPlayNotify.post {
|
||||
binding.flPlayNotify.removeView(svgaImageView)
|
||||
isPlayAnim = false
|
||||
}
|
||||
}
|
||||
}
|
||||
binding.flPlayNotify.addView(svgaImageView)
|
||||
shareParser().decodeFromAssets(
|
||||
"svga/svga_notify_h5.svga",
|
||||
object : SVGAParser.ParseCompletion {
|
||||
override fun onComplete(videoItem: SVGAVideoEntity) {
|
||||
val dynamicEntity = SVGADynamicEntity()
|
||||
val textPaint = TextPaint()
|
||||
textPaint.color = Color.WHITE //字體顏色
|
||||
textPaint.textSize = 24f
|
||||
dynamicEntity.setDynamicText(
|
||||
StaticLayout(
|
||||
data.content,
|
||||
0,
|
||||
data.content!!.length,
|
||||
textPaint,
|
||||
0,
|
||||
Layout.Alignment.ALIGN_CENTER,
|
||||
1.0f,
|
||||
0.0f,
|
||||
false
|
||||
), "bg"
|
||||
)
|
||||
val drawable = SVGADrawable(videoItem, dynamicEntity)
|
||||
svgaImageView.setImageDrawable(drawable)
|
||||
svgaImageView.stepToFrame(0, true)
|
||||
}
|
||||
|
||||
override fun onError() {}
|
||||
},
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
private fun showTarotNotify(roomPlayBean: RoomPlayBean) {
|
||||
val chatRoomMessage = roomPlayBean.chatRoomMessage
|
||||
val attachment = chatRoomMessage.attachment as TarotAttachment
|
||||
val textView =
|
||||
LayoutInflater.from(mContext)
|
||||
.inflate(R.layout.layout_notify_tarot_intermediate, null) as TextView
|
||||
val string = mContext.getString(
|
||||
R.string.avroom_widget_roomeffectview_026,
|
||||
StringUtils.abbreviate(RegexUtil.getPrintableString(attachment.tarotMsgBean.nick), 8),
|
||||
attachment.tarotMsgBean.drawGoldNum
|
||||
)
|
||||
textView.text = HtmlCompat.fromHtml(string, HtmlCompat.FROM_HTML_MODE_COMPACT)
|
||||
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
binding.flPlayNotify.addView(textView)
|
||||
textView.startAnimation(animationPlay)
|
||||
binding.flPlayNotify.postDelayed(
|
||||
{
|
||||
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
|
||||
textView.startAnimation(animationPlay)
|
||||
},
|
||||
SHOW_TIME.toLong()
|
||||
)
|
||||
binding.flPlayNotify.postDelayed({
|
||||
binding.flPlayNotify.removeView(textView)
|
||||
isPlayAnim = false
|
||||
}, CLOSE_TIME.toLong())
|
||||
}
|
||||
|
||||
private fun showBoxNotify(roomPlayBean: RoomPlayBean) {
|
||||
val chatRoomMessage = roomPlayBean.chatRoomMessage
|
||||
val attachment = chatRoomMessage.attachment as RoomBoxPrizeAttachment
|
||||
@@ -770,7 +978,7 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
attachment.nick + " ",
|
||||
attachment.nick.subAndReplaceDot(8),
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
.append(
|
||||
@@ -780,7 +988,7 @@ class RoomEffectView @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))
|
||||
@@ -802,30 +1010,16 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
}, CLOSE_TIME.toLong())
|
||||
}
|
||||
|
||||
private fun showBoxNotifyBySVGA(roomPlayBean: RoomPlayBean) {
|
||||
private fun showTarotNotifyBySVGA(roomPlayBean: RoomPlayBean) {
|
||||
val chatRoomMessage = roomPlayBean.chatRoomMessage
|
||||
val attachment = chatRoomMessage.attachment as RoomBoxPrizeAttachment
|
||||
val text = SpannableBuilder()
|
||||
.append(
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_011),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
attachment.nick + " ",
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(
|
||||
R.string.avroom_widget_roomeffectview_013
|
||||
), ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
attachment.prizeName,
|
||||
ForegroundColorSpan(resources.getColor(R.color.color_00EAFF))
|
||||
)
|
||||
if (attachment.prizeNum > 1) {
|
||||
text.append("x" + attachment.prizeNum, ForegroundColorSpan(Color.WHITE))
|
||||
}
|
||||
val attachment = chatRoomMessage.attachment as TarotAttachment
|
||||
val string = mContext.getString(
|
||||
R.string.avroom_widget_roomeffectview_026,
|
||||
StringUtils.abbreviate(RegexUtil.getPrintableString(attachment.tarotMsgBean.nick), 8),
|
||||
attachment.tarotMsgBean.drawGoldNum
|
||||
)
|
||||
val text = HtmlCompat.fromHtml(string, HtmlCompat.FROM_HTML_MODE_COMPACT)
|
||||
|
||||
val svgaImageView = SVGAImageView(mContext)
|
||||
svgaImageView.loops = 1
|
||||
svgaImageView.clearsAfterStop = true
|
||||
@@ -840,6 +1034,83 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
binding.flPlayNotify.addView(svgaImageView)
|
||||
shareParser().decodeFromAssets(
|
||||
"svga/svga_tarot_senior.svga",
|
||||
object : SVGAParser.ParseCompletion {
|
||||
override fun onComplete(videoItem: SVGAVideoEntity) {
|
||||
val dynamicEntity = SVGADynamicEntity()
|
||||
val textPaint = TextPaint()
|
||||
textPaint.color = Color.WHITE //字體顏色
|
||||
textPaint.textSize = 22f
|
||||
dynamicEntity.setDynamicText(
|
||||
StaticLayout(
|
||||
text,
|
||||
0,
|
||||
text.length,
|
||||
textPaint,
|
||||
0,
|
||||
Layout.Alignment.ALIGN_CENTER,
|
||||
1.0f,
|
||||
0.0f,
|
||||
false
|
||||
), "taxt"
|
||||
)
|
||||
val drawable = SVGADrawable(videoItem, dynamicEntity)
|
||||
svgaImageView.setImageDrawable(drawable)
|
||||
svgaImageView.stepToFrame(0, true)
|
||||
}
|
||||
|
||||
override fun onError() {}
|
||||
},
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
private fun showBoxNotifyBySVGA(roomPlayBean: RoomPlayBean) {
|
||||
val chatRoomMessage = roomPlayBean.chatRoomMessage
|
||||
val attachment = chatRoomMessage.attachment as RoomBoxPrizeAttachment
|
||||
val text = SpannableBuilder()
|
||||
.append(
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_011),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
StringUtils.abbreviate(attachment.nick, 8) + " ",
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(
|
||||
R.string.avroom_widget_roomeffectview_013
|
||||
), ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
attachment.prizeName,
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
if (attachment.prizeNum > 1) {
|
||||
text.append("x" + attachment.prizeNum, ForegroundColorSpan(Color.WHITE))
|
||||
}
|
||||
val svgaImageView = SVGAImageView(mContext)
|
||||
svgaImageView.loops = 1
|
||||
svgaImageView.clearsAfterDetached = true
|
||||
val params = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
||||
svgaImageView.layoutParams = params
|
||||
svgaImageView.callback = object : SimpleSvgaCallback() {
|
||||
override fun onFinished() {
|
||||
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
|
||||
animationPlay!!.setAnimationListener(object : SimpleAnimationListener() {
|
||||
override fun onAnimationEnd(animation: Animation?) {
|
||||
binding.flPlayNotify.removeView(svgaImageView)
|
||||
isPlayAnim = false
|
||||
}
|
||||
})
|
||||
binding.flPlayNotify.startAnimation(animationPlay)
|
||||
}
|
||||
}
|
||||
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
binding.flPlayNotify.addView(svgaImageView)
|
||||
binding.flPlayNotify.startAnimation(animationPlay)
|
||||
|
||||
shareParser().decodeFromAssets("svga/box_notify.svga", object : SVGAParser.ParseCompletion {
|
||||
override fun onComplete(videoItem: SVGAVideoEntity) {
|
||||
val dynamicEntity = SVGADynamicEntity()
|
||||
@@ -857,7 +1128,7 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
1.0f,
|
||||
0.0f,
|
||||
false
|
||||
), "noble_text_tx"
|
||||
), "bg"
|
||||
)
|
||||
val drawable = SVGADrawable(videoItem, dynamicEntity)
|
||||
svgaImageView.setImageDrawable(drawable)
|
||||
@@ -1636,27 +1907,6 @@ class RoomEffectView @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) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUS
|
||||
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;
|
||||
@@ -44,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;
|
||||
|
||||
@@ -67,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;
|
||||
@@ -87,10 +90,7 @@ 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.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.AllServiceVipLevelUPDialog;
|
||||
import com.yizhuan.erban.ui.widget.dialog.OpenNobleGlobalNoticeDialog;
|
||||
import com.yizhuan.erban.utils.UserUtils;
|
||||
@@ -100,9 +100,12 @@ 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;
|
||||
@@ -117,6 +120,7 @@ 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;
|
||||
@@ -124,7 +128,6 @@ import com.yizhuan.xchat_android_core.vip.VipMessageInfo;
|
||||
import com.yizhuan.xchat_android_library.common.util.DeviceUtil;
|
||||
import com.yizhuan.xchat_android_library.rxbus.RxBus;
|
||||
import com.yizhuan.xchat_android_library.utils.AppMetaDataUtil;
|
||||
import com.yizhuan.xchat_android_library.utils.JavaUtil;
|
||||
import com.yizhuan.xchat_android_library.utils.NetworkUtils;
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil;
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil;
|
||||
@@ -192,7 +195,6 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
if (roomEvent == null) return;
|
||||
onReceiveChatRoomEvent(roomEvent);
|
||||
}));
|
||||
registerNimBroadcastMessage(true);
|
||||
}
|
||||
|
||||
protected void onReceiveChatRoomEvent(RoomEvent roomEvent) {
|
||||
@@ -362,16 +364,17 @@ 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;
|
||||
@@ -952,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:
|
||||
@@ -1022,6 +1034,65 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
}
|
||||
}
|
||||
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
|
||||
@@ -1137,8 +1208,14 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
|
||||
private void showGiftDialog() {
|
||||
if (giftList.size() == 0) return;
|
||||
if (giftList.peekFirst() != null && !giftList.peekFirst().isHomeShow()) return;
|
||||
giftDialog = generateAllServiceGiftDialog(this, giftList.peekFirst());
|
||||
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();
|
||||
@@ -1157,19 +1234,8 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public void onGrabApprenticesEvent(GrabApprenticesEvent event) {
|
||||
|
||||
@@ -14,9 +14,10 @@ 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
|
||||
val binding get() = _binding!!
|
||||
open var width = ScreenUtil.getDialogWidth()
|
||||
open var height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
open var gravity = Gravity.CENTER
|
||||
@@ -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;
|
||||
|
||||
@@ -4,10 +4,7 @@ import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.yizhuan.erban.base.BaseViewModel
|
||||
import com.yizhuan.xchat_android_core.bean.response.ListResult
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeRoomInfo
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeTabMapInfo
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeTagInfo
|
||||
import com.yizhuan.xchat_android_core.home.bean.*
|
||||
import com.yizhuan.xchat_android_core.home.model.HomeModel
|
||||
import com.yizhuan.xchat_android_core.room.bean.AnchorInfo
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfo
|
||||
@@ -23,6 +20,15 @@ class HomeViewModel : BaseViewModel() {
|
||||
private val _bannerLiveData = MutableLiveData<List<BannerInfo>?>()
|
||||
val bannerLiveData: MutableLiveData<List<BannerInfo>?> = _bannerLiveData
|
||||
|
||||
private val _currentResourceLiveData = MutableLiveData<List<CurrentResourceInfo>?>()
|
||||
val currentResourceLiveData: MutableLiveData<List<CurrentResourceInfo>?> = _currentResourceLiveData
|
||||
|
||||
private val _resourceJumpLiveData = MutableLiveData<HomeRoomInfo?>()
|
||||
val resourceJumpLiveData: LiveData<HomeRoomInfo?> = _resourceJumpLiveData
|
||||
|
||||
private val _homeChatPickLiveData = MutableLiveData<String?>()
|
||||
val homeChatPickLiveData: LiveData<String?> = _homeChatPickLiveData
|
||||
|
||||
private val _gameRoomLiveData = MutableLiveData<ListResult<HomeRoomInfo>>()
|
||||
val gameRoomLiveData: LiveData<ListResult<HomeRoomInfo>> = _gameRoomLiveData
|
||||
|
||||
@@ -50,8 +56,8 @@ class HomeViewModel : BaseViewModel() {
|
||||
private val _homePlayInfoLiveData = MutableLiveData<List<HomeRoomInfo>?>()
|
||||
val homePlayInfoData: MutableLiveData<List<HomeRoomInfo>?> = _homePlayInfoLiveData
|
||||
|
||||
private val _homeHotRoomLiveData = MutableLiveData<List<HomeRoomInfo>?>()
|
||||
val homeHotRoomLiveData: LiveData<List<HomeRoomInfo>?> = _homeHotRoomLiveData
|
||||
private val _homeHotRoomLiveData = MutableLiveData<ListResult<HomeRoomInfo>>()
|
||||
val homeHotRoomLiveData: LiveData<ListResult<HomeRoomInfo>> = _homeHotRoomLiveData
|
||||
|
||||
private val _newFriendLiveData = MutableLiveData<ListResult<UserInfo>>()
|
||||
val newFriendLiveData: LiveData<ListResult<UserInfo>> = _newFriendLiveData
|
||||
@@ -67,6 +73,44 @@ class HomeViewModel : BaseViewModel() {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页改版资源位
|
||||
*/
|
||||
fun getCurrentResourceInfo() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_currentResourceLiveData.value = null
|
||||
},
|
||||
block = {
|
||||
_currentResourceLiveData.value = HomeModel.getCurrentResource()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getResourceJumpInfo(id: Int) {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_resourceJumpLiveData.value = null
|
||||
it.message.toast()
|
||||
},
|
||||
block = {
|
||||
_resourceJumpLiveData.value = HomeModel.getResourceJumpInfo(id)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getHomeChatPick() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_homeChatPickLiveData.value = null
|
||||
it.message.toast()
|
||||
},
|
||||
block = {
|
||||
_homeChatPickLiveData.value = HomeModel.getHomeChatPick()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getBannerInfo() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
@@ -181,10 +225,11 @@ class HomeViewModel : BaseViewModel() {
|
||||
fun getHotRoom() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_homeHotRoomLiveData.value = null
|
||||
_homeHotRoomLiveData.value = ListResult.failed(1)
|
||||
},
|
||||
block = {
|
||||
_homeHotRoomLiveData.value = HomeModel.getHotRoom()
|
||||
val result = HomeModel.getHotRoom()
|
||||
_homeHotRoomLiveData.value = ListResult.success(result, 1)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.yizhuan.erban.home.adapter
|
||||
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
|
||||
import com.zhpan.bannerview.BaseBannerAdapter
|
||||
import com.zhpan.bannerview.BaseViewHolder
|
||||
|
||||
class HomeBannerAdapter : BaseBannerAdapter<BannerInfo?>() {
|
||||
override fun getLayoutId(viewType: Int): Int {
|
||||
return R.layout.activity_home_banner
|
||||
}
|
||||
|
||||
override fun bindData(
|
||||
helper: BaseViewHolder<BannerInfo?>,
|
||||
item: BannerInfo?,
|
||||
position: Int,
|
||||
pageSize: Int
|
||||
) {
|
||||
ImageLoadUtilsV2.loadImage(helper.findViewById(R.id.iv_cover), item?.bannerPic)
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2
|
||||
import com.yizhuan.erban.ui.utils.loadFromAssets
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeRoomInfo
|
||||
import com.yizhuan.xchat_android_library.utils.StringCutUtils
|
||||
import com.yizhuan.xchat_android_core.utils.subAndReplaceDot
|
||||
|
||||
/**
|
||||
* create by lvzebiao @2019/11/13
|
||||
@@ -20,8 +20,7 @@ class HomeChatAdapter :
|
||||
override fun convert(helper: BaseViewHolder, item: HomeRoomInfo) {
|
||||
val svgaLiving = helper.getView<SVGAImageView>(R.id.svga_living)
|
||||
ImageLoadUtilsV2.loadAvatar(helper.getView(R.id.iv_avatar), item.avatar)
|
||||
val name = StringCutUtils.subStrByLen(item.title.substring(0, item.title.length - 3), 8)
|
||||
helper.setText(R.id.tv_name, name)
|
||||
helper.setText(R.id.tv_name, item.title.subAndReplaceDot(6))
|
||||
if (item.mgId == 0L) {
|
||||
helper.getView<Group>(R.id.group_game).visibility = View.INVISIBLE
|
||||
} else {
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
package com.yizhuan.erban.home.adapter
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
import androidx.core.view.isGone
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.opensource.svgaplayer.SVGAImageView
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2
|
||||
import com.yizhuan.erban.ui.utils.load
|
||||
import com.yizhuan.erban.ui.utils.loadFromAssets
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeRoomInfo
|
||||
import com.yizhuan.xchat_android_core.utils.TextUtils
|
||||
|
||||
@@ -25,5 +29,46 @@ class HomeHotAdapter :
|
||||
helper.setGone(R.id.iv_room_tag, !TextUtils.isEmptyText(item.tagPict))
|
||||
ImageLoadUtilsV2.loadImage(helper.getView(R.id.iv_room_tag), item.tagPict)
|
||||
|
||||
val icTopList = helper.getView<AppCompatImageView>(R.id.iv_top_list)
|
||||
if(item.isHourTop1 == 1){
|
||||
icTopList.visibility = View.VISIBLE
|
||||
icTopList.setImageResource(R.drawable.bg_recommend_hour_list)
|
||||
} else if(item.isWeekTop1 == 1){
|
||||
icTopList.visibility = View.VISIBLE
|
||||
icTopList.setImageResource(R.drawable.bg_recommend_weekly_list)
|
||||
} else {
|
||||
icTopList.visibility = View.INVISIBLE
|
||||
}
|
||||
|
||||
val avatars: Array<ImageView> = arrayOf(
|
||||
helper.getView(R.id.iv_avatar_0),
|
||||
helper.getView(R.id.iv_avatar_1),
|
||||
helper.getView(R.id.iv_avatar_2),
|
||||
helper.getView(R.id.iv_avatar_3),
|
||||
helper.getView(R.id.iv_avatar_4)
|
||||
)
|
||||
for (i in avatars.indices) {
|
||||
val avatarUrl = item.micUsers?.getOrNull(i)?.avatar
|
||||
avatars[i].isGone = avatarUrl.isNullOrBlank()
|
||||
avatars[i].load(avatarUrl)
|
||||
}
|
||||
|
||||
val svgaPk = helper.getView<SVGAImageView>(R.id.svga_pk)
|
||||
if (item.isCrossPking) {
|
||||
svgaPk.visibility = View.VISIBLE
|
||||
svgaPk.loadFromAssets("svga/svga_home_pk.svga")
|
||||
} else {
|
||||
svgaPk.visibility = View.GONE
|
||||
}
|
||||
|
||||
val svgaLiving = helper.getView<SVGAImageView>(R.id.svga_living)
|
||||
svgaLiving.loadFromAssets("svga/home_white_living.svga")
|
||||
}
|
||||
|
||||
override fun onViewAttachedToWindow(holder: BaseViewHolder) {
|
||||
super.onViewAttachedToWindow(holder)
|
||||
val svgaLiving = holder.getView<SVGAImageView>(R.id.svga_living)
|
||||
svgaLiving?.loadFromAssets("svga/home_white_living.svga")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
package com.yizhuan.erban.home.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.netease.nim.uikit.support.glide.GlideApp;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.avroom.firstcharge.FirstChargeDialog;
|
||||
import com.yizhuan.erban.shipantics.PullRadishActivity;
|
||||
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.widget.rollviewpager.adapter.StaticPagerAdapter;
|
||||
import com.yizhuan.erban.utils.CommonJumpHelper;
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo;
|
||||
import com.yizhuan.xchat_android_core.room.model.AvRoomModel;
|
||||
import com.yizhuan.xchat_android_library.utils.config.BasicConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RoomActAdapter extends StaticPagerAdapter {
|
||||
|
||||
private Context mContext;
|
||||
private List<BannerInfo> data;
|
||||
private RoomActClickListener listener;
|
||||
|
||||
public RoomActAdapter(Context context, List<BannerInfo> data) {
|
||||
this.data = data;
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(ViewGroup container, int position) {
|
||||
View view = LayoutInflater.from(mContext).inflate(R.layout.item_room_act, container, false);
|
||||
ImageView ivCover = view.findViewById(R.id.iv_cover);
|
||||
BannerInfo bannerInfo = data.get(position);
|
||||
String actId = String.valueOf(bannerInfo.getBannerId());
|
||||
ivCover.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
if (bannerInfo.isFairy()) {
|
||||
ivCover.setImageResource(R.drawable.ic_fairy_entrance);
|
||||
} else if (bannerInfo.isFirstCharge()) {
|
||||
ivCover.setImageResource(R.drawable.ic_first_charge_enter);
|
||||
} else if (bannerInfo.isBox()) {
|
||||
GlideApp.with(BasicConfig.INSTANCE.getAppContext())
|
||||
.load(GoldBoxHelper.getBoxIcon())
|
||||
.error(R.drawable.icon_room_treasure_box)
|
||||
.into(ivCover);
|
||||
} else if (bannerInfo.isRadish()) {
|
||||
ivCover.setImageResource(R.drawable.ic_radish_entrance);
|
||||
} else {
|
||||
ImageLoadUtils.loadImage(mContext, bannerInfo.getBannerPic(), ivCover, R.drawable.default_cover);
|
||||
}
|
||||
ivCover.setOnClickListener(v -> {
|
||||
if (bannerInfo.isFairy()) {
|
||||
HomeFairyActivity.start(mContext);
|
||||
} else if (bannerInfo.isFirstCharge()) {
|
||||
FirstChargeDialog.start(mContext);
|
||||
} else if (bannerInfo.isBox()) {
|
||||
GoldBoxHelper.handleBoxClick(mContext);
|
||||
} else if (bannerInfo.isRadish()) {
|
||||
PullRadishActivity.start(mContext);
|
||||
} else {
|
||||
AvRoomModel.get().activityClickLog("2", actId).subscribe();
|
||||
if (bannerInfo.getSkipType() == 3 && bannerInfo.getShowType() != 1) {
|
||||
if (listener != null) {
|
||||
listener.onWebClick(bannerInfo.getSkipUri());
|
||||
}
|
||||
} else {
|
||||
CommonJumpHelper.bannerJump(mContext, bannerInfo);
|
||||
}
|
||||
}
|
||||
});
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
if (data != null) {
|
||||
return data.size();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void setRoomActClickListener(RoomActClickListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public interface RoomActClickListener {
|
||||
void onWebClick(String url);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.yizhuan.erban.home.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import com.netease.nim.uikit.support.glide.GlideApp
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.firstcharge.FirstChargeDialog
|
||||
import com.yizhuan.erban.shipantics.PullRadishActivity
|
||||
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.webview.room_banner.RoomBannerWebDialogActivity
|
||||
import com.yizhuan.erban.ui.widget.rollviewpager.adapter.StaticPagerAdapter
|
||||
import com.yizhuan.erban.utils.CommonJumpHelper
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
|
||||
import com.yizhuan.xchat_android_core.room.model.AvRoomModel
|
||||
import com.yizhuan.xchat_android_library.utils.config.BasicConfig
|
||||
import okhttp3.internal.filterList
|
||||
|
||||
class RoomActAdapter(private val mContext: Context, private val data: List<BannerInfo>) :
|
||||
StaticPagerAdapter() {
|
||||
override fun getView(container: ViewGroup, position: Int): View {
|
||||
val view = LayoutInflater.from(mContext).inflate(R.layout.item_room_act, container, false)
|
||||
val ivCover = view.findViewById<ImageView>(R.id.iv_cover)
|
||||
val bannerInfo = data[position]
|
||||
val actId = bannerInfo.bannerId.toString()
|
||||
ivCover.scaleType = ImageView.ScaleType.CENTER_CROP
|
||||
if (bannerInfo.isFairy) {
|
||||
ivCover.setImageResource(R.drawable.ic_fairy_entrance)
|
||||
} else if (bannerInfo.isFirstCharge) {
|
||||
ivCover.setImageResource(R.drawable.ic_first_charge_enter)
|
||||
} else if (bannerInfo.isBox) {
|
||||
GlideApp.with(BasicConfig.INSTANCE.appContext)
|
||||
.load(GoldBoxHelper.getBoxIcon())
|
||||
.error(R.drawable.icon_room_treasure_box)
|
||||
.into(ivCover)
|
||||
} else if (bannerInfo.isRadish) {
|
||||
ivCover.setImageResource(R.drawable.ic_radish_entrance)
|
||||
} else {
|
||||
ImageLoadUtils.loadImage(
|
||||
mContext,
|
||||
bannerInfo.bannerPic,
|
||||
ivCover,
|
||||
R.drawable.default_cover
|
||||
)
|
||||
}
|
||||
ivCover.setOnClickListener { v: View? ->
|
||||
if (bannerInfo.isFairy) {
|
||||
HomeFairyActivity.start(mContext)
|
||||
} else if (bannerInfo.isFirstCharge) {
|
||||
FirstChargeDialog.start(mContext)
|
||||
} else if (bannerInfo.isBox) {
|
||||
GoldBoxHelper.handleBoxClick(mContext)
|
||||
} else if (bannerInfo.isRadish) {
|
||||
PullRadishActivity.start(mContext)
|
||||
} else {
|
||||
AvRoomModel.get().activityClickLog("2", actId).subscribe()
|
||||
if (bannerInfo.skipType == 3) {
|
||||
val list = data.filterList {
|
||||
skipType == 3
|
||||
}
|
||||
val newPosition = list.indexOfFirst {
|
||||
it == bannerInfo
|
||||
}
|
||||
RoomBannerWebDialogActivity.start(mContext, newPosition, list)
|
||||
} else {
|
||||
CommonJumpHelper.bannerJump(mContext, bannerInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
return view
|
||||
}
|
||||
|
||||
override fun getCount(): Int {
|
||||
return data.size
|
||||
}
|
||||
}
|
||||
@@ -7,66 +7,78 @@ import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import androidx.constraintlayout.widget.Group
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.google.android.flexbox.AlignItems
|
||||
import com.google.android.flexbox.FlexDirection
|
||||
import com.opensource.svgaplayer.SVGAImageView
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.audio.helper.AudioPlayerHelper
|
||||
import com.yizhuan.erban.audio.helper.OnPlayListener
|
||||
import com.yizhuan.erban.avroom.activity.AVRoomActivity
|
||||
import com.yizhuan.erban.ui.im.avtivity.NimP2PMessageActivity
|
||||
import com.yizhuan.erban.ui.user.activity.UserInfoActivity
|
||||
import com.yizhuan.erban.ui.user.adapter.UserInfoLabelAdapter
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtils
|
||||
import com.yizhuan.erban.ui.utils.loadAvatar
|
||||
import com.yizhuan.erban.ui.utils.loadFromAssets
|
||||
import com.yizhuan.erban.view.GenderAgeTextView
|
||||
import com.yizhuan.xchat_android_core.Constants
|
||||
import com.yizhuan.xchat_android_core.manager.AudioEngineManager
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfo
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfo.SoundBean
|
||||
import com.yizhuan.xchat_android_core.utils.CurrentTimeUtils
|
||||
import com.yizhuan.xchat_android_core.utils.StarUtils
|
||||
import com.yizhuan.xchat_android_core.utils.ifNullOrEmpty
|
||||
import com.yizhuan.xchat_android_library.common.widget.LinesFlexBoxLayoutManager
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils
|
||||
import java.util.*
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import java.util.Date
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class RoomNewFriendsAdapter :
|
||||
BaseQuickAdapter<UserInfo, BaseViewHolder>(R.layout.item_room_new_friends) {
|
||||
|
||||
private var disposable: Disposable? = null
|
||||
|
||||
private var isMute = false
|
||||
private var isRemoteMute = false
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: UserInfo) {
|
||||
helper.getView<ImageView>(R.id.iv_avatar).loadAvatar(item.avatar)
|
||||
helper.setText(R.id.tv_desc, item.userDesc.ifNullOrEmpty { "我是个默认签名" })
|
||||
.setText(
|
||||
R.id.tv_age,
|
||||
((CurrentTimeUtils.getCurrentTime() - item.birth) / 1000 / 60 / 60 / 24 / 365).toString()
|
||||
)
|
||||
|
||||
val tvGenderAge = helper.getView<GenderAgeTextView>(R.id.tv_gender_age)
|
||||
tvGenderAge.setBirthDay(item.birth)
|
||||
tvGenderAge.setGender(item.gender)
|
||||
|
||||
//设置星座
|
||||
val star = StarUtils.getConstellation(Date(item.birth))
|
||||
helper.setGone(R.id.tv_constellation, star != null)
|
||||
.setText(R.id.tv_constellation, star)
|
||||
helper.setBackgroundRes(
|
||||
R.id.ll_gender_age,
|
||||
if (item.gender == 1) R.drawable.shape_65d3f7_corner else R.drawable.shape_ff9cce_corner
|
||||
)
|
||||
helper.setImageResource(
|
||||
R.id.iv_gender,
|
||||
if (item.gender == 1) R.drawable.ic_home_man else R.drawable.ic_home_woman
|
||||
)
|
||||
val tvTalk = helper.getView<TextView>(R.id.tv_talk)
|
||||
val viewOnline = helper.getView<View>(R.id.view_online)
|
||||
val groupParty = helper.getView<Group>(R.id.group_party)
|
||||
helper.setImageResource(R.id.iv_constellation, star)
|
||||
|
||||
viewOnline.isVisible = item.inOnline
|
||||
if(item.inMic){
|
||||
groupParty.visibility = View.VISIBLE
|
||||
} else {
|
||||
groupParty.visibility = View.INVISIBLE
|
||||
}
|
||||
val tvTalk = helper.getView<TextView>(R.id.tv_talk)
|
||||
|
||||
helper.setVisible(
|
||||
R.id.view_online, if (item.inMic) {
|
||||
false
|
||||
} else item.inOnline
|
||||
)
|
||||
helper.setVisible(R.id.group_party, item.inMic)
|
||||
|
||||
if (item.inRoomUid != 0L) {
|
||||
tvTalk.text = "去找TA"
|
||||
tvTalk.setOnClickListener {
|
||||
AVRoomActivity.start(mContext, item.inRoomUid)
|
||||
AVRoomActivity.startForFromType(
|
||||
mContext,
|
||||
item.inRoomUid,
|
||||
AVRoomActivity.FROM_TYPE_USER,
|
||||
item.nick,
|
||||
item.uid.toString()
|
||||
)
|
||||
}
|
||||
} else {
|
||||
tvTalk.text = "和TA聊"
|
||||
@@ -100,20 +112,21 @@ class RoomNewFriendsAdapter :
|
||||
)
|
||||
}
|
||||
|
||||
if (item.audioCard != null && !TextUtils.isEmpty(item.audioCard.audioUrl)) {
|
||||
if (item.userVoice.isNullOrBlank()) {
|
||||
helper.getView<AppCompatTextView>(R.id.tv_desc).visibility = View.VISIBLE
|
||||
helper.getView<LinearLayout>(R.id.llAudio).visibility = View.GONE
|
||||
} else {
|
||||
helper.getView<AppCompatTextView>(R.id.tv_desc).visibility = View.GONE
|
||||
helper.getView<LinearLayout>(R.id.llAudio).visibility = View.VISIBLE
|
||||
|
||||
helper.getView<AppCompatTextView>(R.id.tvAudio).text = item.audioCard.second.toString()
|
||||
helper.getView<AppCompatTextView>(R.id.tvAudio).text = item.voiceDura.toString()
|
||||
helper.getView<LinearLayout>(R.id.llAudio)
|
||||
.setOnClickListener { v -> toggleAudio(item.audioCard) }
|
||||
} else {
|
||||
helper.getView<AppCompatTextView>(R.id.tv_desc).visibility = View.VISIBLE
|
||||
helper.getView<LinearLayout>(R.id.llAudio).visibility = View.GONE
|
||||
.setOnClickListener { toggleAudio(helper, item) }
|
||||
helper.setImageResource(R.id.liv_user, R.drawable.ic_sound_wave)
|
||||
}
|
||||
|
||||
val mLabelRecyclerView = helper.getView<RecyclerView>(R.id.mLabelRecyclerView)
|
||||
if(!ListUtils.isListEmpty(item.labels)){
|
||||
if (!ListUtils.isListEmpty(item.labels)) {
|
||||
mLabelRecyclerView.visibility = View.VISIBLE
|
||||
val userInfoLabelAdapter = UserInfoLabelAdapter()
|
||||
|
||||
@@ -131,8 +144,91 @@ class RoomNewFriendsAdapter :
|
||||
|
||||
}
|
||||
|
||||
private fun toggleAudio(audioCard: SoundBean) {
|
||||
|
||||
private fun toggleAudio(holder: BaseViewHolder, item: UserInfo) {
|
||||
if (item.isVoicePlaying) {
|
||||
stopAudio()
|
||||
} else {
|
||||
playAudio(holder, item)
|
||||
}
|
||||
}
|
||||
|
||||
private fun stopAudio() {
|
||||
AudioPlayerHelper.get().endPlay()
|
||||
}
|
||||
|
||||
private fun resetAudioUI(holder: BaseViewHolder, item: UserInfo) {
|
||||
item.isVoicePlaying = false
|
||||
|
||||
disposable?.dispose()
|
||||
holder.setImageResource(R.id.iv_audio_control, R.drawable.ic_sound_pause)
|
||||
holder.setText(R.id.tvAudio, item.voiceDura.toString())
|
||||
|
||||
val svgaImageView = holder.getView<SVGAImageView>(R.id.liv_user)
|
||||
svgaImageView.stopAnimation()
|
||||
svgaImageView.setImageResource(R.drawable.ic_sound_wave)
|
||||
|
||||
AvRoomDataManager.get().mCurrentRoomInfo?.run {
|
||||
AudioEngineManager.get().isRemoteMute = isRemoteMute //非靜音
|
||||
AudioEngineManager.get().isMute = isMute //能説話
|
||||
AudioEngineManager.get().setRole(
|
||||
if (isRemoteMute) Constants.CLIENT_ROLE_AUDIENCE else Constants.CLIENT_ROLE_BROADCASTER
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun playAudio(holder: BaseViewHolder, item: UserInfo) {
|
||||
AudioPlayerHelper.get().endPlay()
|
||||
|
||||
item.isVoicePlaying = true
|
||||
|
||||
|
||||
holder.setImageResource(R.id.iv_audio_control, R.drawable.ic_sound_start)
|
||||
val svgaImageView = holder.getView<SVGAImageView>(R.id.liv_user)
|
||||
svgaImageView.loadFromAssets("svga/home_voice_playing.svga")
|
||||
|
||||
disposable = Observable.interval(1L, TimeUnit.SECONDS)
|
||||
.subscribeOn(Schedulers.computation())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.map { it + 1 }
|
||||
.takeUntil { it == item.voiceDura.toLong() }
|
||||
.subscribe {
|
||||
holder.setText(R.id.tvAudio, (item.voiceDura - it).toString())
|
||||
}
|
||||
|
||||
AvRoomDataManager.get().mCurrentRoomInfo?.run {
|
||||
isRemoteMute = AudioEngineManager.get().isRemoteMute
|
||||
isMute = AudioEngineManager.get().isMute
|
||||
AudioEngineManager.get().isRemoteMute = true //設置靜音
|
||||
AudioEngineManager.get().isMute = true //不能説話
|
||||
AudioEngineManager.get().setRole(Constants.CLIENT_ROLE_AUDIENCE)
|
||||
}
|
||||
|
||||
AudioPlayerHelper.get().playInThread(item.userVoice, object : OnPlayListener {
|
||||
override fun onError(error: String) {
|
||||
SingleToastUtil.showToast(mContext.getString(R.string.me_error_playing))
|
||||
resetAudioUI(holder, item)
|
||||
}
|
||||
|
||||
override fun onPrepared() {}
|
||||
override fun onPlaying(currDuration: Long) {}
|
||||
override fun onCompletion() {
|
||||
resetAudioUI(holder, item)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onViewDetachedFromWindow(holder: BaseViewHolder) {
|
||||
super.onViewDetachedFromWindow(holder)
|
||||
|
||||
val position = holder.absoluteAdapterPosition
|
||||
|
||||
if (position < 0 || position >= data.size) {
|
||||
return
|
||||
}
|
||||
|
||||
val item = data[position]
|
||||
if (item.isVoicePlaying) {
|
||||
stopAudio()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,11 +104,11 @@ class AccompanyFragment : BaseViewBindingFragment<FragmentAccompanyBinding>() {
|
||||
it?.let {
|
||||
if (it.isNotEmpty()) {
|
||||
binding.mLiCreateRoom.visibility = View.GONE
|
||||
binding.mRecyclerChat.visibility = View.VISIBLE
|
||||
binding.nsHost.visibility = View.VISIBLE
|
||||
charAdapter.setNewData(it)
|
||||
} else {
|
||||
binding.mLiCreateRoom.visibility = View.VISIBLE
|
||||
binding.mRecyclerChat.visibility = View.GONE
|
||||
binding.nsHost.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -148,7 +148,7 @@ class AccompanyFragment : BaseViewBindingFragment<FragmentAccompanyBinding>() {
|
||||
private fun showGameGuide(){
|
||||
val userInfo = UserModel.get().cacheLoginUserInfo
|
||||
if (userInfo?.isHasPermitRoom == true) {
|
||||
binding.ivGameGuide.visibility = View.VISIBLE
|
||||
binding.ivGameGuide.visibility = View.GONE
|
||||
} else {
|
||||
binding.ivGameGuide.visibility = View.GONE
|
||||
}
|
||||
|
||||
@@ -10,22 +10,29 @@ import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.application.IReportConstants
|
||||
import com.yizhuan.erban.application.ReportManager
|
||||
import com.yizhuan.erban.avroom.activity.AVRoomActivity
|
||||
import com.yizhuan.erban.base.BaseViewBindingFragment
|
||||
import com.yizhuan.erban.databinding.FragmentHomeBinding
|
||||
import com.yizhuan.erban.home.HomeViewModel
|
||||
import com.yizhuan.erban.home.adapter.PartyMagicIndicatorAdapter
|
||||
import com.yizhuan.erban.home.helper.BannerHelper
|
||||
import com.yizhuan.erban.home.adapter.HomeBannerAdapter
|
||||
import com.yizhuan.erban.home.dialog.RecommendRoomDialog
|
||||
import com.yizhuan.erban.home.helper.OpenRoomHelper
|
||||
import com.yizhuan.erban.ui.im.avtivity.NimP2PMessageActivity
|
||||
import com.yizhuan.erban.ui.search.SearchActivity
|
||||
import com.yizhuan.erban.ui.user.adapter.MainIndicatorAdapter
|
||||
import com.yizhuan.erban.ui.user.adapter.UserInfoIndicatorAdapter
|
||||
import com.yizhuan.erban.ui.utils.load
|
||||
import com.yizhuan.erban.ui.webview.CommonWebViewActivity
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.ViewPagerHelper
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
|
||||
import com.yizhuan.erban.utils.CommonJumpHelper
|
||||
import com.yizhuan.xchat_android_core.DemoCache
|
||||
import com.yizhuan.xchat_android_core.UriProvider
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeTagInfo
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil
|
||||
import com.zhpan.bannerview.BannerViewPager
|
||||
|
||||
/**
|
||||
* Peko首页
|
||||
@@ -37,27 +44,95 @@ class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClic
|
||||
private val mTabInfoList = mutableListOf<HomeTagInfo>()
|
||||
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
|
||||
private var mBanner: BannerViewPager<BannerInfo>? = null
|
||||
|
||||
companion object {
|
||||
private const val TAG = "HomeFragment"
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
mBanner = view?.findViewById(R.id.banner)
|
||||
initTitleTab()
|
||||
initListener()
|
||||
homeViewModel.bannerLiveData.observe(this) {
|
||||
it?.let {
|
||||
BannerHelper.setBanner(binding.rollView, it) { _, _ ->
|
||||
//首页_banner
|
||||
ReportManager.get().reportEvent(
|
||||
IReportConstants.MODULE_HOMEPAGE_CLICK, mapOf(
|
||||
Pair(IReportConstants.HOMEPAGE_TYPE, IReportConstants.SIX),
|
||||
Pair(IReportConstants.MODULE, IReportConstants.PEKO_HOMEPAGE)
|
||||
)
|
||||
)
|
||||
if (ListUtils.isListEmpty(it)) {
|
||||
mBanner?.visibility = View.GONE
|
||||
return@let
|
||||
}
|
||||
mBanner?.visibility = View.VISIBLE
|
||||
mBanner?.adapter = HomeBannerAdapter()
|
||||
mBanner?.post {
|
||||
mBanner?.apply {
|
||||
this.setPageMargin(UIUtil.dip2px(mContext, 8.0))
|
||||
.setScrollDuration(800)
|
||||
.setOnPageClickListener { _: View?, position: Int ->
|
||||
//首页_banner
|
||||
ReportManager.get().reportEvent(
|
||||
IReportConstants.MODULE_HOMEPAGE_CLICK, mapOf(
|
||||
Pair(IReportConstants.HOMEPAGE_TYPE, IReportConstants.SIX),
|
||||
Pair(IReportConstants.MODULE, IReportConstants.PEKO_HOMEPAGE)
|
||||
)
|
||||
)
|
||||
CommonJumpHelper.bannerJump(context, it[position])
|
||||
}
|
||||
.create(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
homeViewModel.currentResourceLiveData.observe(this) {
|
||||
it?.let {
|
||||
if(it.size != 2){
|
||||
binding.csResource.visibility = View.GONE
|
||||
return@observe
|
||||
}
|
||||
binding.csResource.visibility = View.VISIBLE
|
||||
val resourceViews = arrayOf(
|
||||
binding.ivResource0,
|
||||
binding.ivResource1
|
||||
)
|
||||
for (i in resourceViews.indices) {
|
||||
resourceViews[i].load(it[i].icon)
|
||||
resourceViews[i].setOnClickListener { _ ->
|
||||
when {
|
||||
it[i].resourceType == 5 -> {
|
||||
CommonWebViewActivity.start(context, it[i].resourceContent)
|
||||
}
|
||||
i == 3 -> {
|
||||
dialogManager.showProgressDialog(mContext)
|
||||
homeViewModel.getHomeChatPick()
|
||||
}
|
||||
else -> {
|
||||
dialogManager.showProgressDialog(mContext)
|
||||
homeViewModel.getResourceJumpInfo(it[i].id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
homeViewModel.resourceJumpLiveData.observe(this) {
|
||||
dialogManager.dismissDialog()
|
||||
it?.let {
|
||||
if (it.isPick) {
|
||||
AVRoomActivity.start(context, it.uid)
|
||||
} else {
|
||||
RecommendRoomDialog.newInstance(it).show(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
homeViewModel.homeChatPickLiveData.observe(viewLifecycleOwner) {
|
||||
dialogManager.dismissDialog()
|
||||
it?.let {
|
||||
if (it.isNotEmpty()) {
|
||||
NimP2PMessageActivity.start(context, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
homeViewModel.getBannerInfo()
|
||||
homeViewModel.getCurrentResourceInfo()
|
||||
}
|
||||
|
||||
private fun initListener() {
|
||||
@@ -146,6 +221,7 @@ class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClic
|
||||
|
||||
}
|
||||
ViewPagerHelper.bind(binding.magicIndicator, binding.viewPager)
|
||||
binding.viewPager.offscreenPageLimit = 1
|
||||
}
|
||||
|
||||
override fun onItemSelect(position: Int, view: TextView?) {
|
||||
|
||||
@@ -241,7 +241,7 @@ class MeFragment : BaseFragment(), View.OnClickListener {
|
||||
copyName(it.erbanNo.toString())
|
||||
}
|
||||
val star = StarUtils.getConstellation(Date(it.birth))
|
||||
mBinding.tvConstellation.text = star
|
||||
mBinding.ivConstellation.setImageResource(star)
|
||||
setUserLevel(it.userLevelVo)
|
||||
setWalletInfo()
|
||||
|
||||
@@ -396,6 +396,7 @@ class MeFragment : BaseFragment(), View.OnClickListener {
|
||||
when (v.id) {
|
||||
R.id.iv_user_head, R.id.rl_user_info ->
|
||||
mUserInfo?.let { UIHelper.showUserInfoAct(mContext, it.uid) }
|
||||
|
||||
R.id.iv_edit ->
|
||||
mUserInfo?.let { UIHelper.showUserInfoModifyAct(mContext, it.uid) }
|
||||
|
||||
@@ -405,12 +406,14 @@ class MeFragment : BaseFragment(), View.OnClickListener {
|
||||
AttentionListActivity::class.java
|
||||
)
|
||||
)
|
||||
|
||||
R.id.ll_user_fans -> startActivity(
|
||||
Intent(
|
||||
mContext,
|
||||
FansListActivity::class.java
|
||||
)
|
||||
)
|
||||
|
||||
R.id.me_item_wallet -> {
|
||||
//进入充值页面埋点
|
||||
val goldWalletInfo = PayModel.get().currentWalletInfo
|
||||
@@ -421,17 +424,10 @@ class MeFragment : BaseFragment(), View.OnClickListener {
|
||||
}
|
||||
map[IReportConstants.MODULE] = IReportConstants.PEKO_PAY
|
||||
ReportManager.get().reportEvent(IReportConstants.PAYPAGE_SHOW, map)
|
||||
if (AppMetaDataUtil.getChannelID().equals(Constants.GOOGLE)) {
|
||||
ChargeActivity.start(mContext)
|
||||
} else {
|
||||
CommonWebViewActivity.start(
|
||||
context, UriProvider.getOfficialPay(
|
||||
4,
|
||||
DeviceUtil.getDeviceId(context)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
jumpChargePage()
|
||||
}
|
||||
|
||||
R.id.me_item_vip -> {
|
||||
VipMainActivity.start(mContext)
|
||||
//进入贵族中心埋点
|
||||
@@ -444,17 +440,42 @@ class MeFragment : BaseFragment(), View.OnClickListener {
|
||||
map[IReportConstants.MODULE] = IReportConstants.PEKO_PAY
|
||||
ReportManager.get().reportEvent(IReportConstants.PAYPAGE_SHOW, map)
|
||||
}
|
||||
|
||||
R.id.ll_room -> {
|
||||
OpenRoomHelper.openRoom(context as BaseActivity?)
|
||||
}
|
||||
|
||||
R.id.ll_gain -> {
|
||||
context?.let { EarnRecordActivity.start(it) }
|
||||
}
|
||||
|
||||
R.id.ll_clean_diamonds -> {
|
||||
GiveGoldActivity.start(mContext)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun jumpChargePage() {
|
||||
PayModel.get().chargeChannel
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe({
|
||||
if (it.isNative) {
|
||||
ChargeActivity.start(mContext)
|
||||
return@subscribe
|
||||
}
|
||||
|
||||
CommonWebViewActivity.start(
|
||||
context,
|
||||
UriProvider.getOfficialPay(4, DeviceUtil.getDeviceId(context))
|
||||
)
|
||||
}, {
|
||||
toast(it.message)
|
||||
ChargeActivity.start(mContext)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,30 +3,20 @@ package com.yizhuan.erban.home.fragment
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.application.IReportConstants
|
||||
import com.yizhuan.erban.application.ReportManager
|
||||
import com.yizhuan.erban.avroom.activity.AVRoomActivity
|
||||
import com.yizhuan.erban.avroom.dialog.CreateRoomDialog
|
||||
import com.yizhuan.erban.base.BaseActivity
|
||||
import com.yizhuan.erban.base.BaseViewBindingFragment
|
||||
import com.yizhuan.erban.common.EmptyViewHelper
|
||||
import com.yizhuan.erban.databinding.FragmentRecommendBinding
|
||||
import com.yizhuan.erban.home.HomeViewModel
|
||||
import com.yizhuan.erban.home.adapter.HomeChatAdapter
|
||||
import com.yizhuan.erban.home.adapter.HomeHotAdapter
|
||||
import com.yizhuan.erban.home.adapter.HomeTopAdapter
|
||||
import com.yizhuan.erban.home.helper.BannerHelper
|
||||
import com.yizhuan.erban.home.helper.OpenRoomHelper
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil
|
||||
import com.yizhuan.erban.ui.utils.RVDelegate
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeRoomInfo
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeTabMapInfo
|
||||
import com.yizhuan.xchat_android_core.home.event.RefreshHomeDataEvent
|
||||
import com.yizhuan.xchat_android_core.room.event.RoomShieldEvent
|
||||
import com.yizhuan.xchat_android_core.user.UserModel
|
||||
import com.yizhuan.xchat_android_core.user.event.LoginUserInfoUpdateEvent
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils
|
||||
import com.zhpan.bannerview.BannerViewPager
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
@@ -35,8 +25,11 @@ import org.greenrobot.eventbus.ThreadMode
|
||||
* Peko首页
|
||||
*/
|
||||
class RecommendFragment : BaseViewBindingFragment<FragmentRecommendBinding>() {
|
||||
|
||||
private lateinit var roomHotAdapter: HomeHotAdapter
|
||||
|
||||
private lateinit var rvDelegate: RVDelegate<HomeRoomInfo>
|
||||
|
||||
private val homeViewModel: HomeViewModel by activityViewModels()
|
||||
|
||||
//是否需要刷新接口进行屏蔽房间操作
|
||||
@@ -72,11 +65,14 @@ class RecommendFragment : BaseViewBindingFragment<FragmentRecommendBinding>() {
|
||||
AVRoomActivity.start(mContext, homePlayInfo.uid)
|
||||
}
|
||||
}
|
||||
binding.mRecyclerRoom.adapter = roomHotAdapter
|
||||
rvDelegate = RVDelegate.Builder<HomeRoomInfo>()
|
||||
.setAdapter(roomHotAdapter)
|
||||
.setRecyclerView(binding.mRecyclerRoom)
|
||||
.setEmptyView(EmptyViewHelper.createEmptyTextViewHeight(context, "暂无熱門推薦"))
|
||||
.setLayoutManager(GridLayoutManager(mContext, 2))
|
||||
.build()
|
||||
homeViewModel.homeHotRoomLiveData.observe(this) {
|
||||
it?.let {
|
||||
roomHotAdapter.setNewData(it)
|
||||
}
|
||||
rvDelegate.loadData(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
package com.yizhuan.erban.main.helper;
|
||||
|
||||
import static android.Manifest.permission.POST_NOTIFICATIONS;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.common.widget.dialog.DialogManager;
|
||||
@@ -35,23 +41,35 @@ public class NoticationsUiHelper {
|
||||
private static final long CACHE_DISTANCE_TIME = 3 * TimeUtils.MILLIS_OF_A_DAY;
|
||||
|
||||
public static void handle(Activity activity, DialogManager dialogManager) {
|
||||
if (NotificationsUtils.isNotificationEnabled(activity)) {
|
||||
if (Build.VERSION.SDK_INT >= 33) {
|
||||
if (ActivityCompat.checkSelfPermission(activity, POST_NOTIFICATIONS) == PackageManager.PERMISSION_DENIED) {
|
||||
if (!ActivityCompat.shouldShowRequestPermissionRationale(activity, POST_NOTIFICATIONS)) {
|
||||
enableNotification(activity, dialogManager);
|
||||
} else {
|
||||
ActivityCompat.requestPermissions(activity, new String[]{POST_NOTIFICATIONS}, 100);
|
||||
}
|
||||
}
|
||||
} else if (NotificationsUtils.isNotificationEnabled(activity)) {
|
||||
return;
|
||||
}
|
||||
enableNotification(activity, dialogManager);
|
||||
}
|
||||
|
||||
private static void enableNotification(Activity activity, DialogManager dialogManager) {
|
||||
Single.create(new SingleOnSubscribe<String>() {
|
||||
@Override
|
||||
public void subscribe(SingleEmitter<String> emitter) throws Exception {
|
||||
long lastDialogTime = (long) SharedPreferenceUtils
|
||||
.get(KEY_NOTICATIONS_DIALOG_TIME, 0L);
|
||||
long currTime = System.currentTimeMillis();
|
||||
if (lastDialogTime == 0L || currTime - lastDialogTime >= CACHE_DISTANCE_TIME) {
|
||||
//超过三天需要重新弹窗
|
||||
emitter.onSuccess("");
|
||||
return;
|
||||
}
|
||||
emitter.onError(new Throwable("no need to show notications dialog"));
|
||||
}
|
||||
})
|
||||
@Override
|
||||
public void subscribe(SingleEmitter<String> emitter) throws Exception {
|
||||
long lastDialogTime = (long) SharedPreferenceUtils
|
||||
.get(KEY_NOTICATIONS_DIALOG_TIME, 0L);
|
||||
long currTime = System.currentTimeMillis();
|
||||
if (lastDialogTime == 0L || currTime - lastDialogTime >= CACHE_DISTANCE_TIME) {
|
||||
//超过三天需要重新弹窗
|
||||
emitter.onSuccess("");
|
||||
return;
|
||||
}
|
||||
emitter.onError(new Throwable("no need to show notications dialog"));
|
||||
}
|
||||
})
|
||||
.flatMap(new Function<String, SingleSource<String>>() {
|
||||
@Override
|
||||
public SingleSource<String> apply(String s) throws Exception {
|
||||
|
||||
@@ -8,6 +8,8 @@ import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.widget.EditText
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseActivity
|
||||
@@ -18,7 +20,6 @@ import com.yizhuan.xchat_android_core.room.bean.SearchRoomInfo
|
||||
import com.yizhuan.xchat_android_core.room.model.AvRoomModel
|
||||
import com.yizhuan.xchat_android_core.utils.net.RxHelper
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil
|
||||
import kotlinx.android.synthetic.main.activity_give_gold_search.*
|
||||
|
||||
class GiveGoldSearchActivity : BaseActivity(), TextWatcher {
|
||||
|
||||
@@ -42,7 +43,7 @@ class GiveGoldSearchActivity : BaseActivity(), TextWatcher {
|
||||
.setPageSize(Int.MAX_VALUE)
|
||||
.setEmptyView(EmptyViewHelper.createEmptyTextView(this, ResUtil.getString(R.string.pay_activity_givegoldsearchactivity_01)))
|
||||
.setLayoutManager(LinearLayoutManager(this))
|
||||
.setRecyclerView(recyclerView)
|
||||
.setRecyclerView(findViewById(R.id.recyclerView))
|
||||
.setAdapter(adapter)
|
||||
.build()
|
||||
adapter.setOnItemClickListener { _, _, position ->
|
||||
@@ -53,8 +54,8 @@ class GiveGoldSearchActivity : BaseActivity(), TextWatcher {
|
||||
})
|
||||
finish()
|
||||
}
|
||||
editSearch.addTextChangedListener(this)
|
||||
tvCancel.setOnClickListener { finish() }
|
||||
findViewById<EditText>(R.id.editSearch).addTextChangedListener(this)
|
||||
findViewById<TextView>(R.id.tvCancel).setOnClickListener { finish() }
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
|
||||
@@ -3,10 +3,10 @@ package com.yizhuan.erban.pay.activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.widget.TextView
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseActivity
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil
|
||||
import kotlinx.android.synthetic.main.activity_give_gold_success.*
|
||||
|
||||
class GiveGoldSuccessActivity : BaseActivity() {
|
||||
|
||||
@@ -24,9 +24,9 @@ class GiveGoldSuccessActivity : BaseActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_give_gold_success)
|
||||
initTitleBar(ResUtil.getString(R.string.pay_activity_givegoldsuccessactivity_01))
|
||||
tvNickname.text = "轉贈給:${intent.getStringExtra("nickname")}"
|
||||
tvGold.text = "${intent.getStringExtra("gold")?.toInt()}鉆石"
|
||||
tvSure.setOnClickListener { finish() }
|
||||
findViewById<TextView>(R.id.tvNickname).text = "轉贈給:${intent.getStringExtra("nickname")}"
|
||||
findViewById<TextView>(R.id.tvGold).text = "${intent.getStringExtra("gold")?.toInt()}鉆石"
|
||||
findViewById<TextView>(R.id.tvSure).setOnClickListener { finish() }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import android.text.TextWatcher
|
||||
import android.util.SparseArray
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.EditText
|
||||
import androidx.activity.viewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@@ -39,7 +40,6 @@ import com.yizhuan.xchat_android_core.pay.PayModel
|
||||
import com.yizhuan.xchat_android_core.user.UserModel
|
||||
import com.yizhuan.xchat_android_core.user.bean.SearchUserInfo
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil
|
||||
import kotlinx.android.synthetic.main.activity_give_gold_to_user.*
|
||||
|
||||
class GiveGoldToUserActivity : BaseViewBindingActivity<ActivityGiveGoldToUserBinding>(),
|
||||
GridPasswordNoFocusView.OnPasswordChangedListener,
|
||||
@@ -371,7 +371,7 @@ class GiveGoldToUserActivity : BaseViewBindingActivity<ActivityGiveGoldToUserBin
|
||||
if (password.length == 6) {
|
||||
searchUserInfo?.apply {
|
||||
dialogManager.showProgressDialog(context)
|
||||
PayModel.get().giveGold(uid, mEditGold.text.toString(), DESAndBase64(password))
|
||||
PayModel.get().giveGold(uid, findViewById<EditText>(R.id.mEditGold).text.toString(), DESAndBase64(password))
|
||||
.compose(bindToLifecycle())
|
||||
.doOnError {
|
||||
toast(it.message)
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
package com.yizhuan.erban.pay.presenter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.yizhuan.erban.pay.view.IChargeView;
|
||||
import com.yizhuan.xchat_android_core.pay.PayModel;
|
||||
import com.yizhuan.xchat_android_library.base.PresenterEvent;
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils;
|
||||
|
||||
/**
|
||||
* Created by MadisonRong on 05/01/2018.
|
||||
@@ -21,7 +26,16 @@ public class ChargePresenter extends PayPresenter<IChargeView> {
|
||||
refreshWalletInfo(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public void loadBanner() {
|
||||
payModel.loadChargeBanner()
|
||||
.compose(bindUntilEvent(PresenterEvent.DESTROY))
|
||||
.subscribe(list -> {
|
||||
if (ListUtils.isListEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
getMvpView().onLoadedBanners(list);
|
||||
},
|
||||
error -> ToastUtils.show(error.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
package com.yizhuan.erban.pay.view;
|
||||
|
||||
|
||||
import com.yizhuan.xchat_android_core.pay.bean.Banner;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by MadisonRong on 05/01/2018.
|
||||
*/
|
||||
|
||||
public interface IChargeView extends IPayView {
|
||||
|
||||
void onLoadedBanners(List<Banner> banners);
|
||||
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class NimTeamMessageFragment extends MessageFragment {
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
@SuppressLint("CheckResult")
|
||||
public void onNimAudioChatEvent(NimAudioChatEvent event) {
|
||||
checkPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.RECORD_AUDIO)
|
||||
checkPermission(Manifest.permission.RECORD_AUDIO)
|
||||
.subscribe(result -> {
|
||||
if (result) {
|
||||
event.getSuccess().accept(result);
|
||||
@@ -133,7 +133,7 @@ public class NimTeamMessageFragment extends MessageFragment {
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
@SuppressLint("CheckResult")
|
||||
public void onNimImageActionEvent(NimImageActionEvent event) {
|
||||
checkPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA)
|
||||
checkPermission(Manifest.permission.CAMERA)
|
||||
.subscribe(result -> {
|
||||
if (result) {
|
||||
event.getSuccess().accept(result);
|
||||
|
||||
@@ -10,7 +10,19 @@ import com.yizhuan.erban.treasurefairy.event.UpdateDataEvent
|
||||
import com.yizhuan.erban.treasurefairy.view.MyFairyItemView
|
||||
import com.yizhuan.xchat_android_core.bean.response.ListResult
|
||||
import com.yizhuan.xchat_android_core.gift.bean.SimpleUserInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.*
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.Compound
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.DrawInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.ExchangeGiftInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.FairyInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.FairyResolveParam
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.FairyTestParam
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.ForestInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.MyFairyInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.PrizeInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.ResolveInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.SendFairyInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.TestFairyRecordInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.TreasureFairyModel
|
||||
import com.yizhuan.xchat_android_core.utils.net.ServerException
|
||||
import com.yizhuan.xchat_android_core.utils.toast
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
@@ -54,7 +66,8 @@ class FairyViewModel : BaseViewModel() {
|
||||
val sendFairyRecordLiveData: LiveData<ListResult<SendFairyInfo>> = _sendFairyRecordLiveData
|
||||
|
||||
private val _compoundFairyInfosLiveData = MutableLiveData<SparseArray<FairyInfo>?>()
|
||||
val compoundFairyInfosLiveData: MutableLiveData<SparseArray<FairyInfo>?> = _compoundFairyInfosLiveData
|
||||
val compoundFairyInfosLiveData: MutableLiveData<SparseArray<FairyInfo>?> =
|
||||
_compoundFairyInfosLiveData
|
||||
|
||||
private val _testResultLiveData = MutableLiveData<Event<FairyInfo>?>()
|
||||
val testResultLiveData: MutableLiveData<Event<FairyInfo>?> = _testResultLiveData
|
||||
@@ -62,17 +75,26 @@ class FairyViewModel : BaseViewModel() {
|
||||
private val _testLegendResultLiveData = MutableLiveData<Event<FairyInfo>?>()
|
||||
val testLegendResultLiveData: MutableLiveData<Event<FairyInfo>?> = _testLegendResultLiveData
|
||||
|
||||
private val _resolveResultLiveData = MutableLiveData<Event<ResolveInfo>?>()
|
||||
val resolveResultLiveData: MutableLiveData<Event<ResolveInfo>?> = _resolveResultLiveData
|
||||
|
||||
private val _testRecordLiveData = MutableLiveData<ListResult<TestFairyRecordInfo>>()
|
||||
val testRecordLiveData: LiveData<ListResult<TestFairyRecordInfo>> = _testRecordLiveData
|
||||
|
||||
private val _exchangeGiftListLiveData = MutableLiveData<List<ExchangeGiftInfo>?>()
|
||||
val exchangeGiftListLiveData: MutableLiveData<List<ExchangeGiftInfo>?> = _exchangeGiftListLiveData
|
||||
val exchangeGiftListLiveData: MutableLiveData<List<ExchangeGiftInfo>?> =
|
||||
_exchangeGiftListLiveData
|
||||
|
||||
private val _exchangeGiftLiveData = MutableLiveData<Event<ExchangeGiftInfo>>()
|
||||
val exchangeGiftLiveData: LiveData<Event<ExchangeGiftInfo>> = _exchangeGiftLiveData
|
||||
|
||||
//精灵召唤列表
|
||||
private val _fairyCallInfoLiveData = MutableLiveData<List<ExchangeGiftInfo>?>()
|
||||
val fairyCallInfoLiveData: MutableLiveData<List<ExchangeGiftInfo>?> = _fairyCallInfoLiveData
|
||||
|
||||
private val _debrisExchangeListLiveData = MutableLiveData<List<ExchangeGiftInfo>?>()
|
||||
val debrisExchangeListLiveData: MutableLiveData<List<ExchangeGiftInfo>?> = _debrisExchangeListLiveData
|
||||
val debrisExchangeListLiveData: MutableLiveData<List<ExchangeGiftInfo>?> =
|
||||
_debrisExchangeListLiveData
|
||||
|
||||
private val _debrisExchangeLiveData = MutableLiveData<Event<ExchangeGiftInfo>>()
|
||||
val debrisExchangeLiveData: LiveData<Event<ExchangeGiftInfo>> = _debrisExchangeLiveData
|
||||
@@ -85,6 +107,9 @@ class FairyViewModel : BaseViewModel() {
|
||||
val exchangeDebrisRecordLiveData: LiveData<ListResult<ExchangeGiftInfo>> =
|
||||
_exchangeDebrisRecordLiveData
|
||||
|
||||
private val _buyDebrisLiveData = MutableLiveData<Event<Int>>()
|
||||
val buyDebrisLiveData: LiveData<Event<Int>> = _buyDebrisLiveData
|
||||
|
||||
init {
|
||||
initPrizeInfoList()
|
||||
}
|
||||
@@ -197,6 +222,21 @@ class FairyViewModel : BaseViewModel() {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 精灵召唤列表
|
||||
*/
|
||||
fun getFairyCallInfo() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_myFairyInfoLiveData.value = null
|
||||
it.message.toast()
|
||||
},
|
||||
block = {
|
||||
_myFairyInfoLiveData.value = TreasureFairyModel.getMyFairyInfo()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getFriendsList(nick: String? = null) {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
@@ -258,20 +298,21 @@ class FairyViewModel : BaseViewModel() {
|
||||
_compoundFairyInfosLiveData.value = null
|
||||
_testLegendResultLiveData.value = null
|
||||
_testResultLiveData.value = null
|
||||
_resolveResultLiveData.value = null
|
||||
val myFairyInfo = _myFairyInfoLiveData.value
|
||||
myFairyInfo?.lowElves?.forEach {
|
||||
it.selectedNum = 0
|
||||
}
|
||||
myFairyInfo?.middleElves?.forEach {
|
||||
myFairyInfo?.highElves?.forEach {
|
||||
it.selectedNum = 0
|
||||
}
|
||||
_myFairyInfoLiveData.value = myFairyInfo
|
||||
}
|
||||
|
||||
fun addTestFairy(fairyInfo: FairyInfo) {
|
||||
fun addTestFairy(fairyInfo: FairyInfo, size: Int) {
|
||||
val array = _compoundFairyInfosLiveData.value ?: SparseArray()
|
||||
|
||||
if (array.size() >= 3) {
|
||||
if (array.size() >= size) {
|
||||
"試煉爐已滿!".toast()
|
||||
} else {
|
||||
if (fairyInfo.elfNum == 0) {
|
||||
@@ -313,9 +354,9 @@ class FairyViewModel : BaseViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
fun oneKeyAdd(fairyInfos: List<FairyInfo>) {
|
||||
fun oneKeyAdd(fairyInfos: List<FairyInfo>, size: Int) {
|
||||
val compoundFairyInfos = _compoundFairyInfosLiveData.value ?: SparseArray()
|
||||
var needNum = 3 - compoundFairyInfos.size()
|
||||
var needNum = size - compoundFairyInfos.size()
|
||||
if (needNum == 0) {
|
||||
"試煉爐已滿!".toast()
|
||||
return
|
||||
@@ -327,7 +368,7 @@ class FairyViewModel : BaseViewModel() {
|
||||
compoundFairyInfos.put(nextIndex(compoundFairyInfos), it)
|
||||
}
|
||||
}
|
||||
if (needNum <= 3 && needNum != 0) {
|
||||
if (needNum <= size && needNum != 0) {
|
||||
"精靈數量不足".toast()
|
||||
return
|
||||
}
|
||||
@@ -342,21 +383,27 @@ class FairyViewModel : BaseViewModel() {
|
||||
fairyInfos.get(1) == null -> {
|
||||
1
|
||||
}
|
||||
else -> {
|
||||
fairyInfos.get(2) == null -> {
|
||||
2
|
||||
}
|
||||
fairyInfos.get(3) == null -> {
|
||||
3
|
||||
}
|
||||
else -> {
|
||||
4
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun testFairy(level: Int): Boolean {
|
||||
val fairyInfos = _compoundFairyInfosLiveData.value ?: SparseArray()
|
||||
if (fairyInfos.size() != 3) {
|
||||
if (fairyInfos.size() != 5) {
|
||||
"精靈數量不足".toast()
|
||||
return false
|
||||
}
|
||||
safeLaunch(
|
||||
onError = {
|
||||
if (level == MyFairyItemView.EPIC) {
|
||||
if (level == MyFairyItemView.LEGEND) {
|
||||
_testLegendResultLiveData.value = null
|
||||
} else {
|
||||
_testResultLiveData.value = null
|
||||
@@ -371,7 +418,7 @@ class FairyViewModel : BaseViewModel() {
|
||||
}
|
||||
fairyTestParam.level = level
|
||||
val result = TreasureFairyModel.testFairy(fairyTestParam)
|
||||
(if (level == MyFairyItemView.EPIC) {
|
||||
(if (level == MyFairyItemView.LEGEND) {
|
||||
_testLegendResultLiveData
|
||||
} else {
|
||||
_testResultLiveData
|
||||
@@ -382,6 +429,30 @@ class FairyViewModel : BaseViewModel() {
|
||||
return true
|
||||
}
|
||||
|
||||
fun resolveFairy(): Boolean {
|
||||
val fairyInfos = _compoundFairyInfosLiveData.value ?: SparseArray()
|
||||
if (fairyInfos.size() != 1) {
|
||||
"精靈數量不足".toast()
|
||||
return false
|
||||
}
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_resolveResultLiveData.value = null
|
||||
it.message.toast()
|
||||
},
|
||||
block = {
|
||||
val fairyTestParam = FairyResolveParam()
|
||||
fairyInfos.forEach { _, value ->
|
||||
fairyTestParam.expendList.add(Compound(value.elfId, 1))
|
||||
}
|
||||
val result = TreasureFairyModel.resolveFairy(fairyTestParam)
|
||||
_resolveResultLiveData.value = result?.let { Event(it[0]) }
|
||||
getMyFairyInfo()
|
||||
}
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
fun getTestFairyRecordList(
|
||||
page: Int,
|
||||
pageSize: Int
|
||||
@@ -409,6 +480,18 @@ class FairyViewModel : BaseViewModel() {
|
||||
)
|
||||
}
|
||||
|
||||
//精灵召唤列表
|
||||
fun getFairyCallList() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_fairyCallInfoLiveData.value = null
|
||||
},
|
||||
block = {
|
||||
val result = TreasureFairyModel.getFairyCallList()
|
||||
_fairyCallInfoLiveData.value = result
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getDebrisExchangeList() {
|
||||
safeLaunch(
|
||||
@@ -435,6 +518,7 @@ class FairyViewModel : BaseViewModel() {
|
||||
val result = TreasureFairyModel.exchangeGift(itemId)
|
||||
_debrisExchangeLiveData.value = result?.let { Event(it) }
|
||||
_myFairyInfoLiveData.value = TreasureFairyModel.getMyFairyInfo()
|
||||
initDrawInfo()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,4 +552,21 @@ class FairyViewModel : BaseViewModel() {
|
||||
)
|
||||
}
|
||||
|
||||
fun buyDebris(num: Int, uid: String) {
|
||||
safeLaunch(
|
||||
block = {
|
||||
TreasureFairyModel.buyDebris(num, uid)
|
||||
|
||||
_drawInfoLiveData.value?.apply {
|
||||
this.drawTicketNum = this.drawTicketNum + num
|
||||
_drawInfoLiveData.value = this
|
||||
}
|
||||
|
||||
initDrawInfo()
|
||||
|
||||
_buyDebrisLiveData.value = Event(num)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,24 +10,26 @@ import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import android.view.*
|
||||
import android.view.animation.AnimationUtils
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.activity.viewModels
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.graphics.toColorInt
|
||||
import androidx.core.widget.doAfterTextChanged
|
||||
import com.alibaba.fastjson.JSON
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseViewBindingActivity
|
||||
import com.yizhuan.erban.common.widget.dialog.DialogManager
|
||||
import com.yizhuan.erban.databinding.TreasureFairyDialogHomeBinding
|
||||
import com.yizhuan.erban.treasurefairy.dialog.ForestFairyDialog
|
||||
import com.yizhuan.erban.treasurefairy.dialog.HomeMorePopupWindow
|
||||
import com.yizhuan.erban.treasurefairy.dialog.HomePrizeDialog
|
||||
import com.yizhuan.erban.treasurefairy.dialog.MyFairyDialog
|
||||
import com.yizhuan.erban.treasure_box.activity.TreasureBoxActivity
|
||||
import com.yizhuan.erban.treasurefairy.dialog.*
|
||||
import com.yizhuan.erban.treasurefairy.view.CustomDrawable
|
||||
import com.yizhuan.erban.ui.webview.FairyDialogWebViewActivity
|
||||
import com.yizhuan.erban.utils.KeyBoardUtils
|
||||
import com.yizhuan.erban.utils.SpannableBuilder
|
||||
import com.yizhuan.xchat_android_core.UriProvider
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
@@ -40,7 +42,11 @@ import com.yizhuan.xchat_android_core.manager.RoomEvent
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.DrawInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.FairyMsgInfoBean
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.PrizeInfo
|
||||
import com.yizhuan.xchat_android_library.common.SpConstants
|
||||
import com.yizhuan.xchat_android_library.common.util.SPUtils
|
||||
import com.yizhuan.xchat_android_library.utils.FormatUtils
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
|
||||
import com.yizhuan.xchat_android_library.utils.TimeUtils
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
@@ -64,6 +70,8 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
|
||||
private var isCheck = false
|
||||
|
||||
private var mPrice = -1
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
@@ -96,16 +104,75 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
ScreenUtil.screenHeight - ScreenUtil.getStatusBarHeight(this)
|
||||
)
|
||||
window.setGravity(Gravity.BOTTOM)
|
||||
|
||||
binding.fairyItem0.isSelected = true
|
||||
looperHintPrize()
|
||||
binding.tvKeyNum.setOnClickListener {
|
||||
FairyDialogWebViewActivity.start(this, UriProvider.getFairyKey())
|
||||
|
||||
binding.viewPrice1.setOnClickListener {
|
||||
setFairyPriceSelect(1)
|
||||
}
|
||||
binding.viewPrice2.setOnClickListener {
|
||||
setFairyPriceSelect(2)
|
||||
}
|
||||
binding.viewPrice3.setOnClickListener {
|
||||
setFairyPriceSelect(3)
|
||||
}
|
||||
|
||||
binding.etQuantity.doAfterTextChanged {
|
||||
try {
|
||||
mPrice = it.toString().toInt()
|
||||
if (mPrice > TreasureBoxActivity.MAX_BUY_QUANTITY_LIMIT) {
|
||||
mPrice = TreasureBoxActivity.MAX_BUY_QUANTITY_LIMIT
|
||||
binding.etQuantity.setText(mPrice.toString())
|
||||
binding.etQuantity.setSelection(binding.etQuantity.text.length)
|
||||
SingleToastUtil.showToast(
|
||||
getString(
|
||||
R.string.treasure_box_activity_treasureboxactivity_01,
|
||||
TreasureBoxActivity.MAX_BUY_QUANTITY_LIMIT
|
||||
)
|
||||
)
|
||||
}
|
||||
setFairyPriceSelect(0)
|
||||
} catch (e: NumberFormatException) {
|
||||
e.printStackTrace()
|
||||
mPrice = -1
|
||||
}
|
||||
}
|
||||
|
||||
binding.tvBuy.setOnClickListener {
|
||||
if (mPrice < 1) {
|
||||
toast("請選擇購買的碎片數量")
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
val date = SPUtils.getLong(SpConstants.FAIRY_BUY_DEBRIS, 0L)
|
||||
if (TimeUtils.isToday(date)) {
|
||||
viewModel.buyDebris(
|
||||
mPrice,
|
||||
AuthModel.get().currentUid.toString()
|
||||
)
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
FairyBuyDebrisDialog.newInstance(mPrice).show(context)
|
||||
}
|
||||
|
||||
viewModel.buyDebrisLiveData.observe(this) {
|
||||
val date = SPUtils.getLong(SpConstants.FAIRY_BUY_SUCCESS, 0L)
|
||||
if (TimeUtils.isToday(date)) {
|
||||
ToastUtils.show("購買碎片成功")
|
||||
return@observe
|
||||
}
|
||||
|
||||
FairyBuySuccessDialog.newInstance(it.peekContent()).show(this)
|
||||
|
||||
}
|
||||
|
||||
binding.ivMyFairy.setOnClickListener {
|
||||
MyFairyDialog.newInstance().show(this)
|
||||
}
|
||||
binding.ivFairyTreasure.setOnClickListener {
|
||||
ForestFairyDialog.newInstance().show(this)
|
||||
binding.ivFairyStore.setOnClickListener {
|
||||
ExchangeFairyDialog.newInstance().show(context)
|
||||
}
|
||||
binding.ivOpen1.setOnClickListener {
|
||||
if (checkKeyNum(1)) {
|
||||
@@ -152,6 +219,16 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
isCheck = isChecked
|
||||
}
|
||||
|
||||
binding.viewBgLuckyValue.setOnClickListener {
|
||||
binding.ivRefresh.startAnimation(
|
||||
AnimationUtils.loadAnimation(
|
||||
this,
|
||||
R.anim.comm_loading
|
||||
)
|
||||
)
|
||||
viewModel.initDrawInfo()
|
||||
}
|
||||
|
||||
viewModel.prizeInfoListLiveData.observe(this) {
|
||||
it?.forEachIndexed { index, prizeInfo ->
|
||||
if (index < fairyItems.size) {
|
||||
@@ -166,6 +243,9 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
?.indexOfFirst { prize ->
|
||||
it[0].itemIndex == prize.itemIndex
|
||||
} ?: -2
|
||||
if (targetIndex >= fairyItems.size) {
|
||||
targetIndex = 0
|
||||
}
|
||||
if (targetIndex == -2) {
|
||||
viewModel.initPrizeInfoList()
|
||||
}
|
||||
@@ -177,6 +257,8 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
}
|
||||
|
||||
viewModel.drawInfoLiveData.observe(this) {
|
||||
binding.ivRefresh.clearAnimation()
|
||||
|
||||
it?.let {
|
||||
drawInfo = it
|
||||
binding.tvKeyNum.text = FormatUtils.formatBigNum(it.drawTicketNum.toString())
|
||||
@@ -184,9 +266,12 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
|
||||
binding.tvShortLuckyValue.text =
|
||||
SpannableBuilder()
|
||||
.append("幸運值達到", ForegroundColorSpan("#59FDFF".toColorInt()))
|
||||
.append("還差", ForegroundColorSpan("#59FDFF".toColorInt()))
|
||||
.append("${it.needLuckyNum}", ForegroundColorSpan("#FFE8AA".toColorInt()))
|
||||
.append("后,下次奪寶獲贈精靈球", ForegroundColorSpan("#59FDFF".toColorInt()))
|
||||
.append(
|
||||
"幸運值,額外獲贈傳説精靈",
|
||||
ForegroundColorSpan("#59FDFF".toColorInt())
|
||||
)
|
||||
.build()
|
||||
binding.ivLuckyStone.post {
|
||||
val drawable =
|
||||
@@ -202,7 +287,8 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
0f,
|
||||
binding.ivLuckyStone.width.toFloat(),
|
||||
binding.ivLuckyStone.height *
|
||||
(1 - it.luckyNum / it.needLuckyNum.toFloat().coerceAtLeast(1f)),
|
||||
(1 - it.luckyNum / (it.luckyNum + it.needLuckyNum).toFloat()
|
||||
.coerceAtLeast(1f)),
|
||||
Path.Direction.CW
|
||||
)
|
||||
drawable.setSrcPath(path)
|
||||
@@ -213,21 +299,83 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
|
||||
viewModel.showGetKeyLiveData.observe(this) {
|
||||
it.getContentIfNotHandled()?.let {
|
||||
DialogManager(context).showOkCancelDialog("購買限時裝扮活動奪寶券", "去參与", "取消") {
|
||||
DialogManager(context).showOkCancelDialog(
|
||||
"購買限時裝扮活動奪寶券",
|
||||
"去參与",
|
||||
"取消"
|
||||
) {
|
||||
FairyDialogWebViewActivity.start(context, UriProvider.getFairyKey())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setFairyPriceSelect(pos: Int) {
|
||||
if (pos == 0) {
|
||||
binding.viewPrice1.isSelected = false
|
||||
binding.viewPrice2.isSelected = false
|
||||
binding.viewPrice3.isSelected = false
|
||||
binding.ivDebris1.alpha = 0.4f
|
||||
binding.ivDebris2.alpha = 0.4f
|
||||
binding.ivDebris3.alpha = 0.4f
|
||||
binding.tvOne.alpha = 0.4f
|
||||
binding.tvTwo.alpha = 0.4f
|
||||
binding.tvThree.alpha = 0.4f
|
||||
return
|
||||
}
|
||||
|
||||
binding.etQuantity.text = null
|
||||
KeyBoardUtils.hideKeyBoard(this, binding.etQuantity)
|
||||
binding.etQuantity.clearFocus()
|
||||
|
||||
when (pos) {
|
||||
1 -> {
|
||||
mPrice = 1
|
||||
binding.viewPrice1.isSelected = true
|
||||
binding.viewPrice2.isSelected = false
|
||||
binding.viewPrice3.isSelected = false
|
||||
binding.ivDebris1.alpha = 1f
|
||||
binding.ivDebris2.alpha = 0.4f
|
||||
binding.ivDebris3.alpha = 0.4f
|
||||
binding.tvOne.alpha = 1f
|
||||
binding.tvTwo.alpha = 0.4f
|
||||
binding.tvThree.alpha = 0.4f
|
||||
}
|
||||
|
||||
2 -> {
|
||||
mPrice = 10
|
||||
binding.viewPrice1.isSelected = false
|
||||
binding.viewPrice2.isSelected = true
|
||||
binding.viewPrice3.isSelected = false
|
||||
binding.ivDebris1.alpha = 0.4f
|
||||
binding.ivDebris2.alpha = 1f
|
||||
binding.ivDebris3.alpha = 0.4f
|
||||
binding.tvOne.alpha = 0.4f
|
||||
binding.tvTwo.alpha = 1f
|
||||
binding.tvThree.alpha = 0.4f
|
||||
}
|
||||
|
||||
3 -> {
|
||||
mPrice = 100
|
||||
binding.viewPrice1.isSelected = false
|
||||
binding.viewPrice2.isSelected = false
|
||||
binding.viewPrice3.isSelected = true
|
||||
binding.ivDebris1.alpha = 0.4f
|
||||
binding.ivDebris2.alpha = 0.4f
|
||||
binding.ivDebris3.alpha = 1f
|
||||
binding.tvOne.alpha = 0.4f
|
||||
binding.tvTwo.alpha = 0.4f
|
||||
binding.tvThree.alpha = 1f
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkKeyNum(num: Int): Boolean {
|
||||
val keyNum = drawInfo?.drawTicketNum ?: 0
|
||||
if (keyNum >= num) {
|
||||
return true
|
||||
}
|
||||
DialogManager(context).showOkCancelDialog("購買限時裝扮活動奪寶券", "去參与", "取消") {
|
||||
FairyDialogWebViewActivity.start(context, UriProvider.getFairyKey())
|
||||
}
|
||||
FairyBuyDebrisModifyQuantityDialog.newInstance(num).show(this)
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -253,7 +401,7 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
fairyItems[selectIndex].isSelected = true
|
||||
}
|
||||
if ((selectIndex == targetIndex || targetIndex == -2) && minCount >= 24) {
|
||||
if(!isCheck) {
|
||||
if (!isCheck) {
|
||||
HomePrizeDialog.newInstance().show(context)
|
||||
}
|
||||
disposable?.dispose()
|
||||
@@ -320,10 +468,10 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
*/
|
||||
override fun onReceivedNimBroadcastMessage(body: String?) {
|
||||
val baseProtocol: BaseProtocol<*> = try {
|
||||
JSON.parseObject(body, BaseProtocol::class.java)
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
} ?: return
|
||||
JSON.parseObject(body, BaseProtocol::class.java)
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
} ?: return
|
||||
when (baseProtocol.first) {
|
||||
CustomAttachment.CUSTOM_MSG_BOX -> if (baseProtocol.second == CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
|
||||
val roomBoxPrizeAttachment = RoomBoxPrizeAttachment(
|
||||
@@ -364,6 +512,7 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
CustomAttachment.CUSTOM_MSG_LUCKY_SEA -> if (baseProtocol.second == CustomAttachment.CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL) {
|
||||
val attachment = RoomLuckySeaAttachment(
|
||||
CustomAttachment.CUSTOM_MSG_LUCKY_SEA,
|
||||
@@ -383,6 +532,7 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
IMNetEaseManager.get()
|
||||
.noticeRoomEvent(message, RoomEvent.LUCKY_SEA_GIFT_SERVER_NOTIFY)
|
||||
}
|
||||
|
||||
CustomAttachment.CUSTOM_MSG_LUCKY_GIFT -> if (baseProtocol.second == CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY || baseProtocol.second == CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL) {
|
||||
val attachment =
|
||||
RoomReceivedLuckyGiftAttachment(CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY)
|
||||
@@ -397,6 +547,7 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
IMNetEaseManager.get().noticeServiceLuckyBagNotice(message)
|
||||
IMNetEaseManager.get().addMessages(message)
|
||||
}
|
||||
|
||||
CustomAttachment.CUSTOM_MSG_FAIRY -> if (baseProtocol.second == CustomAttachment.CUSTOM_MSG_SUB_DRAW_GIFT_L5) {
|
||||
val attachment = FairyMsgAttachment(
|
||||
CustomAttachment.CUSTOM_MSG_FAIRY,
|
||||
@@ -412,6 +563,7 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
)
|
||||
IMNetEaseManager.get().noticeRoomEvent(message, RoomEvent.FAIRY_DRAW_GIFT_L5)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ class ExchangeDebrisAdapter :
|
||||
override fun convert(helper: BaseViewHolder, item: ExchangeGiftInfo) {
|
||||
ImageLoadUtilsV2.loadImage(helper.getView(R.id.iv_prize_icon), item.rewardPicUrl)
|
||||
helper.setText(R.id.tv_prize_name, item.getPrizeName())
|
||||
helper.setText(R.id.tv_need_num, "${item.expendNum}")
|
||||
|
||||
helper.setText(R.id.tv_value, item.expendNum.toString())
|
||||
helper.addOnClickListener(R.id.tv_exchange)
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,6 @@ class ExchangeFairyRecordAdapter :
|
||||
helper.setText(R.id.tv_time_year, formatYear.format(item.createTime))
|
||||
helper.setText(R.id.tv_time_hour, formatHour.format(item.createTime))
|
||||
helper.setText(R.id.tv_prize_name, "${item.rewardName}x${item.rewardNum}")
|
||||
helper.setText(
|
||||
R.id.tv_prize_type, when (item.convertLevel) {
|
||||
1 -> mContext.getString(R.string.fairy_primary_call)
|
||||
2 -> mContext.getString(R.string.fairy_epic_call)
|
||||
else -> mContext.getString(R.string.fairy_legend_call)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.yizhuan.erban.treasurefairy.adapter
|
||||
|
||||
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.ImageLoadUtilsV2
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.ExchangeGiftInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.PropItemInfo
|
||||
|
||||
class ExchangeSummonAdapter :
|
||||
BaseQuickAdapter<ExchangeGiftInfo, BaseViewHolder>(R.layout.treasure_fairy_item_exchange_summon) {
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: ExchangeGiftInfo) {
|
||||
ImageLoadUtilsV2.loadImage(helper.getView(R.id.iv_prize_icon), item.rewardPicUrl)
|
||||
helper.setText(R.id.tv_prize_name, item.getPrizeName())
|
||||
|
||||
val adapter: BaseQuickAdapter<PropItemInfo, BaseViewHolder> =
|
||||
object : BaseQuickAdapter<PropItemInfo, BaseViewHolder>(R.layout.item_exchange_debris) {
|
||||
override fun convert(helper: BaseViewHolder, item: PropItemInfo) {
|
||||
ImageLoadUtilsV2.loadImage(helper.getView(R.id.iv_icon), item.picUrl)
|
||||
helper.setText(R.id.tv_num, "${item.propName}x${item.propNum}")
|
||||
}
|
||||
}
|
||||
helper.getView<RecyclerView>(R.id.mRecyclerView).adapter = adapter
|
||||
item.propItems?.let {
|
||||
adapter.setNewData(it)
|
||||
}
|
||||
|
||||
helper.addOnClickListener(R.id.tv_exchange)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.yizhuan.erban.treasurefairy.adapter
|
||||
|
||||
import android.widget.ImageView
|
||||
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.load
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.FairyInfo
|
||||
import java.util.*
|
||||
|
||||
class ResolveFairyAdapter :
|
||||
BaseQuickAdapter<FairyInfo, BaseViewHolder>(R.layout.treasure_fairy_item_resolve_fairy) {
|
||||
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: FairyInfo) {
|
||||
helper.getView<ImageView>(R.id.iv_fairy_icon).load(item.elfPicUrl)
|
||||
helper.setText(R.id.tv_fairy_num, "${item.selectedNum}/${item.elfNum}")
|
||||
helper.setText(R.id.tv_fairy_name, item.elfName)
|
||||
helper.setBackgroundRes(
|
||||
R.id.ll_root,
|
||||
if (item.selectedNum > 0) R.drawable.treasure_fairy_bg_test_fairy_item_select else 0
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.yizhuan.erban.treasurefairy.adapter
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.ResolveInfo
|
||||
|
||||
class ResolveFairyResultAdapter :
|
||||
BaseQuickAdapter<ResolveInfo, BaseViewHolder>(R.layout.treasure_fairy_item_forest_prize_single_resolve) {
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: ResolveInfo) {
|
||||
helper.setText(R.id.tv_prize_name, "x${item.pieceNum}")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,8 +19,9 @@ class TestFairyRecordAdapter :
|
||||
helper.setText(R.id.tv_time_hour, formatHour.format(item.createTime))
|
||||
helper.setText(R.id.tv_prize_name, item.elfName)
|
||||
helper.setText(
|
||||
R.id.tv_prize_type, when (item.elfLevel) {
|
||||
2 -> "史詩試煉"
|
||||
R.id.tv_prize_type, when (item.type) {
|
||||
4 -> "傳說試煉"
|
||||
7 -> "精靈分解"
|
||||
else -> "傳說試煉"
|
||||
}
|
||||
)
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.yizhuan.erban.databinding.TreasureFairyDialogExchangeBinding
|
||||
import com.yizhuan.erban.treasurefairy.FairyViewModel
|
||||
import com.yizhuan.erban.treasurefairy.fragment.ExchangeDebrisFragment
|
||||
import com.yizhuan.erban.treasurefairy.fragment.ExchangeFairyFragment
|
||||
import com.yizhuan.erban.treasurefairy.fragment.ExchangeSummonFragment
|
||||
|
||||
class ExchangeFairyDialog : BaseDialog<TreasureFairyDialogExchangeBinding>() {
|
||||
|
||||
@@ -32,31 +33,31 @@ class ExchangeFairyDialog : BaseDialog<TreasureFairyDialogExchangeBinding>() {
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
binding?.ivBack?.setOnClickListener {
|
||||
binding.ivBack.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
binding?.tvRecord?.setOnClickListener {
|
||||
binding.tvRecord.setOnClickListener {
|
||||
ExchangeRecordDialog.newInstance().show(context)
|
||||
}
|
||||
binding?.rg?.setOnCheckedChangeListener { _, checkedId ->
|
||||
binding.rg.setOnCheckedChangeListener { _, checkedId ->
|
||||
when (checkedId) {
|
||||
R.id.rb_epic -> binding?.viewPager?.currentItem = 0
|
||||
R.id.rb_legend -> binding?.viewPager?.currentItem = 1
|
||||
R.id.rb_epic -> binding.viewPager.currentItem = 0
|
||||
R.id.rb_legend -> binding.viewPager.currentItem = 1
|
||||
}
|
||||
}
|
||||
binding?.viewPager?.addOnPageChangeListener(object : ViewPager.SimpleOnPageChangeListener() {
|
||||
binding.viewPager.addOnPageChangeListener(object : ViewPager.SimpleOnPageChangeListener() {
|
||||
override fun onPageSelected(position: Int) {
|
||||
when (position) {
|
||||
0 -> binding?.rg?.check(R.id.rb_epic)
|
||||
1 -> binding?.rg?.check(R.id.rb_legend)
|
||||
0 -> binding.rg.check(R.id.rb_epic)
|
||||
1 -> binding.rg.check(R.id.rb_legend)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
binding?.viewPager?.adapter = RoomVPAdapter(
|
||||
binding.viewPager.adapter = RoomVPAdapter(
|
||||
childFragmentManager,
|
||||
listOf(
|
||||
ExchangeFairyFragment.newInstance(),
|
||||
ExchangeSummonFragment.newInstance(),
|
||||
ExchangeDebrisFragment.newInstance()
|
||||
)
|
||||
)
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.yizhuan.erban.treasurefairy.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.WindowManager
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.databinding.TreasureFairyDialogBuyDebrisBinding
|
||||
import com.yizhuan.erban.treasurefairy.FairyViewModel
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_library.common.SpConstants
|
||||
import com.yizhuan.xchat_android_library.common.util.SPUtils
|
||||
|
||||
/**
|
||||
* 购买碎片
|
||||
*/
|
||||
class FairyBuyDebrisDialog : BaseDialog<TreasureFairyDialogBuyDebrisBinding>() {
|
||||
|
||||
override var width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
override var height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
override var gravity = Gravity.CENTER
|
||||
private val viewModel: FairyViewModel by activityViewModels()
|
||||
|
||||
companion object {
|
||||
fun newInstance(num: Int): FairyBuyDebrisDialog {
|
||||
val args = Bundle()
|
||||
args.putInt("num", num)
|
||||
val fragment = FairyBuyDebrisDialog()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
private val num by lazy { requireArguments().getInt("num") }
|
||||
private val price by lazy { AvRoomDataManager.get().mSeizeTreasureSwitchVo?.price ?: 0 }
|
||||
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
binding.tvDebrisNum.text = getString(R.string.buy_debris, num)
|
||||
binding.tvPrizeName.text = (num * price).toString()
|
||||
|
||||
binding.cbPay.setOnCheckedChangeListener { _, isChecked ->
|
||||
if (isChecked) {
|
||||
SPUtils.putLong(SpConstants.FAIRY_BUY_DEBRIS, System.currentTimeMillis())
|
||||
} else {
|
||||
SPUtils.putLong(SpConstants.FAIRY_BUY_DEBRIS, 0L)
|
||||
}
|
||||
}
|
||||
|
||||
binding.tvBuy.setOnClickListener {
|
||||
viewModel.buyDebris(num, AuthModel.get().currentUid.toString())
|
||||
}
|
||||
|
||||
viewModel.buyDebrisLiveData.observe(this) {
|
||||
it.getContentIfNotHandled()?.let {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.yizhuan.erban.treasurefairy.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.WindowManager
|
||||
import androidx.core.widget.doAfterTextChanged
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.databinding.TreasureFairyDialogBuyDebrisModifyQuantityBinding
|
||||
import com.yizhuan.erban.treasure_box.activity.TreasureBoxActivity
|
||||
import com.yizhuan.erban.treasurefairy.FairyViewModel
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.utils.StringUtils
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
|
||||
|
||||
/**
|
||||
* 购买碎片
|
||||
*/
|
||||
class FairyBuyDebrisModifyQuantityDialog :
|
||||
BaseDialog<TreasureFairyDialogBuyDebrisModifyQuantityBinding>() {
|
||||
|
||||
override var width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
override var height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
override var gravity = Gravity.CENTER
|
||||
private val viewModel: FairyViewModel by activityViewModels()
|
||||
|
||||
companion object {
|
||||
fun newInstance(num: Int): FairyBuyDebrisModifyQuantityDialog {
|
||||
val args = Bundle()
|
||||
args.putInt("num", num)
|
||||
val fragment = FairyBuyDebrisModifyQuantityDialog()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
private var num = 0
|
||||
private val price by lazy { AvRoomDataManager.get().mSeizeTreasureSwitchVo?.price ?: 0 }
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
num = requireArguments().getInt("num")
|
||||
|
||||
binding.etNum.setText(num.toString())
|
||||
binding.tvPrizeName.text = (num * price).toString()
|
||||
|
||||
binding.ivDecrease.setOnClickListener {
|
||||
num = (num - 10).coerceAtLeast(1)
|
||||
binding.etNum.setText(num.toString())
|
||||
binding.etNum.setSelection(num.toString().length)
|
||||
binding.tvPrizeName.text = (num * price).toString()
|
||||
}
|
||||
|
||||
binding.ivIncrease.setOnClickListener {
|
||||
num = (num + 10).coerceAtMost(200)
|
||||
binding.etNum.setText(num.toString())
|
||||
binding.etNum.setSelection(num.toString().length)
|
||||
binding.tvPrizeName.text = (num * price).toString()
|
||||
}
|
||||
|
||||
binding.etNum.doAfterTextChanged {
|
||||
var n = StringUtils.toInt(binding.etNum.text.toString(), 0)
|
||||
|
||||
if (n < 1) {
|
||||
binding.etNum.setText("1")
|
||||
binding.etNum.setSelection(1)
|
||||
num = 1
|
||||
return@doAfterTextChanged
|
||||
}
|
||||
|
||||
if (n > TreasureBoxActivity.MAX_BUY_QUANTITY_LIMIT) {
|
||||
n = TreasureBoxActivity.MAX_BUY_QUANTITY_LIMIT
|
||||
binding.etNum.setText(n.toString())
|
||||
binding.etNum.setSelection(n.toString().length)
|
||||
SingleToastUtil.showToast(
|
||||
getString(
|
||||
R.string.treasure_box_activity_treasureboxactivity_01,
|
||||
TreasureBoxActivity.MAX_BUY_QUANTITY_LIMIT
|
||||
)
|
||||
)
|
||||
}
|
||||
binding.tvPrizeName.text = (n * price).toString()
|
||||
num = n
|
||||
}
|
||||
|
||||
|
||||
binding.tvBuy.setOnClickListener {
|
||||
viewModel.buyDebris(num, AuthModel.get().currentUid.toString())
|
||||
}
|
||||
|
||||
viewModel.buyDebrisLiveData.observe(this) {
|
||||
it.getContentIfNotHandled()?.let {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.yizhuan.erban.treasurefairy.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.WindowManager
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.databinding.TreasureFairyDialogBuySuccessBinding
|
||||
import com.yizhuan.erban.treasurefairy.FairyViewModel
|
||||
import com.yizhuan.xchat_android_library.common.SpConstants
|
||||
import com.yizhuan.xchat_android_library.common.util.SPUtils
|
||||
|
||||
/**
|
||||
* 购买碎片成功
|
||||
*/
|
||||
class FairyBuySuccessDialog : BaseDialog<TreasureFairyDialogBuySuccessBinding>() {
|
||||
|
||||
override var width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
override var height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
override var gravity = Gravity.CENTER
|
||||
|
||||
companion object {
|
||||
fun newInstance(num: Int): FairyBuySuccessDialog {
|
||||
val args = Bundle()
|
||||
args.putSerializable("num", num)
|
||||
val fragment = FairyBuySuccessDialog()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
private val num by lazy { requireArguments().getInt("num") }
|
||||
|
||||
@SuppressLint("CheckResult", "SetTextI18n")
|
||||
override fun init() {
|
||||
binding.tvDebrisNum.text = "x${num}"
|
||||
|
||||
binding.cbPay.setOnCheckedChangeListener { buttonView, isChecked ->
|
||||
if (isChecked) {
|
||||
SPUtils.putLong(SpConstants.FAIRY_BUY_SUCCESS, System.currentTimeMillis())
|
||||
} else {
|
||||
SPUtils.putLong(SpConstants.FAIRY_BUY_SUCCESS, 0L)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,7 +34,7 @@ class HomePrizeDialog : BaseDialog<TreasureFairyDialogHomePrizeBinding>() {
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
binding?.rootView?.setOnClickListener {
|
||||
binding.rootView.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
val prizeInfoList = viewModel.resultLiveData.value?.peekContent()
|
||||
@@ -43,7 +43,7 @@ class HomePrizeDialog : BaseDialog<TreasureFairyDialogHomePrizeBinding>() {
|
||||
prizeAdapter = HomePrizeAdapter(isSingle)
|
||||
rvDelegate = RVDelegate.Builder<PrizeInfo>()
|
||||
.setAdapter(prizeAdapter)
|
||||
.setRecyclerView(binding?.recyclerView)
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.setLayoutManager(
|
||||
if (isSingle) {
|
||||
LinearLayoutManager(context)
|
||||
|
||||
@@ -39,39 +39,39 @@ class MyFairyDialog : BaseDialog<TreasureFairyDialogMyFairyBinding>() {
|
||||
override fun init() {
|
||||
EventBus.getDefault().register(this)
|
||||
|
||||
binding?.ivBack?.setOnClickListener {
|
||||
binding.ivBack.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
binding?.ivRecord?.setOnClickListener {
|
||||
binding.ivFairyTest.setOnClickListener {
|
||||
TestFairyDialog.newInstance().show(context)
|
||||
}
|
||||
binding.ivRecord.setOnClickListener {
|
||||
MyFairyRecordDialog.newInstance().show(context)
|
||||
}
|
||||
binding?.rg?.setOnCheckedChangeListener { _, checkedId ->
|
||||
binding.rg.setOnCheckedChangeListener { _, checkedId ->
|
||||
when (checkedId) {
|
||||
R.id.rb_base -> binding?.viewPager?.currentItem = 0
|
||||
R.id.rb_epic -> binding?.viewPager?.currentItem = 1
|
||||
R.id.rb_legend -> binding?.viewPager?.currentItem = 2
|
||||
R.id.rb_base -> binding.viewPager.currentItem = 0
|
||||
R.id.rb_legend -> binding.viewPager.currentItem = 1
|
||||
}
|
||||
}
|
||||
binding?.viewPager?.addOnPageChangeListener(object : ViewPager.SimpleOnPageChangeListener() {
|
||||
binding.viewPager.addOnPageChangeListener(object : ViewPager.SimpleOnPageChangeListener() {
|
||||
override fun onPageSelected(position: Int) {
|
||||
when (position) {
|
||||
0 -> binding?.rg?.check(R.id.rb_base)
|
||||
1 -> binding?.rg?.check(R.id.rb_epic)
|
||||
2 -> binding?.rg?.check(R.id.rb_legend)
|
||||
0 -> binding.rg.check(R.id.rb_base)
|
||||
1 -> binding.rg.check(R.id.rb_legend)
|
||||
}
|
||||
DemoCache.saveMyFairyIndex(position)
|
||||
}
|
||||
})
|
||||
binding?.viewPager?.adapter = RoomVPAdapter(
|
||||
binding.viewPager.adapter = RoomVPAdapter(
|
||||
childFragmentManager,
|
||||
listOf(
|
||||
MyFairyFragment.newInstance(MyFairyItemView.BASE),
|
||||
MyFairyFragment.newInstance(MyFairyItemView.EPIC),
|
||||
MyFairyFragment.newInstance(MyFairyItemView.LEGEND)
|
||||
)
|
||||
)
|
||||
|
||||
binding?.viewPager?.setCurrentItem(DemoCache.readMyFairyIndex(), false)
|
||||
binding.viewPager.setCurrentItem(DemoCache.readMyFairyIndex(), false)
|
||||
|
||||
viewModel.getMyFairyInfo()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.yizhuan.erban.treasurefairy.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.WindowManager
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.databinding.TreasureFairyDialogResolveFairyResultBinding
|
||||
import com.yizhuan.erban.treasurefairy.FairyViewModel
|
||||
import com.yizhuan.erban.treasurefairy.adapter.ResolveFairyResultAdapter
|
||||
import com.yizhuan.erban.ui.utils.RVDelegate
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.ResolveInfo
|
||||
|
||||
class ResolveFairyResultDialog : BaseDialog<TreasureFairyDialogResolveFairyResultBinding>() {
|
||||
|
||||
private lateinit var rvDelegate: RVDelegate<ResolveInfo>
|
||||
private lateinit var prizeAdapter: ResolveFairyResultAdapter
|
||||
|
||||
override var width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
override var height = WindowManager.LayoutParams.WRAP_CONTENT
|
||||
override var gravity = Gravity.CENTER
|
||||
private val viewModel: FairyViewModel by activityViewModels()
|
||||
|
||||
companion object {
|
||||
fun newInstance(resolveInfo: ResolveInfo): ResolveFairyResultDialog {
|
||||
val args = Bundle()
|
||||
args.putSerializable("resolveInfo",resolveInfo)
|
||||
val fragment = ResolveFairyResultDialog()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
private val resolveInfo by lazy { requireArguments().getSerializable("resolveInfo") as ResolveInfo }
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
binding.tvClose.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
prizeAdapter = ResolveFairyResultAdapter()
|
||||
rvDelegate = RVDelegate.Builder<ResolveInfo>()
|
||||
.setAdapter(prizeAdapter)
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.setLayoutManager(
|
||||
LinearLayoutManager(context)
|
||||
)
|
||||
.build()
|
||||
|
||||
rvDelegate.setNewData(arrayListOf(resolveInfo))
|
||||
viewModel.cleanTestParam()
|
||||
viewModel.initDrawInfo()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,33 +32,33 @@ class TestFairyDialog : BaseDialog<TreasureFairyDialogTestFairyBinding>() {
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
binding?.ivBack?.setOnClickListener {
|
||||
binding.ivBack.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
binding?.tvRecord?.setOnClickListener {
|
||||
binding.tvRecord.setOnClickListener {
|
||||
TestFairyRecordDialog.newInstance().show(context)
|
||||
}
|
||||
binding?.rg?.setOnCheckedChangeListener { _, checkedId ->
|
||||
binding.rg.setOnCheckedChangeListener { _, checkedId ->
|
||||
when (checkedId) {
|
||||
R.id.rb_epic -> binding?.viewPager?.currentItem = 0
|
||||
R.id.rb_legend -> binding?.viewPager?.currentItem = 1
|
||||
R.id.rb_epic -> binding.viewPager.currentItem = 0
|
||||
R.id.rb_legend -> binding.viewPager.currentItem = 1
|
||||
}
|
||||
}
|
||||
binding?.viewPager?.addOnPageChangeListener(object : ViewPager.SimpleOnPageChangeListener() {
|
||||
binding.viewPager.addOnPageChangeListener(object : ViewPager.SimpleOnPageChangeListener() {
|
||||
override fun onPageSelected(position: Int) {
|
||||
when (position) {
|
||||
0 -> binding?.rg?.check(R.id.rb_epic)
|
||||
1 -> binding?.rg?.check(R.id.rb_legend)
|
||||
0 -> binding.rg.check(R.id.rb_epic)
|
||||
1 -> binding.rg.check(R.id.rb_legend)
|
||||
}
|
||||
viewModel.cleanTestParam()
|
||||
}
|
||||
})
|
||||
|
||||
binding?.viewPager?.adapter = RoomVPAdapter(
|
||||
binding.viewPager.adapter = RoomVPAdapter(
|
||||
childFragmentManager,
|
||||
listOf(
|
||||
TestFairyFragment.newInstance(MyFairyItemView.BASE),
|
||||
TestFairyFragment.newInstance(MyFairyItemView.EPIC)
|
||||
TestFairyFragment.newInstance(MyFairyItemView.LEGEND)
|
||||
)
|
||||
)
|
||||
viewModel.getMyFairyInfo()
|
||||
|
||||
@@ -36,13 +36,13 @@ class TestFairyResultDialog : BaseDialog<TreasureFairyDialogTestFairyResultBindi
|
||||
private val fairyInfo by lazy { requireArguments().getSerializable("fairyInfo") as FairyInfo }
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
binding?.tvClose?.setOnClickListener {
|
||||
binding.tvClose.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
prizeAdapter = TestFairyResultAdapter()
|
||||
rvDelegate = RVDelegate.Builder<FairyInfo>()
|
||||
.setAdapter(prizeAdapter)
|
||||
.setRecyclerView(binding?.recyclerView)
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.setLayoutManager(
|
||||
LinearLayoutManager(context)
|
||||
)
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.yizhuan.erban.treasurefairy.fragment
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
@@ -21,7 +22,6 @@ import com.yizhuan.xchat_android_core.utils.toast
|
||||
class ExchangeDebrisFragment :
|
||||
BaseViewBindingFragment<TreasureFairyFragmentExchangeDebrisBinding>() {
|
||||
|
||||
|
||||
companion object {
|
||||
fun newInstance(): ExchangeDebrisFragment {
|
||||
val args = Bundle()
|
||||
@@ -49,7 +49,6 @@ class ExchangeDebrisFragment :
|
||||
)
|
||||
.setLayoutManager(GridLayoutManager(context, 2, LinearLayoutManager.VERTICAL, false))
|
||||
.build()
|
||||
viewModel.getDebrisExchangeList()
|
||||
viewModel.debrisExchangeListLiveData.observe(viewLifecycleOwner) {
|
||||
rvDelegate.setNewData(it)
|
||||
}
|
||||
@@ -61,8 +60,11 @@ class ExchangeDebrisFragment :
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.getDebrisExchangeList()
|
||||
viewModel.getMyFairyInfo()
|
||||
|
||||
binding.llMyDebris.visibility = View.VISIBLE
|
||||
binding.rvMyFairy.visibility = View.GONE
|
||||
viewModel.myFairyInfoLiveData.observe(viewLifecycleOwner) {
|
||||
it?.let {
|
||||
binding.tvDebrisNum.text = it.chipNum.toString()
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.yizhuan.erban.treasurefairy.fragment
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseViewBindingFragment
|
||||
import com.yizhuan.erban.common.EmptyViewHelper
|
||||
import com.yizhuan.erban.databinding.TreasureFairyFragmentExchangeDebrisBinding
|
||||
import com.yizhuan.erban.treasurefairy.FairyViewModel
|
||||
import com.yizhuan.erban.treasurefairy.adapter.ExchangeSummonAdapter
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2
|
||||
import com.yizhuan.erban.ui.utils.RVDelegate
|
||||
import com.yizhuan.erban.ui.utils.loadAvatar
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.ExchangeGiftInfo
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.FairyInfo
|
||||
import com.yizhuan.xchat_android_core.user.UserModel
|
||||
import com.yizhuan.xchat_android_core.utils.subAndReplaceDot
|
||||
import com.yizhuan.xchat_android_core.utils.toast
|
||||
|
||||
class ExchangeSummonFragment :
|
||||
BaseViewBindingFragment<TreasureFairyFragmentExchangeDebrisBinding>() {
|
||||
|
||||
companion object {
|
||||
fun newInstance(): ExchangeSummonFragment {
|
||||
val args = Bundle()
|
||||
val fragment = ExchangeSummonFragment()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
private val viewModel: FairyViewModel by activityViewModels()
|
||||
private lateinit var rvDelegate: RVDelegate<ExchangeGiftInfo>
|
||||
private lateinit var exchangeSummonAdapter: ExchangeSummonAdapter
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
exchangeSummonAdapter = ExchangeSummonAdapter()
|
||||
rvDelegate = RVDelegate.Builder<ExchangeGiftInfo>()
|
||||
.setAdapter(exchangeSummonAdapter)
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.setEmptyView(
|
||||
EmptyViewHelper.createEmptyTextViewNoImage(
|
||||
context,
|
||||
getString(R.string.fairy_no_further_data_is_available)
|
||||
)
|
||||
)
|
||||
.setLayoutManager(GridLayoutManager(context, 2, LinearLayoutManager.VERTICAL, false))
|
||||
.build()
|
||||
viewModel.fairyCallInfoLiveData.observe(viewLifecycleOwner) {
|
||||
rvDelegate.setNewData(it)
|
||||
}
|
||||
exchangeSummonAdapter.setOnItemChildClickListener { _, _, position ->
|
||||
exchangeSummonAdapter.getItem(position)?.let {
|
||||
dialogManager.showTipsDialog("您將要兌換“${it.getPrizeName()}”", "兌換") {
|
||||
viewModel.debrisExchange(it.itemId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.getFairyCallList()
|
||||
viewModel.getMyFairyInfo()
|
||||
|
||||
viewModel.myFairyInfoLiveData.observe(viewLifecycleOwner) {
|
||||
it?.let {
|
||||
binding.tvDebrisNum.text = it.chipNum.toString()
|
||||
}
|
||||
}
|
||||
|
||||
UserModel.get().cacheLoginUserInfo?.let {
|
||||
binding.ivAvatar.loadAvatar(it.avatar)
|
||||
binding.tvNickname.text = it.nick.subAndReplaceDot(7)
|
||||
}
|
||||
|
||||
viewModel.debrisExchangeLiveData.observe(viewLifecycleOwner) {
|
||||
it?.getContentIfNotHandled()?.let {
|
||||
"兌換成功~".toast()
|
||||
}
|
||||
}
|
||||
|
||||
val myFairyAdapter =
|
||||
object : BaseQuickAdapter<FairyInfo, BaseViewHolder>(R.layout.item_my_fairy) {
|
||||
override fun convert(helper: BaseViewHolder, item: FairyInfo) {
|
||||
ImageLoadUtilsV2.loadImage(helper.getView(R.id.iv_fairy), item.elfPicUrl)
|
||||
helper.setText(R.id.tv_count, item.elfNum.toString())
|
||||
}
|
||||
}
|
||||
binding.rvMyFairy.adapter = myFairyAdapter
|
||||
|
||||
viewModel.myFairyInfoLiveData.observe(this) {
|
||||
it?.let {
|
||||
myFairyAdapter.setNewData(it.highElves?.take(3))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -33,8 +33,6 @@ class MyFairyFragment : BaseViewBindingFragment<TreasureFairyFragmentMyFairyBind
|
||||
binding.fairyItem0,
|
||||
binding.fairyItem1,
|
||||
binding.fairyItem2,
|
||||
binding.fairyItem3,
|
||||
binding.fairyItem4
|
||||
)
|
||||
fairyItems.forEach {
|
||||
it.setFairyType(fairyType)
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.yizhuan.erban.treasurefairy.fragment
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
@@ -10,7 +12,9 @@ import com.yizhuan.erban.base.BaseViewBindingFragment
|
||||
import com.yizhuan.erban.common.EmptyViewHelper
|
||||
import com.yizhuan.erban.databinding.TreasureFairyFragmentTestFairyBinding
|
||||
import com.yizhuan.erban.treasurefairy.FairyViewModel
|
||||
import com.yizhuan.erban.treasurefairy.adapter.ResolveFairyAdapter
|
||||
import com.yizhuan.erban.treasurefairy.adapter.TestFairyAdapter
|
||||
import com.yizhuan.erban.treasurefairy.dialog.ResolveFairyResultDialog
|
||||
import com.yizhuan.erban.treasurefairy.dialog.TestFairyResultDialog
|
||||
import com.yizhuan.erban.treasurefairy.view.MyFairyItemView
|
||||
import com.yizhuan.erban.ui.utils.RVDelegate
|
||||
@@ -19,7 +23,6 @@ import com.yizhuan.xchat_android_core.treasurefairy.FairyInfo
|
||||
|
||||
class TestFairyFragment : BaseViewBindingFragment<TreasureFairyFragmentTestFairyBinding>() {
|
||||
|
||||
|
||||
companion object {
|
||||
fun newInstance(fairyType: Int): TestFairyFragment {
|
||||
val args = Bundle()
|
||||
@@ -34,6 +37,7 @@ class TestFairyFragment : BaseViewBindingFragment<TreasureFairyFragmentTestFairy
|
||||
private val viewModel: FairyViewModel by activityViewModels()
|
||||
private lateinit var rvDelegate: RVDelegate<FairyInfo>
|
||||
private lateinit var testFairyAdapter: TestFairyAdapter
|
||||
private lateinit var resolveFairyAdapter: ResolveFairyAdapter
|
||||
|
||||
private val showResultRunnable = Runnable {
|
||||
if (canShowResult) {
|
||||
@@ -51,44 +55,69 @@ class TestFairyFragment : BaseViewBindingFragment<TreasureFairyFragmentTestFairy
|
||||
resultNotShowed = true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得精灵碎片
|
||||
*/
|
||||
private val showResolveResultRunnable = Runnable {
|
||||
if (canShowResult) {
|
||||
canShowResult = false
|
||||
binding.ivBegin.isEnabled = true
|
||||
viewModel.resolveResultLiveData.value?.peekContent()?.let {
|
||||
ResolveFairyResultDialog.newInstance(it).show(context)
|
||||
}
|
||||
} else {
|
||||
resultNotShowed = true
|
||||
}
|
||||
}
|
||||
private var canShowResult = false
|
||||
private var resultNotShowed = false
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
val fairyViews = listOf(binding.ivFairy0, binding.ivFairy1, binding.ivFairy2)
|
||||
val fairyViews = listOf(
|
||||
binding.ivFairy0,
|
||||
binding.ivFairy1,
|
||||
binding.ivFairy2,
|
||||
binding.ivFairy3,
|
||||
binding.ivFairy4
|
||||
)
|
||||
val fairyResolveViews = listOf(binding.ivFairy3)
|
||||
testFairyAdapter = TestFairyAdapter()
|
||||
resolveFairyAdapter = ResolveFairyAdapter()
|
||||
rvDelegate = RVDelegate.Builder<FairyInfo>()
|
||||
.setAdapter(testFairyAdapter)
|
||||
.setEmptyView(EmptyViewHelper.createEmptyTextViewNoImage(
|
||||
context,
|
||||
getString(R.string.fairy_no_further_data_is_available)
|
||||
))
|
||||
.setAdapter(if(fairyType == MyFairyItemView.BASE) resolveFairyAdapter else testFairyAdapter)
|
||||
.setEmptyView(
|
||||
EmptyViewHelper.createEmptyTextViewNoImage(
|
||||
context,
|
||||
getString(R.string.fairy_no_further_data_is_available)
|
||||
)
|
||||
)
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.setLayoutManager(GridLayoutManager(context, 5, LinearLayoutManager.VERTICAL, false))
|
||||
.setLayoutManager(GridLayoutManager(context, if(fairyType == MyFairyItemView.BASE) 6 else 3 , LinearLayoutManager.VERTICAL, false))
|
||||
.build()
|
||||
|
||||
viewModel.myFairyInfoLiveData.observe(viewLifecycleOwner) {
|
||||
val fairyInfos = it?.let {
|
||||
when (fairyType) {
|
||||
MyFairyItemView.EPIC -> {
|
||||
it.middleElves
|
||||
}
|
||||
else -> {
|
||||
it.lowElves
|
||||
}
|
||||
}
|
||||
val fairyInfos = it?.lowElves
|
||||
if(fairyType == MyFairyItemView.BASE) {
|
||||
val list = mutableListOf<FairyInfo>()
|
||||
it?.lowElves?.take(3)?.let { it1 -> list.addAll(it1) }
|
||||
it?.highElves?.take(3)?.let { it2 -> list.addAll(it2) }
|
||||
rvDelegate.setNewData(list)
|
||||
} else {
|
||||
rvDelegate.setNewData(fairyInfos?.take(3))
|
||||
}
|
||||
rvDelegate.setNewData(fairyInfos)
|
||||
}
|
||||
|
||||
if (fairyType == MyFairyItemView.EPIC) {
|
||||
binding.tvTips.text = "點擊投入試煉傳說精靈"
|
||||
resolveFairyAdapter.setOnItemClickListener { _, _, position ->
|
||||
resolveFairyAdapter.getItem(position)?.let {
|
||||
viewModel.addTestFairy(it, 1)
|
||||
}
|
||||
}
|
||||
|
||||
testFairyAdapter.setOnItemClickListener { _, _, position ->
|
||||
testFairyAdapter.getItem(position)?.let {
|
||||
viewModel.addTestFairy(it)
|
||||
viewModel.addTestFairy(it, 5)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,20 +126,53 @@ class TestFairyFragment : BaseViewBindingFragment<TreasureFairyFragmentTestFairy
|
||||
viewModel.minusTestFairy(index)
|
||||
}
|
||||
}
|
||||
fairyResolveViews.forEachIndexed { index, imageView ->
|
||||
imageView.setOnClickListener {
|
||||
viewModel.minusTestFairy(index)
|
||||
}
|
||||
}
|
||||
binding.tvReset.setOnClickListener {
|
||||
viewModel.cleanTestParam()
|
||||
}
|
||||
binding.tvOneKeyAdd.setOnClickListener {
|
||||
viewModel.oneKeyAdd(testFairyAdapter.data)
|
||||
if (fairyType == MyFairyItemView.BASE) {
|
||||
viewModel.oneKeyAdd(resolveFairyAdapter.data, 1)
|
||||
} else {
|
||||
viewModel.oneKeyAdd(testFairyAdapter.data, 5)
|
||||
}
|
||||
}
|
||||
|
||||
if (fairyType == MyFairyItemView.EPIC) {
|
||||
if (fairyType == MyFairyItemView.BASE) {
|
||||
binding.viewBgAnim.setBackgroundResource(R.drawable.treasure_fairy_bg_test_fairy_anim_legend)
|
||||
val p = binding.ivFairy3.layoutParams as ConstraintLayout.LayoutParams
|
||||
p.verticalBias = 0.9f
|
||||
binding.tvResolveTips.visibility = View.VISIBLE
|
||||
binding.tvResolveTips.text = getString(R.string.tips_fairy_resolve_low)
|
||||
binding.viewBgTop.setBackgroundResource(R.drawable.treasure_fairy_bg_test_fairy_legend)
|
||||
binding.ivBegin.setBackgroundResource(R.drawable.treasure_fairy_bg_resolve_fairy_begin)
|
||||
binding.tvTips.text = "點擊投入需要分解的精靈"
|
||||
} else {
|
||||
binding.viewBgAnim.setBackgroundResource(R.drawable.treasure_fairy_bg_test_fairy_anim_epic)
|
||||
val p = binding.ivFairy3.layoutParams as ConstraintLayout.LayoutParams
|
||||
p.verticalBias = 0.94f
|
||||
binding.tvResolveTips.visibility = View.GONE
|
||||
binding.viewBgTop.setBackgroundResource(R.drawable.treasure_fairy_bg_test_fairy)
|
||||
binding.ivBegin.setBackgroundResource(R.drawable.treasure_fairy_bg_test_fairy_begin)
|
||||
binding.tvTips.text = "點擊投入試煉傳說精靈"
|
||||
}
|
||||
|
||||
binding.ivBegin.setOnClickListener {
|
||||
if (viewModel.testFairy(fairyType)) {
|
||||
if (fairyType == MyFairyItemView.BASE) {
|
||||
if (viewModel.resolveFairy()) {
|
||||
binding.animView.startPlay(
|
||||
requireContext().assets,
|
||||
"vap/test_fairy_anim_epic.mp4"
|
||||
)
|
||||
binding.ivBegin.isEnabled = false
|
||||
canShowResult = false
|
||||
binding.ivBegin.postDelayed(showResolveResultRunnable, 1800)
|
||||
}
|
||||
} else if (viewModel.testFairy(fairyType)) {
|
||||
binding.animView.startPlay(
|
||||
requireContext().assets,
|
||||
if (fairyType == MyFairyItemView.BASE) {
|
||||
@@ -146,15 +208,47 @@ class TestFairyFragment : BaseViewBindingFragment<TreasureFairyFragmentTestFairy
|
||||
binding.ivBegin.isEnabled = true
|
||||
}
|
||||
}
|
||||
viewModel.compoundFairyInfosLiveData.observe(viewLifecycleOwner) {
|
||||
fairyViews.forEachIndexed { index, imageView ->
|
||||
it?.get(index)?.elfPicUrl?.let { elfPicUrl ->
|
||||
imageView.load(elfPicUrl)
|
||||
} ?: run {
|
||||
imageView.setImageDrawable(null)
|
||||
|
||||
//分解碎片
|
||||
viewModel.resolveResultLiveData.observe(viewLifecycleOwner) {
|
||||
it?.getContentIfNotHandled()?.let {
|
||||
canShowResult = true
|
||||
if (resultNotShowed) {
|
||||
showResultRunnable.run()
|
||||
}
|
||||
} ?: run {
|
||||
binding.ivBegin.isEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.compoundFairyInfosLiveData.observe(viewLifecycleOwner) {
|
||||
if (fairyType == MyFairyItemView.BASE) {
|
||||
fairyResolveViews.forEachIndexed { index, imageView ->
|
||||
it?.get(index)?.elfPicUrl?.let { elfPicUrl ->
|
||||
binding.tvResolveTips.text = getString(
|
||||
if (it[index].level == FairyInfo.LEVEL_HIGH) {
|
||||
R.string.tips_fairy_resolve_high
|
||||
} else {
|
||||
R.string.tips_fairy_resolve_low
|
||||
}
|
||||
)
|
||||
imageView.load(elfPicUrl)
|
||||
} ?: run {
|
||||
binding.tvResolveTips.text = getString(R.string.tips_fairy_resolve_low)
|
||||
imageView.setImageDrawable(null)
|
||||
}
|
||||
}
|
||||
resolveFairyAdapter.notifyDataSetChanged()
|
||||
} else {
|
||||
fairyViews.forEachIndexed { index, imageView ->
|
||||
it?.get(index)?.elfPicUrl?.let { elfPicUrl ->
|
||||
imageView.load(elfPicUrl)
|
||||
} ?: run {
|
||||
imageView.setImageDrawable(null)
|
||||
}
|
||||
}
|
||||
testFairyAdapter.notifyDataSetChanged()
|
||||
}
|
||||
testFairyAdapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user