Compare commits
85 Commits
peko_relea
...
v2.0.4
Author | SHA1 | Date | |
---|---|---|---|
![]() |
f4fb164999 | ||
![]() |
6134bd508b | ||
![]() |
59adea0674 | ||
![]() |
6e9032bcb4 | ||
![]() |
9ce499c027 | ||
![]() |
dca7f68130 | ||
![]() |
3c21fe8cb6 | ||
![]() |
c0ea66522a | ||
![]() |
d4e4759994 | ||
![]() |
077cef5c26 | ||
![]() |
aebb11557a | ||
![]() |
52a73e3d08 | ||
![]() |
ac7089dc0b | ||
![]() |
2e167f2e21 | ||
![]() |
9aaa2043a4 | ||
![]() |
465f1de55c | ||
![]() |
a71b265687 | ||
![]() |
90e92e6f98 | ||
![]() |
eb4d32e6cc | ||
![]() |
92edbf42b4 | ||
![]() |
4194c492ab | ||
![]() |
d7ce32b101 | ||
![]() |
3237a772d7 | ||
![]() |
ddc65609d4 | ||
![]() |
888ee9dc4b | ||
![]() |
27f5931d30 | ||
![]() |
b4b1add221 | ||
![]() |
83f2a8f5a8 | ||
![]() |
746c0ccac4 | ||
![]() |
115d47db63 | ||
![]() |
517ad7bb38 | ||
![]() |
f87c54f0e1 | ||
![]() |
653116d3df | ||
![]() |
0ec9324f38 | ||
![]() |
475ec454ab | ||
![]() |
c3e001e70b | ||
![]() |
6965343562 | ||
![]() |
9b0b878593 | ||
![]() |
227f41e1bb | ||
![]() |
aaa5529e3c | ||
![]() |
33acf7fab5 | ||
![]() |
558328f639 | ||
![]() |
3d2d614bba | ||
![]() |
06c83e3305 | ||
![]() |
2934ad0e49 | ||
![]() |
10c7e3409e | ||
![]() |
ebf1b891db | ||
![]() |
f43afae374 | ||
![]() |
05d391bd1b | ||
![]() |
2ea4312a09 | ||
![]() |
46847b2bc7 | ||
![]() |
a95b7940f8 | ||
![]() |
090797b4d8 | ||
![]() |
8fadbea6fa | ||
![]() |
4ce884a903 | ||
![]() |
122d5842fe | ||
![]() |
12f2757861 | ||
![]() |
9d83904f20 | ||
![]() |
6b49e70f28 | ||
![]() |
c4c69169aa | ||
![]() |
3f341362bc | ||
![]() |
47749cd30f | ||
![]() |
4d1c7dc07b | ||
![]() |
167a41fd9c | ||
![]() |
b22b99af90 | ||
![]() |
0ab4fdb105 | ||
![]() |
4c3b9fdcaf | ||
![]() |
009518f019 | ||
![]() |
03ba5abd7d | ||
![]() |
d5b8ee1737 | ||
![]() |
a5094d6ead | ||
![]() |
9a6d31a711 | ||
![]() |
313675c09e | ||
![]() |
8f7d464262 | ||
![]() |
78383c9cfd | ||
![]() |
f7cd89683d | ||
![]() |
737aeaec3e | ||
![]() |
8e565c1e44 | ||
![]() |
3d5bf70208 | ||
![]() |
5211a4e256 | ||
![]() |
2fef91f1cb | ||
![]() |
0a54824057 | ||
![]() |
1c20b65a64 | ||
![]() |
348e63b45e | ||
![]() |
642f8ce309 |
@@ -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-jdk8:$kotlin_version"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@@ -2,6 +2,7 @@ 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'
|
||||
|
||||
@@ -60,16 +61,16 @@ android {
|
||||
if (abi == null) {
|
||||
abi = "universal"
|
||||
}
|
||||
outputFileName = "piko_${buildType.name}_v${defaultConfig.versionName}_${defaultConfig.versionCode}_${abi}_${date}.apk"
|
||||
outputFileName = "piko_${buildType.name}_v${defaultConfig.versionName}_${abi}_${date}.apk"
|
||||
}
|
||||
}
|
||||
|
||||
lint {
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
disable 'MissingTranslation', 'ExtraTranslation', 'ContentDescription', 'SmallSp'
|
||||
disable 'MissingTranslation'
|
||||
disable 'ExtraTranslation'
|
||||
}
|
||||
|
||||
|
||||
dataBinding {
|
||||
enabled = true
|
||||
}
|
||||
@@ -151,8 +152,6 @@ android {
|
||||
def server_url_release = '"https://api.pekolive.com/"'
|
||||
|
||||
debug {
|
||||
println("minifyEnabled = " + minify_enabled)
|
||||
|
||||
ext.enableCrashlytics = false
|
||||
ext.alwaysUpdateBuildId = false // Firebase Crashlytics禁用更新构建ID
|
||||
|
||||
@@ -160,8 +159,7 @@ android {
|
||||
buildConfigField "String", "BASE_URL_DEBUG", "BASE_URL"
|
||||
buildConfigField "String", "BASE_URL_STAGING", "BASE_URL"
|
||||
buildConfigField "String", "BASE_URL_RELEASE", server_url_release
|
||||
minifyEnabled minify_enabled.toBoolean() // 是否混淆
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
minifyEnabled false // 是否混淆
|
||||
crunchPngs false // 停用 PNG 压缩
|
||||
signingConfig signingConfigs.v2
|
||||
gradle.taskGraph.whenReady {
|
||||
@@ -215,9 +213,6 @@ 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'
|
||||
|
||||
@@ -275,7 +270,7 @@ dependencies {
|
||||
|
||||
implementation 'com.github.fodroid:XRadioGroup:v1.5'
|
||||
|
||||
api 'com.tencent.vasdolly:helper:3.0.6'
|
||||
api 'com.tencent.vasdolly:helper:3.0.3'
|
||||
implementation "io.github.tencent:vap:2.0.24"
|
||||
|
||||
implementation 'com.github.mmin18:realtimeblurview:1.2.1'
|
||||
@@ -303,7 +298,6 @@ dependencies {
|
||||
implementation 'com.contrarywind:wheelview:4.1.0'
|
||||
|
||||
implementation 'tech.sud.mgp:SudMGP-static:1.3.3.1158'
|
||||
implementation 'com.google.android.material:material:1.9.0'
|
||||
}
|
||||
|
||||
channel {
|
||||
|
15
app/proguard-rules.pro
vendored
15
app/proguard-rules.pro
vendored
@@ -99,18 +99,16 @@
|
||||
-keep class android.support.v7.** { *;}
|
||||
|
||||
#----------------EventBus事件巴士-----------------
|
||||
-keepattributes *Annotation*
|
||||
-keepclassmembers class * {
|
||||
-keepclassmembers class ** {
|
||||
@org.greenrobot.eventbus.Subscribe <methods>;
|
||||
}
|
||||
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
|
||||
# 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);
|
||||
|
||||
# Only required if you use AsyncExecutor
|
||||
-keepclassmembers class * extends 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.**
|
||||
@@ -236,7 +234,6 @@
|
||||
-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.** {*;}
|
||||
|
||||
|
||||
#百度统计
|
||||
|
@@ -355,24 +355,6 @@
|
||||
android:name=".ui.webview.CommonWebViewActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".ui.wallet.PaymentResultActivity"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTask"
|
||||
android:theme="@style/transparent_activity"
|
||||
android:windowSoftInputMode="adjustPan">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data
|
||||
android:host="payment"
|
||||
android:path="/result"
|
||||
android:scheme="pekoapp" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.webview.SimpleWebViewActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
@@ -539,7 +521,7 @@
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".treasure_box.activity.TreasureBoxActivity"
|
||||
android:theme="@style/transparent_activity" />
|
||||
android:theme="@style/dialog_web_view_activity" />
|
||||
<activity
|
||||
android:name=".treasure_box.activity.BoxRankingActivity"
|
||||
android:theme="@style/room_message_activity" />
|
||||
@@ -843,18 +825,10 @@
|
||||
<activity
|
||||
android:name=".ui.webview.DialogWebViewActivity"
|
||||
android:theme="@style/dialog_web_view_activity"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
<activity
|
||||
android:name=".ui.webview.room_banner.RoomWebDialogActivity"
|
||||
android:theme="@style/room_dialog_web_view_activity"
|
||||
android:windowSoftInputMode="adjustPan" /><!-- 隐私政策 -->
|
||||
android:windowSoftInputMode="adjustPan" /> <!-- 隐私政策 -->
|
||||
<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" />
|
||||
@@ -1112,8 +1086,6 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".avroom.room_album.RoomAlbumActivity" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
@@ -1 +0,0 @@
|
||||
[{"name":"Taiwan","abbr":"TW","mcc":"466","code":"886"},{"name":"Hong Kong","abbr":"HK","mcc":"454","code":"852"},{"name":"Singapore","abbr":"SG","mcc":"525","code":"65"},{"name":"Malaysia","abbr":"MY","mcc":"502","code":"60"},{"name":"China","abbr":"CN","mcc":"460","code":"86"}]
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -410,7 +410,6 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
}
|
||||
onParseIntent();
|
||||
handleNimIntent();
|
||||
InitialModel.get().regionCheck();
|
||||
}
|
||||
|
||||
private void onParseIntent() {
|
||||
@@ -520,7 +519,6 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onLoadLoginUserInfoEvent(LoadLoginUserInfoEvent event) {
|
||||
firstLoadedUserInfo();
|
||||
InitialModel.get().regionCheck();
|
||||
}
|
||||
|
||||
public void onLogout() {
|
||||
|
@@ -16,10 +16,7 @@ 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;
|
||||
@@ -67,7 +64,6 @@ 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;
|
||||
@@ -116,9 +112,6 @@ 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) {
|
||||
@@ -207,11 +200,10 @@ 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);
|
||||
@@ -250,13 +242,6 @@ 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;
|
||||
@@ -267,7 +252,6 @@ 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);
|
||||
|
||||
//生命周期监听
|
||||
@@ -416,13 +400,11 @@ 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 初始化
|
||||
@@ -561,18 +543,4 @@ 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()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,8 +3,6 @@ package com.yizhuan.erban.avroom.activity;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_BOX;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_CRAZY_ZOO;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_CRAZY_ZOO_SUB_ALL_ROOM;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAIRY;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT;
|
||||
@@ -16,11 +14,8 @@ 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_BOX_ALL_ROOM_NOTIFY_BY_SVGA;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_GIFT_L5;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_ROOM_PK_NOTIFY;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY_ALL;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -43,12 +38,10 @@ 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;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.netease.nimlib.sdk.NIMSDK;
|
||||
import com.netease.nimlib.sdk.Observer;
|
||||
@@ -72,7 +65,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.RedPackageHandler;
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageOpenDialog;
|
||||
import com.yizhuan.erban.avroom.view.IAvRoomView;
|
||||
import com.yizhuan.erban.avroom.widget.VerticalViewPagerAdapter;
|
||||
import com.yizhuan.erban.base.BaseMvpActivity;
|
||||
@@ -88,7 +81,10 @@ 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.AllServiceGiftLevelDialog;
|
||||
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.MonsterDialog;
|
||||
import com.yizhuan.erban.utils.UserUtils;
|
||||
import com.yizhuan.tutu.room_chat.activity.RoomMsgActivity;
|
||||
@@ -112,8 +108,6 @@ 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.RoomTemplateNotifyAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomTemplateNotifyMsgBean;
|
||||
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;
|
||||
@@ -134,6 +128,7 @@ 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;
|
||||
@@ -145,9 +140,6 @@ 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.support.room.RoomWidget;
|
||||
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;
|
||||
@@ -156,6 +148,7 @@ 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;
|
||||
@@ -167,7 +160,10 @@ 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;
|
||||
|
||||
@@ -184,7 +180,7 @@ import io.reactivex.disposables.Disposable;
|
||||
*/
|
||||
@CreatePresenter(AvRoomPresenter.class)
|
||||
public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter>
|
||||
implements View.OnClickListener, IAvRoomView, RoomView {
|
||||
implements View.OnClickListener, IAvRoomView {
|
||||
|
||||
public static final int FROM_TYPE_NORMAL = 0;
|
||||
public static final int FROM_TYPE_RECOMMEND = 1;
|
||||
@@ -222,6 +218,7 @@ 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;
|
||||
/*********************************显示全服礼物***************************************/
|
||||
@@ -229,13 +226,9 @@ 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;
|
||||
|
||||
// 是否禁用VP滑动(true:不允许滑动;false:某些条件下可以滑动)
|
||||
private boolean viewPagerInputDisable;
|
||||
|
||||
public static void start(Context context, long roomUid) {
|
||||
startForFromType(context, roomUid, FROM_TYPE_NORMAL, null, null);
|
||||
@@ -331,8 +324,7 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
}
|
||||
} else if (roomInfo.getType() == RoomInfo.ROOM_TYPE_SINGLE) {
|
||||
bgPicture[0] = "";
|
||||
// svgaRoomBg.setImageResource(R.drawable.bg_room_single_pic);
|
||||
playSvgaBg(svgaRoomBg, "svga/room_bg_single.svga");
|
||||
svgaRoomBg.setImageResource(R.drawable.bg_room_single_pic);
|
||||
} else {
|
||||
bgPicture[0] = "";
|
||||
if (roomInfo.getRoomModeType() == RoomModeType.OPEN_PK_MODE) {
|
||||
@@ -409,7 +401,7 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
public void setCurrentItem(int item) {
|
||||
dismissLoadingDialog();
|
||||
if (viewpager != null) {
|
||||
tryEnabledViewPagerInput();
|
||||
viewpager.setUserInputEnabled(true);
|
||||
viewpager.setCurrentItem(item, false);
|
||||
}
|
||||
}
|
||||
@@ -421,12 +413,6 @@ 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 {
|
||||
@@ -458,7 +444,7 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
viewpager.setOffscreenPageLimit(2);
|
||||
viewpager.setOrientation(ViewPager2.ORIENTATION_VERTICAL);
|
||||
viewpager.getChildAt(0).setOverScrollMode(View.OVER_SCROLL_NEVER);
|
||||
disableViewPagerInput();
|
||||
viewpager.setUserInputEnabled(false);
|
||||
viewpager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
@@ -485,11 +471,11 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
if (state == 0 && viewpager.getCurrentItem() == 2) {
|
||||
showLoadingDialog();
|
||||
((FakeSingleRoomFragment) mAdapter.getItem(2)).tryJumpRoom();
|
||||
disableViewPagerInput();
|
||||
viewpager.setUserInputEnabled(false);
|
||||
} else if (state == 0 && viewpager.getCurrentItem() == 0) {
|
||||
showLoadingDialog();
|
||||
((FakeSingleRoomBackFragment) mAdapter.getItem(0)).tryJumpRoom();
|
||||
disableViewPagerInput();
|
||||
viewpager.setUserInputEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -525,6 +511,8 @@ 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) {
|
||||
@@ -628,11 +616,8 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
case RoomEvent.MY_SELF_KICK_OUT_ROOM_BY_S_ADMIN:
|
||||
toBack(true);
|
||||
break;
|
||||
case RoomEvent.FAIRY_DRAW_GIFT_L5:
|
||||
ChatRoomMessage message = roomEvent.getChatRoomMessage();
|
||||
if (message != null) {
|
||||
IMNetEaseManager.get().addMessages(message);
|
||||
}
|
||||
case RoomEvent.RECEIVE_RED_PACKAGE:
|
||||
showRedPackage(AvRoomDataManager.get().mCurrentRoomInfo);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
@@ -682,14 +667,7 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
*/
|
||||
private void showRoomFragment(boolean isRoomMin) {
|
||||
mCurrentFragment = (HomePartyFragment) mAdapter.getItem(1);
|
||||
mCurrentFragment.getPlayNotifyState().observe(getLifecycleOwner(), aBoolean -> {
|
||||
if (!aBoolean) {
|
||||
if (isValid()) {
|
||||
showGiftDialog();
|
||||
}
|
||||
}
|
||||
});
|
||||
tryEnabledViewPagerInput();
|
||||
viewpager.setUserInputEnabled(AvRoomDataManager.get().isSingleRoom());
|
||||
viewpager.setCurrentItem(1, false);
|
||||
if (isRoomMin) {
|
||||
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
@@ -702,17 +680,6 @@ 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) {
|
||||
@@ -749,24 +716,42 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
AvRoomDataManager.get().release();
|
||||
}
|
||||
|
||||
/**
|
||||
* 尝试展示来源红包(在房间外点击红包入口进入房间时)
|
||||
*/
|
||||
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();
|
||||
@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 dismissRedPackageDialog() {
|
||||
if (openDialogs != null) {
|
||||
openDialogs.clear();
|
||||
}
|
||||
if (mCurrentFragment != null) {
|
||||
mCurrentFragment.dismissSendRedPackageDialog();
|
||||
}
|
||||
@@ -1091,6 +1076,7 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
DemoCache.readNewUserChargeGift() == 0) {
|
||||
DemoCache.saveNewUserChargeGift(1);
|
||||
}
|
||||
showRedPackage(AvRoomDataManager.get().mCurrentRoomInfo);
|
||||
dismissLoadingDialog();
|
||||
}
|
||||
|
||||
@@ -1222,10 +1208,17 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
return;
|
||||
giftList.add(data);
|
||||
if (second2 == CUSTOM_MSG_ALL_SERVICE_GIFT) {
|
||||
if (mCurrentFragment != null && mCurrentFragment.isShowingPlayNotify()) {
|
||||
return;
|
||||
if (giftDialog != null && giftDialog.isShowing()) {
|
||||
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
|
||||
AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst();
|
||||
if (dataBean != null) {
|
||||
return;
|
||||
} else {
|
||||
giftDialog.dismiss();
|
||||
}
|
||||
} else {
|
||||
showGiftDialog();
|
||||
}
|
||||
showGiftDialog();
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_BOX://寻爱之旅
|
||||
@@ -1292,22 +1285,6 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
IMNetEaseManager.get().noticeRoomEvent(message, RoomEvent.LUCKY_SEA_GIFT_SERVER_NOTIFY);
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_CRAZY_ZOO://疯狂动物园
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_CRAZY_ZOO_SUB_ALL_ROOM) {
|
||||
RoomLuckySeaAttachment attachment = new RoomLuckySeaAttachment(CUSTOM_MSG_CRAZY_ZOO, CUSTOM_MSG_CRAZY_ZOO_SUB_ALL_ROOM);
|
||||
attachment.setRoomLuckySeaMsgBean(JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomLuckySeaMsgBean.class));
|
||||
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), attachment);
|
||||
IMNetEaseManager.get().noticeRoomEvent(message, RoomEvent.CRAZY_ZOO_ALL_ROOM_NOTIFY);
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_TEMPLATE_NOTIFY://通用飘屏
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_TEMPLATE_NOTIFY_ALL) {
|
||||
RoomTemplateNotifyAttachment attachment = new RoomTemplateNotifyAttachment(CUSTOM_MSG_TEMPLATE_NOTIFY, CUSTOM_MSG_TEMPLATE_NOTIFY_ALL);
|
||||
attachment.setMsgBean(new Gson().fromJson(String.valueOf(baseProtocol.getData()), RoomTemplateNotifyMsgBean.class));
|
||||
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), attachment);
|
||||
IMNetEaseManager.get().noticeRoomEvent(message, RoomEvent.TEMPLATE_NOTIFY);
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_LUCKY_GIFT://福袋
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY || baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL) {
|
||||
RoomReceivedLuckyGiftAttachment attachment = new RoomReceivedLuckyGiftAttachment(CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY);
|
||||
@@ -1338,24 +1315,9 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isShowingGiftNotify() {
|
||||
if (giftDialog != null && giftDialog.isShowing()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void showGiftDialog() {
|
||||
if (!isValid()) return;
|
||||
if (giftList == null) return;
|
||||
if (giftList.size() == 0) return;
|
||||
AllServiceGiftProtocol.DataBean data = giftList.peekFirst();
|
||||
if (data == null) return;
|
||||
if (giftDialog != null && giftDialog.isShowing()) {
|
||||
return;
|
||||
}
|
||||
giftDialog = generateAllServiceGiftDialog(this, data);
|
||||
giftDialog = generateAllServiceGiftDialog(this, giftList.peekFirst());
|
||||
giftDialog.setOnDismissListener(dialog -> {
|
||||
giftList.pollFirst();
|
||||
AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst();
|
||||
@@ -1370,16 +1332,30 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
giftDialog.show();
|
||||
}
|
||||
|
||||
private AllServiceGiftLevelDialog generateAllServiceGiftDialog(@NonNull Context context, @NonNull AllServiceGiftProtocol.DataBean dataBean) {
|
||||
return new AllServiceGiftLevelDialog(context, dataBean);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
registerGiftBroadcastMessage(false);
|
||||
isResume = false;
|
||||
}
|
||||
|
||||
|
||||
private void handlePmExitRoom() {
|
||||
EventBus.getDefault().post(new PmDismissAllLimitDialogEvent());
|
||||
getMvpPresenter().exitRoom();
|
||||
@@ -1425,30 +1401,6 @@ 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;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public RoomWidget findWidget(@NonNull String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class GiftBroadcastObserver implements Observer<BroadcastMessage> {
|
||||
private WeakReference<AVRoomActivity> mReference;
|
||||
|
||||
@@ -1462,64 +1414,24 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
|
||||
String contentStr = broadcastMessage.getContent();
|
||||
Logger.i(ResUtil.getString(R.string.avroom_activity_avroomactivity_014) + contentStr);
|
||||
if (TextUtils.isEmpty(contentStr)) return;
|
||||
try {
|
||||
AVRoomActivity activity = mReference.get();
|
||||
if (activity == null) return;
|
||||
if (activity.isValid()) {
|
||||
JSONObject jsonObject;
|
||||
try {
|
||||
jsonObject = JSON.parseObject(contentStr);
|
||||
} catch (Exception e) {
|
||||
jsonObject = null;
|
||||
}
|
||||
if (jsonObject == null) return;
|
||||
if (jsonObject.containsKey("body")) {
|
||||
String body = jsonObject.getString("body");
|
||||
if (TextUtils.isEmpty(body)) return;
|
||||
activity.onReceivedGiftBroadcastMessage(body);
|
||||
}
|
||||
AVRoomActivity activity = mReference.get();
|
||||
if (activity == null) return;
|
||||
if (activity.isValid()) {
|
||||
JSONObject jsonObject;
|
||||
try {
|
||||
jsonObject = JSON.parseObject(contentStr);
|
||||
} catch (Exception e) {
|
||||
jsonObject = null;
|
||||
}
|
||||
if (jsonObject == null) return;
|
||||
if (jsonObject.containsKey("body")) {
|
||||
String body = jsonObject.getString("body");
|
||||
if (TextUtils.isEmpty(body)) return;
|
||||
activity.onReceivedGiftBroadcastMessage(body);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onReceiveChatRoomEvent(RoomEvent roomEvent) {
|
||||
super.onReceiveChatRoomEvent(roomEvent);
|
||||
switch (roomEvent.getEvent()) {
|
||||
case RoomEvent.UP_MIC:
|
||||
case RoomEvent.DOWN_MIC:
|
||||
resetViewPagerInputEnabled();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁用VP滑动
|
||||
*/
|
||||
private void disableViewPagerInput() {
|
||||
this.viewPagerInputDisable = true;
|
||||
resetViewPagerInputEnabled();
|
||||
}
|
||||
|
||||
private void tryEnabledViewPagerInput() {
|
||||
this.viewPagerInputDisable = false;
|
||||
resetViewPagerInputEnabled();
|
||||
}
|
||||
|
||||
private void resetViewPagerInputEnabled() {
|
||||
if (viewPagerInputDisable) {
|
||||
viewpager.setUserInputEnabled(false);
|
||||
} else {
|
||||
if (AvRoomDataManager.get().isSingleRoom() && !AvRoomDataManager.get().isOwnerOnMic()) {
|
||||
// 个播+没在麦位=可以滑动
|
||||
viewpager.setUserInputEnabled(true);
|
||||
} else {
|
||||
viewpager.setUserInputEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -21,7 +21,6 @@ import com.yizhuan.erban.base.BaseMvpActivity;
|
||||
import com.yizhuan.xchat_android_core.Constants;
|
||||
import com.yizhuan.xchat_android_core.noble.NobleResourceType;
|
||||
import com.yizhuan.xchat_android_core.room.bean.OnlineChatMember;
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomOnlineUserBean;
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfo;
|
||||
import com.yizhuan.xchat_android_library.base.factory.CreatePresenter;
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils;
|
||||
@@ -108,11 +107,10 @@ public class RoomInviteActivity extends BaseMvpActivity<IRoomInviteView, RoomInv
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestRoomOnlineListSuccess(List<RoomOnlineUserBean> list) {
|
||||
public void onRequestChatMemberByPageSuccess(List<OnlineChatMember> memberList, int page) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRequestChatMemberByPageFail(String errorStr, int page) {
|
||||
mPage = page;
|
||||
|
@@ -527,7 +527,7 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
/**
|
||||
* 主席位特有
|
||||
*/
|
||||
View frTitle;
|
||||
FrameLayout frTitle;
|
||||
TextView tvRoomDesc;
|
||||
ImageView ivTag;
|
||||
TextView tvLabelLeaveMode;
|
||||
|
@@ -12,20 +12,27 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.netease.nim.uikit.impl.cache.NimUserInfoCache;
|
||||
import com.netease.nimlib.sdk.RequestCallbackWrapper;
|
||||
import com.netease.nimlib.sdk.uinfo.constant.GenderEnum;
|
||||
import com.netease.nimlib.sdk.uinfo.model.NimUserInfo;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
|
||||
import com.yizhuan.erban.ui.widget.NobleAvatarView;
|
||||
import com.yizhuan.erban.utils.NamePlateHelper;
|
||||
import com.yizhuan.erban.utils.RegexUtil;
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
import com.yizhuan.xchat_android_core.level.UserLevelVo;
|
||||
import com.yizhuan.xchat_android_core.level.UserLevelResourceType;
|
||||
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.noble.NobleResourceType;
|
||||
import com.yizhuan.xchat_android_core.noble.NobleUtil;
|
||||
import com.yizhuan.xchat_android_core.room.bean.OnlineChatMember;
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomOnlineUserBean;
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfo;
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
/**
|
||||
@@ -34,17 +41,19 @@ import io.reactivex.disposables.Disposable;
|
||||
* @author Administrator
|
||||
* @date 2017/12/4
|
||||
*/
|
||||
public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<RoomOnlineUserBean, BaseViewHolder> {
|
||||
public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<OnlineChatMember, BaseViewHolder> {
|
||||
|
||||
private boolean mIsHomeParty;
|
||||
private Disposable mDisposable;
|
||||
private Context context;
|
||||
private OnRoomOnlineNumberChangeListener mListener;
|
||||
|
||||
public OnlineUserAdapter(Context context, boolean isHomeParty) {
|
||||
super(null);
|
||||
addItemType(RoomOnlineUserBean.NORMAL, R.layout.list_item_online_user);
|
||||
addItemType(RoomOnlineUserBean.NOBLE, R.layout.list_item_online_user_mystery);
|
||||
addItemType(OnlineChatMember.NORMAL, R.layout.list_item_online_user);
|
||||
addItemType(OnlineChatMember.NOBLE, R.layout.list_item_online_user_mystery);
|
||||
mIsHomeParty = isHomeParty;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,76 +63,147 @@ public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<RoomOnlineUserB
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(@NonNull BaseViewHolder helper, RoomOnlineUserBean item) {
|
||||
if (item.getItemType() == OnlineChatMember.NOBLE) {
|
||||
return;
|
||||
}
|
||||
// 性别
|
||||
final ImageView sexImage = helper.getView(R.id.sex);
|
||||
if (item.getGender() == 1) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_male);
|
||||
} else if (item.getGender() == 2) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_female);
|
||||
} else {
|
||||
sexImage.setVisibility(View.GONE);
|
||||
protected void convert(@NonNull BaseViewHolder baseViewHolder, OnlineChatMember onlineChatMember) {
|
||||
if (onlineChatMember != null && onlineChatMember.chatRoomMember != null) {
|
||||
if (onlineChatMember.getItemType() == OnlineChatMember.NORMAL) {
|
||||
setNormalData(baseViewHolder, onlineChatMember);
|
||||
} else {
|
||||
setMysteryData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 昵称
|
||||
helper.setText(R.id.nick, RegexUtil.getPrintableString(item.getNick()));
|
||||
private void setMysteryData() {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
// 头像
|
||||
NobleAvatarView nobleAvatarView = helper.getView(R.id.noble_avatar_view);
|
||||
private void setNormalData(BaseViewHolder baseViewHolder, OnlineChatMember onlineChatMember) {
|
||||
setSexData(baseViewHolder, onlineChatMember);
|
||||
|
||||
ImageView roomOnlineTag = baseViewHolder.getView(R.id.room_online_tag);
|
||||
ImageView managerLogo = baseViewHolder.getView(R.id.manager_logo);
|
||||
roomOnlineTag.setVisibility(onlineChatMember.isOnMic ? View.VISIBLE : View.GONE);
|
||||
managerLogo.setVisibility((onlineChatMember.isAdmin || onlineChatMember.isRoomOwer)
|
||||
? View.VISIBLE : View.GONE);
|
||||
managerLogo.setImageResource(onlineChatMember.isAdmin ? R.drawable.icon_admin_logo
|
||||
: R.drawable.icon_user_list_room_ownner);
|
||||
|
||||
baseViewHolder.setText(R.id.nick, RegexUtil.getPrintableString(onlineChatMember.chatRoomMember.getNick()));
|
||||
|
||||
NobleAvatarView nobleAvatarView = baseViewHolder.getView(R.id.noble_avatar_view);
|
||||
nobleAvatarView.setSize(37, 54, 0);
|
||||
nobleAvatarView.setData(item);
|
||||
nobleAvatarView.setData(onlineChatMember.chatRoomMember);
|
||||
|
||||
// 官字
|
||||
helper.getView(R.id.iv_user_official).setVisibility(item.isOfficial() ? View.VISIBLE : View.GONE);
|
||||
|
||||
// 管理
|
||||
ImageView ivManager = helper.getView(R.id.manager_logo);
|
||||
if (item.getMemberType() != null && item.getMemberType().equals("MANAGER")) {
|
||||
ivManager.setVisibility(View.VISIBLE);
|
||||
ivManager.setImageResource(R.drawable.icon_admin_logo);
|
||||
} else if (item.getMemberType() != null && item.getMemberType().equals("CREATOR")) {
|
||||
ivManager.setVisibility(View.VISIBLE);
|
||||
ivManager.setImageResource(R.drawable.icon_user_list_room_ownner);
|
||||
} else {
|
||||
ivManager.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// 在麦
|
||||
ImageView ivMic = helper.getView(R.id.room_online_tag);
|
||||
ivMic.setVisibility(item.isInMic() ? View.VISIBLE : View.GONE);
|
||||
|
||||
|
||||
//等级
|
||||
UserLevelVo levelVo = item.getUserLevelVo();
|
||||
String experLevelUrl = null;
|
||||
String charmLevelUrl = null;
|
||||
if (levelVo != null) {
|
||||
experLevelUrl = levelVo.getExperUrl();
|
||||
charmLevelUrl = levelVo.getCharmUrl();
|
||||
}
|
||||
baseViewHolder.getView(R.id.iv_user_official).setVisibility(onlineChatMember.isOfficial() ? View.VISIBLE : View.GONE);
|
||||
//经验等级
|
||||
AppCompatImageView ivUserExper = helper.getView(R.id.iv_user_exper);
|
||||
AppCompatImageView ivUserExper = baseViewHolder.getView(R.id.iv_user_exper);
|
||||
String experLevelUrl = NobleUtil.getLevel(UserLevelResourceType.EXPER_URL, onlineChatMember.chatRoomMember);
|
||||
boolean isExperLevelUrlEmpty = TextUtils.isEmpty(experLevelUrl);
|
||||
ivUserExper.setVisibility(!isExperLevelUrlEmpty ? View.VISIBLE : View.GONE);
|
||||
if (!isExperLevelUrlEmpty) {
|
||||
ImageLoadUtils.loadImage(mContext, experLevelUrl, ivUserExper);
|
||||
}
|
||||
//魅力等级
|
||||
AppCompatImageView ivUserCharm = helper.getView(R.id.iv_user_charm);
|
||||
AppCompatImageView ivUserCharm = baseViewHolder.getView(R.id.iv_user_charm);
|
||||
String charmLevelUrl = NobleUtil.getLevel(UserLevelResourceType.CHARM_URL, onlineChatMember.chatRoomMember);
|
||||
boolean isCharmLevelUrlEmpty = TextUtils.isEmpty(charmLevelUrl);
|
||||
ivUserCharm.setVisibility(!isCharmLevelUrlEmpty ? View.VISIBLE : View.GONE);
|
||||
if (!isCharmLevelUrlEmpty) {
|
||||
ImageLoadUtils.loadImage(mContext, charmLevelUrl, ivUserCharm);
|
||||
}
|
||||
|
||||
// 官方主播铭牌标识
|
||||
String fixWord = NobleUtil.getLevel(UserInfo.OAC_NAME, onlineChatMember.chatRoomMember);
|
||||
String iconPic = NobleUtil.getLevel(UserInfo.OAC_ICON, onlineChatMember.chatRoomMember);
|
||||
View inOfficialMask = baseViewHolder.getView(R.id.in_official_mask);
|
||||
if (!TextUtils.isEmpty(fixWord) && !TextUtils.isEmpty(iconPic)) {
|
||||
inOfficialMask.setVisibility(View.VISIBLE);
|
||||
TextView tvOfficialMask = inOfficialMask.findViewById(R.id.tv_official_mask);
|
||||
if (tvOfficialMask != null) {
|
||||
tvOfficialMask.setText(fixWord);
|
||||
}
|
||||
|
||||
ImageView ivOfficialMask = inOfficialMask.findViewById(R.id.iv_official_mask);
|
||||
if (ivOfficialMask != null) {
|
||||
ImageLoadUtils.loadImage(mContext, iconPic, ivOfficialMask);
|
||||
}
|
||||
|
||||
} else {
|
||||
inOfficialMask.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// 铭牌
|
||||
View inNamePlate = helper.getView(R.id.in_nameplate);
|
||||
NamePlateHelper.INSTANCE.load(inNamePlate, inNamePlate.findViewById(R.id.tv_official_mask), inNamePlate.findViewById(R.id.iv_official_mask), item);
|
||||
String namePlateWord = NobleUtil.getLevel(UserInfo.NAMEPLATE_WORD, onlineChatMember.chatRoomMember);
|
||||
String namePlatePic = NobleUtil.getLevel(UserInfo.NAMEPLATE_PIC, onlineChatMember.chatRoomMember);
|
||||
View inNamePlate = baseViewHolder.getView(R.id.in_nameplate);
|
||||
if (!TextUtils.isEmpty(namePlateWord) && !TextUtils.isEmpty(namePlatePic)) {
|
||||
inNamePlate.setVisibility(View.VISIBLE);
|
||||
TextView tvNamePlate = inNamePlate.findViewById(R.id.tv_official_mask);
|
||||
if (tvNamePlate != null) {
|
||||
tvNamePlate.setText(namePlateWord);
|
||||
}
|
||||
|
||||
ImageView ivNamePlate = inNamePlate.findViewById(R.id.iv_official_mask);
|
||||
if (ivNamePlate != null) {
|
||||
ImageLoadUtils.loadImage(mContext, namePlatePic, ivNamePlate);
|
||||
}
|
||||
|
||||
} else {
|
||||
inNamePlate.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
AppCompatImageView ivUserLevel = baseViewHolder.getView(R.id.iv_noble_level);
|
||||
String resource = (String) NobleUtil.getResource(NobleResourceType.KEY_BADGE, onlineChatMember.chatRoomMember);
|
||||
if (TextUtils.isEmpty(resource)) {
|
||||
ivUserLevel.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
ivUserLevel.setVisibility(View.VISIBLE);
|
||||
NobleUtil.loadResource(resource, ivUserLevel);
|
||||
}
|
||||
|
||||
private void setSexData(BaseViewHolder baseViewHolder, OnlineChatMember onlineChatMember) {
|
||||
final ImageView sexImage = baseViewHolder.getView(R.id.sex);
|
||||
String gender = NobleUtil.getLevel(UserInfo.GENDER, onlineChatMember.chatRoomMember);
|
||||
if ("1".equals(gender)) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_male);
|
||||
} else if ("2".equals(gender)) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_female);
|
||||
} else {
|
||||
NimUserInfo nimUserInfo = NimUserInfoCache.getInstance().getUserInfo(onlineChatMember.chatRoomMember.getAccount());
|
||||
if (nimUserInfo == null) {
|
||||
NimUserInfoCache.getInstance().getUserInfoFromRemote(onlineChatMember.chatRoomMember.getAccount(),
|
||||
new RequestCallbackWrapper<NimUserInfo>() {
|
||||
@Override
|
||||
public void onResult(int i, NimUserInfo nimUserInfo, Throwable throwable) {
|
||||
if (nimUserInfo != null) {
|
||||
if (nimUserInfo.getGenderEnum() == GenderEnum.MALE) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_male);
|
||||
} else if (nimUserInfo.getGenderEnum() == GenderEnum.FEMALE) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_female);
|
||||
} else {
|
||||
sexImage.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (nimUserInfo.getGenderEnum() == GenderEnum.MALE) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_male);
|
||||
} else if (nimUserInfo.getGenderEnum() == GenderEnum.FEMALE) {
|
||||
sexImage.setVisibility(View.VISIBLE);
|
||||
sexImage.setImageResource(R.drawable.ic_gender_female);
|
||||
} else {
|
||||
sexImage.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void registerRoomEvent() {
|
||||
@@ -160,7 +240,7 @@ public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<RoomOnlineUserB
|
||||
updateMemberIn(roomEvent);
|
||||
} else if (event == RoomEvent.ROOM_MEMBER_EXIT) {
|
||||
if (mListener != null) {
|
||||
mListener.onMemberExit(roomEvent.getAccount());
|
||||
mListener.onMemberExit(roomEvent.getAccount(), mData);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -168,19 +248,19 @@ public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<RoomOnlineUserB
|
||||
|
||||
private void updateMemberIn(RoomEvent roomEvent) {
|
||||
if (mListener != null) {
|
||||
mListener.onMemberIn(roomEvent.getAccount());
|
||||
mListener.onMemberIn(roomEvent.getAccount(), mData);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateManager(RoomEvent roomEvent) {
|
||||
if (mListener != null)
|
||||
mListener.onUpdateMemberManager(roomEvent.getAccount(),
|
||||
roomEvent.getEvent() == RoomEvent.ROOM_MANAGER_REMOVE);
|
||||
roomEvent.getEvent() == RoomEvent.ROOM_MANAGER_REMOVE, mData);
|
||||
}
|
||||
|
||||
private void updateDownUpMic(String account, boolean isUpMic) {
|
||||
if (mListener != null) {
|
||||
mListener.onMemberDownUpMic(account, isUpMic);
|
||||
mListener.onMemberDownUpMic(account, isUpMic, mData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,29 +281,34 @@ public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<RoomOnlineUserB
|
||||
*
|
||||
* @param account
|
||||
*/
|
||||
void onMemberIn(String account);
|
||||
void onMemberIn(String account, List<OnlineChatMember> dataList);
|
||||
|
||||
/**
|
||||
* 成员出去回调
|
||||
*
|
||||
* @param account
|
||||
* @param dataList
|
||||
*/
|
||||
void onMemberExit(String account);
|
||||
void onMemberExit(String account, List<OnlineChatMember> dataList);
|
||||
|
||||
/**
|
||||
* 成员上下麦更新
|
||||
*
|
||||
* @param account
|
||||
* @param isUpMic
|
||||
* @param dataList
|
||||
*/
|
||||
void onMemberDownUpMic(String account, boolean isUpMic);
|
||||
void onMemberDownUpMic(String account, boolean isUpMic,
|
||||
List<OnlineChatMember> dataList);
|
||||
|
||||
/**
|
||||
* 设置管理员回调
|
||||
*
|
||||
* @param account
|
||||
* @param dataList
|
||||
*/
|
||||
void onUpdateMemberManager(String account, boolean isRemoveManager);
|
||||
void onUpdateMemberManager(String account, boolean isRemoveManager,
|
||||
List<OnlineChatMember> dataList);
|
||||
|
||||
void addMemberBlack();
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -1,40 +0,0 @@
|
||||
package com.yizhuan.erban.avroom.banner
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import androidx.core.util.Consumer
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtils
|
||||
import com.yizhuan.erban.ui.widget.rollviewpager.adapter.StaticPagerAdapter
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomIcon
|
||||
|
||||
class RoomBannerAdapter(private val mContext: Context, private val data: List<RoomIcon>) :
|
||||
StaticPagerAdapter() {
|
||||
|
||||
var onItemClickListener: Consumer<RoomIcon>? = null
|
||||
|
||||
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.id?.toString()
|
||||
ivCover.scaleType = ImageView.ScaleType.CENTER_CROP
|
||||
ImageLoadUtils.loadImage(
|
||||
mContext,
|
||||
bannerInfo.icon,
|
||||
ivCover,
|
||||
R.drawable.default_cover
|
||||
)
|
||||
ivCover.setOnClickListener { v: View? ->
|
||||
onItemClickListener?.accept(bannerInfo)
|
||||
}
|
||||
return view
|
||||
}
|
||||
|
||||
override fun getCount(): Int {
|
||||
return data.size
|
||||
}
|
||||
}
|
@@ -1,194 +0,0 @@
|
||||
package com.yizhuan.erban.avroom.banner
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.RelativeLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.firstcharge.FirstChargeDialog
|
||||
import com.yizhuan.erban.databinding.RoomBannerWidgetBinding
|
||||
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.webview.CommonWebViewActivity
|
||||
import com.yizhuan.erban.ui.webview.room_banner.RoomBannerWebDialogActivity
|
||||
import com.yizhuan.erban.ui.webview.room_banner.RoomWebDialogActivity
|
||||
import com.yizhuan.erban.ui.widget.rollviewpager.Util
|
||||
import com.yizhuan.erban.ui.widget.rollviewpager.hintview.ColorPointHintView
|
||||
import com.yizhuan.erban.utils.CommonJumpHelper
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomIcon
|
||||
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.FrameLayoutRoomWidget
|
||||
import com.yizhuan.xchat_android_core.support.room.RoomContext
|
||||
import com.yizhuan.xchat_android_core.support.room.RoomView
|
||||
import okhttp3.internal.filterList
|
||||
|
||||
/**
|
||||
* Created by Max on 2024/2/20 10:42
|
||||
* Desc:玩法活动
|
||||
**/
|
||||
class RoomBannerWidget : FrameLayoutRoomWidget {
|
||||
private val binding: RoomBannerWidgetBinding =
|
||||
DataBindingUtil.inflate(
|
||||
LayoutInflater.from(
|
||||
context
|
||||
), R.layout.room_banner_widget, this, true
|
||||
)
|
||||
|
||||
|
||||
private var indicatorVisible = false
|
||||
|
||||
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 {
|
||||
setIndicatorEnabled(true)
|
||||
}
|
||||
|
||||
override fun onInitialize(roomView: RoomView, roomContext: RoomContext) {
|
||||
super.onInitialize(roomView, roomContext)
|
||||
refreshData()
|
||||
}
|
||||
|
||||
fun disabledIndicator() {
|
||||
setIndicatorEnabled(false)
|
||||
}
|
||||
|
||||
fun refreshData() {
|
||||
if (RoomContext.get()?.getRoomInfo()?.type == RoomInfo.ROOMTYPE_GAME) {
|
||||
refreshData(true)
|
||||
} else {
|
||||
refreshData(false)
|
||||
}
|
||||
}
|
||||
|
||||
private fun refreshData(isGameRoom: Boolean) {
|
||||
val disposable = if (isGameRoom) {
|
||||
AvRoomModel.get().gameRoomBannerList
|
||||
} else {
|
||||
AvRoomModel.get().roomBannerList
|
||||
}.subscribe { list: List<RoomIcon> ->
|
||||
loadData(list)
|
||||
}
|
||||
getCompositeDisposable().add(disposable)
|
||||
}
|
||||
|
||||
private fun loadData(list: List<RoomIcon>?) {
|
||||
if (list.isNullOrEmpty()) {
|
||||
this.isVisible = false
|
||||
return
|
||||
}
|
||||
this.isVisible = true
|
||||
// 只有一個圖標,隱藏底部指示器
|
||||
indicatorVisible = list.size > 1
|
||||
|
||||
val bannerAdapter = RoomBannerAdapter(context, list)
|
||||
bannerAdapter.onItemClickListener = androidx.core.util.Consumer<RoomIcon> {
|
||||
if (it.isSeizeTreasure()) {
|
||||
HomeFairyActivity.start(context)
|
||||
} else if (it.isFirstCharge()) {
|
||||
FirstChargeDialog.start(context)
|
||||
} else if (it.isFindLove()) {
|
||||
GoldBoxHelper.handleBoxClick(context)
|
||||
} else if (it.isNauticalAdventure()) {
|
||||
PullRadishActivity.start(context)
|
||||
} else {
|
||||
AvRoomModel.get().activityClickLog("2", it.id?.toString()).subscribe()
|
||||
|
||||
if (it.skipType == 3) {
|
||||
if (it.tag == RoomIcon.TAG_GAMEPLAY) {
|
||||
if (it.showType == 2) {
|
||||
RoomWebDialogActivity.start(context, it.skipContent ?: "", false)
|
||||
} else {
|
||||
CommonWebViewActivity.start(context, it.skipContent ?: "")
|
||||
}
|
||||
} else {
|
||||
val newList = list.filterList {
|
||||
skipType == 3 && tag != RoomIcon.TAG_GAMEPLAY
|
||||
}
|
||||
val newPosition = newList.indexOfFirst { item ->
|
||||
item == it
|
||||
}
|
||||
RoomBannerWebDialogActivity.start(context, newPosition, newList)
|
||||
}
|
||||
} else {
|
||||
CommonJumpHelper.bannerJump(context, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
binding.pagerView.adapter = bannerAdapter
|
||||
binding.pagerView.setPlayDelay(3000)
|
||||
//設置透明度
|
||||
binding.pagerView.setAnimationDurtion(500)
|
||||
bannerAdapter.notifyDataSetChanged()
|
||||
|
||||
val viewPager = binding.pagerView.viewPager
|
||||
viewPager.offscreenPageLimit = list.size
|
||||
}
|
||||
|
||||
private fun setIndicatorEnabled(isEnabled: Boolean) {
|
||||
// 模擬指示器在viewpager底部效果
|
||||
val viewPager = binding.pagerView.viewPager
|
||||
val layoutParams = viewPager.layoutParams as RelativeLayout.LayoutParams
|
||||
if (isEnabled) {
|
||||
layoutParams.setMargins(0, 0, 0, Util.dip2px(context, 7f))
|
||||
binding.pagerView.setHintView(object : ColorPointHintView(
|
||||
context, Color.WHITE, ContextCompat.getColor(
|
||||
context,
|
||||
R.color.color_66FFFFFF
|
||||
)
|
||||
) {
|
||||
override fun makeFocusDrawable(): Drawable? {
|
||||
val dotFocus = GradientDrawable()
|
||||
dotFocus.setColor(Color.WHITE)
|
||||
dotFocus.cornerRadius = Util.dip2px(
|
||||
context, 2f
|
||||
).toFloat()
|
||||
dotFocus.setSize(
|
||||
Util.dip2px(context, 9f), Util.dip2px(
|
||||
context, 4f
|
||||
)
|
||||
)
|
||||
return if (indicatorVisible) dotFocus else null
|
||||
}
|
||||
|
||||
override fun makeNormalDrawable(): Drawable? {
|
||||
val dotNormal = GradientDrawable()
|
||||
dotNormal.setColor(ContextCompat.getColor(context, R.color.color_66FFFFFF))
|
||||
dotNormal.cornerRadius = Util.dip2px(
|
||||
context, 2f
|
||||
).toFloat()
|
||||
dotNormal.setSize(
|
||||
Util.dip2px(context, 4f), Util.dip2px(
|
||||
context, 4f
|
||||
)
|
||||
)
|
||||
return if (indicatorVisible) dotNormal else null
|
||||
}
|
||||
})
|
||||
} else {
|
||||
layoutParams.setMargins(0, 0, 0, 0)
|
||||
binding.pagerView.setHintView(null)
|
||||
}
|
||||
viewPager.layoutParams = layoutParams
|
||||
}
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
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
|
||||
)
|
@@ -1,19 +0,0 @@
|
||||
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,7 +24,6 @@ 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;
|
||||
@@ -113,7 +112,6 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
true));
|
||||
rvOPtList.setLayoutManager(new FullyGridLayoutManager(getContext(), 5));
|
||||
optAdapter = new OptAdapter(context, null);
|
||||
addRoomAlbum(optAdapter);
|
||||
addDatingAction(optAdapter);
|
||||
addPKAction(optAdapter);
|
||||
addRoomPKAction(optAdapter);
|
||||
@@ -125,7 +123,7 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
addRoomSettingAction(optAdapter);
|
||||
addGiftEffectAction(optAdapter);
|
||||
addOpenOrClosePublicScreenAction(optAdapter);
|
||||
// addRedPackageSwitch();
|
||||
addRedPackageSwitch();
|
||||
addCleanScreenAction(optAdapter);
|
||||
addRoomLimit(optAdapter);
|
||||
addGiftValueAction(optAdapter);
|
||||
@@ -269,14 +267,6 @@ 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());
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 相亲 模式
|
||||
*
|
||||
@@ -341,7 +331,7 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
* @param optAdapter
|
||||
*/
|
||||
private void addRedPacketAction(OptAdapter optAdapter) {
|
||||
if (AvRoomDataManager.get().getRedEnvelopeType() > 0) {
|
||||
if (AvRoomDataManager.get().isRedEnvelopeOpen()) {
|
||||
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (roomInfo == null) {
|
||||
return;
|
||||
@@ -352,6 +342,7 @@ public class RoomOperationDialog extends BottomSheetDialog {
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -428,7 +419,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))
|
||||
@@ -648,7 +639,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.productDetails)
|
||||
buyProduct(charge.skuDetails)
|
||||
}
|
||||
} else {
|
||||
CommonWebViewActivity.start(
|
||||
@@ -142,23 +142,18 @@ 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
|
||||
}
|
||||
@@ -201,13 +196,11 @@ 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}"
|
||||
@@ -234,19 +227,20 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
for (bean in goodsList) {
|
||||
productKeys.add(bean.chargeProdId)
|
||||
}
|
||||
billingManager?.querySkuDetailsAsync(productKeys) { billingResult: BillingResult, productDetails: MutableList<ProductDetails> ->
|
||||
billingManager?.querySkuDetailsAsync(
|
||||
BillingClient.SkuType.INAPP, productKeys
|
||||
) { billingResult: BillingResult, skuDetailsList: List<SkuDetails>? ->
|
||||
if (billingResult.responseCode != BillingClient.BillingResponseCode.OK) {
|
||||
Log.w(
|
||||
TAG,
|
||||
"Unsuccessful query for type: " + BillingClient.ProductType.INAPP + ". Error code: " + billingResult.responseCode
|
||||
"Unsuccessful query for type: " + BillingClient.SkuType.INAPP
|
||||
+ ". Error code: " + billingResult.responseCode
|
||||
)
|
||||
return@querySkuDetailsAsync
|
||||
}
|
||||
if (productDetails.isNotEmpty()) {
|
||||
} else if (skuDetailsList != null && skuDetailsList.isNotEmpty()) {
|
||||
for (chargeBean in goodsList) {
|
||||
for (skuDetails in productDetails) {
|
||||
if (skuDetails.productId == chargeBean.chargeProdId) {
|
||||
chargeBean.productDetails = skuDetails
|
||||
for (skuDetails in skuDetailsList) {
|
||||
if (skuDetails.sku == chargeBean.chargeProdId) {
|
||||
chargeBean.skuDetails = skuDetails
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -264,7 +258,7 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
) {
|
||||
PayModel.get().verifyOrder(
|
||||
purchase.accountIdentifiers!!.obfuscatedAccountId,
|
||||
purchase.products[0],
|
||||
purchase.skus[0],
|
||||
purchase.packageName,
|
||||
purchase.purchaseToken
|
||||
)
|
||||
@@ -273,12 +267,12 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
{ token: String? ->
|
||||
//L.i("token=" + token);
|
||||
billingManager?.consumeAsync(token)
|
||||
var skuDetails: ProductDetails? = null
|
||||
var skuDetails: SkuDetails? = null
|
||||
val goodList = goodsList
|
||||
if (!goodList.isNullOrEmpty()) {
|
||||
if (goodList != null && goodList.isNotEmpty()) {
|
||||
for (datum in goodList) {
|
||||
if (datum.chargeProdId == purchase.products[0]) {
|
||||
skuDetails = datum.productDetails
|
||||
if (datum.chargeProdId == purchase.skus[0]) {
|
||||
skuDetails = datum.skuDetails
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -288,12 +282,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.oneTimePurchaseOfferDetails?.priceAmountMicros!! / 1000000f
|
||||
eventValue["Price"] = skuDetails.oneTimePurchaseOfferDetails?.formattedPrice!!
|
||||
skuDetails.priceAmountMicros / 1000000f
|
||||
eventValue["Price"] = skuDetails.price
|
||||
eventValue[AFInAppEventParameterName.CURRENCY] =
|
||||
skuDetails.oneTimePurchaseOfferDetails?.priceCurrencyCode!!
|
||||
skuDetails.priceCurrencyCode
|
||||
AppsFlyerLib.getInstance().logEvent(
|
||||
applicationContext,
|
||||
AFInAppEventType.PURCHASE,
|
||||
@@ -321,10 +315,10 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
|
||||
/*购买商品*/
|
||||
@SuppressLint("CheckResult")
|
||||
fun buyProduct(skuDetails: ProductDetails?) {
|
||||
fun buyProduct(skuDetails: SkuDetails?) {
|
||||
if (skuDetails != null) {
|
||||
Log.d(TAG, "BuyProduct:" + skuDetails.productId)
|
||||
PayModel.get().placeOrder(skuDetails.productId)
|
||||
Log.d(TAG, "BuyProduct:" + skuDetails.sku)
|
||||
PayModel.get().placeOrder(skuDetails.sku)
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(
|
||||
{ recordId: PayRecordId ->
|
||||
@@ -378,7 +372,6 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
bean.itemType = FirstChargeReward.ONE
|
||||
}
|
||||
}
|
||||
|
||||
2 -> {
|
||||
for (i in firstChargeRewardList.indices) {
|
||||
if (i == 0) {
|
||||
@@ -388,13 +381,11 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
3 -> {
|
||||
for (bean in firstChargeRewardList) {
|
||||
bean.itemType = FirstChargeReward.THREE
|
||||
}
|
||||
}
|
||||
|
||||
4 -> {
|
||||
for (i in firstChargeRewardList.indices) {
|
||||
if ((i + 1) % 2 != 0) {
|
||||
@@ -404,7 +395,6 @@ class FirstChargeDialog : BaseViewBindingActivity<DialogFirstChargeBinding>(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
if (firstChargeRewardList.size % 3 == 0) {
|
||||
for (bean in firstChargeRewardList) {
|
||||
|
@@ -6,21 +6,23 @@ import android.app.Activity
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import android.view.KeyEvent
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.ViewStub
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.EditText
|
||||
import android.widget.ImageView
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.CallSuper
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.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
|
||||
@@ -44,9 +46,9 @@ import com.yizhuan.erban.avroom.dialog.AttentionHintDialog
|
||||
import com.yizhuan.erban.avroom.dialog.DatingVipRuleDialog
|
||||
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.send.RedPackageSendDialog
|
||||
import com.yizhuan.erban.avroom.room_album.RoomAlbumModel
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageSendDialog
|
||||
import com.yizhuan.erban.avroom.view.IBaseRoomView
|
||||
import com.yizhuan.erban.avroom.widget.BottomView
|
||||
import com.yizhuan.erban.avroom.widget.MessageView
|
||||
@@ -55,25 +57,34 @@ import com.yizhuan.erban.base.BaseMvpActivity
|
||||
import com.yizhuan.erban.base.BaseMvpFragment
|
||||
import com.yizhuan.erban.event.OpenRoomIntroEvent
|
||||
import com.yizhuan.erban.friend.view.SelectFriendActivity
|
||||
import com.yizhuan.erban.home.adapter.RoomActAdapter
|
||||
import com.yizhuan.erban.shipantics.PullRadishActivity
|
||||
import com.yizhuan.erban.treasure_box.widget.GoldBoxHelper
|
||||
import com.yizhuan.erban.ui.webview.DialogWebViewActivity
|
||||
import com.yizhuan.erban.ui.widget.ButtonItem
|
||||
import com.yizhuan.erban.ui.widget.GiftDialog
|
||||
import com.yizhuan.erban.ui.widget.GiftDialog.OnGiftDialogBtnClickListener
|
||||
import com.yizhuan.erban.ui.widget.GiftDialog.SenGiftCallback
|
||||
import com.yizhuan.erban.ui.widget.UserInfoDialog
|
||||
import com.yizhuan.erban.ui.widget.dynamicface.DynamicFaceDialog
|
||||
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil
|
||||
import com.yizhuan.erban.ui.widget.rollviewpager.RollPagerView
|
||||
import com.yizhuan.erban.ui.widget.rollviewpager.Util
|
||||
import com.yizhuan.erban.ui.widget.rollviewpager.hintview.ColorPointHintView
|
||||
import com.yizhuan.erban.utils.KeyBoardUtils
|
||||
import com.yizhuan.tutu.music.widget.MusicPlayerView
|
||||
import com.yizhuan.tutu.room_chat.activity.RoomMsgActivity
|
||||
import com.yizhuan.xchat_android_constants.XChatConstants
|
||||
import com.yizhuan.xchat_android_core.Constants
|
||||
import com.yizhuan.xchat_android_core.DemoCache
|
||||
import com.yizhuan.xchat_android_core.UriProvider
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.bean.RoomMicInfo
|
||||
import com.yizhuan.xchat_android_core.gift.GiftModel
|
||||
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.event.OpenRoomMessageInputEvent
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
|
||||
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
|
||||
@@ -83,6 +94,7 @@ import com.yizhuan.xchat_android_core.manager.RoomEvent
|
||||
import com.yizhuan.xchat_android_core.mentoring_relationship.event.MentoringStopCountingEvent
|
||||
import com.yizhuan.xchat_android_core.room.anotherroompk.ShowGiftDialogEvent
|
||||
import com.yizhuan.xchat_android_core.room.anotherroompk.ShowUserInfoDialogEvent
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomContributeUserInfo
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomInfo
|
||||
import com.yizhuan.xchat_android_core.room.event.RoomAtEvent
|
||||
import com.yizhuan.xchat_android_core.room.event.RoomClearScreenEvent
|
||||
@@ -93,8 +105,6 @@ 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
|
||||
@@ -107,7 +117,6 @@ 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
|
||||
@@ -122,8 +131,7 @@ import org.greenrobot.eventbus.ThreadMode
|
||||
*/
|
||||
open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
BaseMvpFragment<V?, P?>(),
|
||||
View.OnClickListener, OnGiftDialogBtnClickListener, IBaseRoomView, OnMicroItemClickListener,
|
||||
RoomView {
|
||||
View.OnClickListener, OnGiftDialogBtnClickListener, IBaseRoomView, OnMicroItemClickListener {
|
||||
private var myUid: Long = 0
|
||||
protected lateinit var messageView: MessageView
|
||||
protected lateinit var bottomView: BottomView
|
||||
@@ -132,6 +140,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
protected lateinit var inputSend: ImageView
|
||||
protected lateinit var microView: MicroView
|
||||
private var musicPlayerView: MusicPlayerView? = null
|
||||
private var ivRadishEntrance: View? = null
|
||||
private var mVsMusicPlayer: ViewStub? = null
|
||||
private var mDisposable: Disposable? = null
|
||||
private var isCloseScreen = false
|
||||
@@ -171,8 +180,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
|
||||
private var atProxy: AtProxy? = null
|
||||
|
||||
// 房间小组件
|
||||
private var widgets: HashMap<String, RoomWidget> = HashMap()
|
||||
|
||||
@CallSuper
|
||||
override fun onFindViews() {
|
||||
@@ -191,6 +198,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
inputSend = mView.findViewById(R.id.input_send)
|
||||
microView = mView.findViewById(R.id.micro_view)
|
||||
mVsMusicPlayer = mView.findViewById(R.id.vs_music_player)
|
||||
ivRadishEntrance = mView.findViewById(R.id.iv_radish_entrance)
|
||||
messageView.setClickConsumer {
|
||||
if (!TextUtils.isEmpty(it) && it != "0") {
|
||||
showUserCardDialog(it)
|
||||
@@ -231,7 +239,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
@SuppressLint("CheckResult")
|
||||
@CallSuper
|
||||
override fun initiate() {
|
||||
initWidget()
|
||||
//如果不需要開麥,並且還沒有權限的情況下,重置狀態為需要去打開麥克風
|
||||
myUid = AuthModel.get().currentUid
|
||||
isCloseScreen = AvRoomDataManager.get().isCloseScreen
|
||||
@@ -270,20 +277,15 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
// 刷新禮物列表,獲取房間專屬禮物列表
|
||||
GiftModel.get().refreshGiftList(AvRoomDataManager.get().roomUid.toString()).subscribe()
|
||||
checkFollowOwner()
|
||||
mvpPresenter?.loadRoomRank()
|
||||
GiftValueMrg.get().updateRoomGiftValue(false)
|
||||
|
||||
//先隐藏航海冒险
|
||||
// ivRadishEntrance?.isVisible =
|
||||
// !GoldBoxHelper.needIntegrateBoxEntrance() && GoldBoxHelper.isShowRadish()
|
||||
|
||||
//获取免费礼物详情
|
||||
mvpPresenter?.queryFreeFlower()
|
||||
initRoomAlbum()
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun initRoomAlbum() {
|
||||
RoomAlbumModel.listUnlockRoomPhoto(AvRoomDataManager.get().roomUid)
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe({
|
||||
AvRoomDataManager.get().unlockedRoomAlbumPhotos = it
|
||||
}, { toast(it.message) })
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
@@ -333,7 +335,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
updateRemoteMuteBtn()
|
||||
openOrCloseGiftValue(true)
|
||||
GiftValueMrg.get().updateRoomGiftValue(false)
|
||||
onEnterRoom()
|
||||
}
|
||||
|
||||
RoomEvent.ADD_BLACK_LIST -> onChatRoomMemberBlackAdd(roomEvent.account)
|
||||
@@ -443,6 +444,68 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
}
|
||||
}
|
||||
|
||||
fun initRoomAct(
|
||||
rollPagerView: RollPagerView,
|
||||
dialogInfo: List<BannerInfo>,
|
||||
bottomDp: Float = 0f
|
||||
) {
|
||||
if (!ListUtils.isListEmpty(dialogInfo)) {
|
||||
rollPagerView.visibility = View.VISIBLE
|
||||
// 只有一個圖標,隱藏底部指示器
|
||||
val show = dialogInfo.size > 1
|
||||
rollPagerView.setHintView(object : ColorPointHintView(
|
||||
mContext, Color.WHITE, ContextCompat.getColor(
|
||||
mContext,
|
||||
R.color.color_66FFFFFF
|
||||
)
|
||||
) {
|
||||
override fun makeFocusDrawable(): Drawable? {
|
||||
val dotFocus = GradientDrawable()
|
||||
dotFocus.setColor(Color.WHITE)
|
||||
dotFocus.cornerRadius = Util.dip2px(
|
||||
context, 2f
|
||||
).toFloat()
|
||||
dotFocus.setSize(
|
||||
Util.dip2px(context, 9f), Util.dip2px(
|
||||
context, 4f
|
||||
)
|
||||
)
|
||||
return if (show) dotFocus else null
|
||||
}
|
||||
|
||||
override fun makeNormalDrawable(): Drawable? {
|
||||
val dotNormal = GradientDrawable()
|
||||
dotNormal.setColor(ContextCompat.getColor(mContext, R.color.color_66FFFFFF))
|
||||
dotNormal.cornerRadius = Util.dip2px(
|
||||
context, 2f
|
||||
).toFloat()
|
||||
dotNormal.setSize(
|
||||
Util.dip2px(context, 4f), Util.dip2px(
|
||||
context, 4f
|
||||
)
|
||||
)
|
||||
return if (show) dotNormal else null
|
||||
}
|
||||
})
|
||||
val bannerAdapter = RoomActAdapter(mContext, dialogInfo)
|
||||
rollPagerView.adapter = bannerAdapter
|
||||
rollPagerView.setPlayDelay(3000)
|
||||
//設置透明度
|
||||
rollPagerView.setAnimationDurtion(500)
|
||||
bannerAdapter.notifyDataSetChanged()
|
||||
bannerAdapter.setRoomActClickListener { url ->
|
||||
DialogWebViewActivity.start(mContext, url)
|
||||
}
|
||||
|
||||
// 模擬指示器在viewpager底部效果
|
||||
val viewPager = rollPagerView.viewPager
|
||||
viewPager.offscreenPageLimit = dialogInfo.size
|
||||
val layoutParams = viewPager.layoutParams as RelativeLayout.LayoutParams
|
||||
layoutParams.setMargins(0, 0, 0, UIUtil.dip2px(mContext, bottomDp.toDouble()))
|
||||
viewPager.layoutParams = layoutParams
|
||||
}
|
||||
}
|
||||
|
||||
private fun releaseView() {
|
||||
roomFreeGiftDialog?.dismiss()
|
||||
messageView.release()
|
||||
@@ -474,9 +537,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
if (isOnMic) {
|
||||
if (musicPlayerView == null) {
|
||||
musicPlayerView = mVsMusicPlayer?.inflate() as? MusicPlayerView
|
||||
musicPlayerView?.let {
|
||||
onInitMusicPlayerView(it)
|
||||
}
|
||||
}
|
||||
musicPlayerView?.visibility = View.VISIBLE
|
||||
} else {
|
||||
@@ -506,7 +566,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
|
||||
) {
|
||||
@@ -565,7 +628,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
releaseView()
|
||||
unregisterWidgets()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
@@ -595,6 +657,17 @@ 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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -939,9 +1012,6 @@ 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
|
||||
@@ -1067,6 +1137,18 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
microView.adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun updateRoomRanks(data: List<RoomContributeUserInfo>) {
|
||||
// val avatarList = arrayListOf<ImageView?>(
|
||||
// mView.findViewById(R.id.iv_rank_0),
|
||||
// mView.findViewById(R.id.iv_rank_1),
|
||||
// mView.findViewById(R.id.iv_rank_2)
|
||||
// )
|
||||
//
|
||||
// for (i in 0 until avatarList.size) {
|
||||
// avatarList[i]?.loadAvatar(data.getOrNull(i)?.avatar)
|
||||
// }
|
||||
}
|
||||
|
||||
private fun onSendGiftBtnClick(giftId: Int = 0) {
|
||||
if (giftDialog == null) {
|
||||
GiftDialog.GIFT_DIALOG_FROM = getString(R.string.room)
|
||||
@@ -1179,7 +1261,10 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
}
|
||||
|
||||
override fun onSendMsgBtnClick() {
|
||||
openMessageInput(null)
|
||||
inputLayout.visibility = View.VISIBLE
|
||||
inputEdit.isFocusableInTouchMode = true
|
||||
inputEdit.requestFocus()
|
||||
KeyBoardUtils.showKeyBoard(context, inputEdit)
|
||||
}
|
||||
|
||||
override fun onSendGiftBtnClick() {
|
||||
@@ -1195,10 +1280,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
override fun onMoreBtnClick() {
|
||||
val dialog = RoomOperationDialog(mContext)
|
||||
dialog.setOnActionListener {
|
||||
redPackageSendDialog = RedPackageSendDialog.newInstance(AvRoomDataManager.get().redEnvelopeType)
|
||||
redPackageSendDialog?.setOnDismissListener {
|
||||
redPackageSendDialog = null
|
||||
}
|
||||
redPackageSendDialog = RedPackageSendDialog()
|
||||
redPackageSendDialog?.show(activity)
|
||||
}
|
||||
dialog.show()
|
||||
@@ -1208,67 +1290,4 @@ 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
|
||||
}
|
||||
|
||||
override fun findWidget(name: String): RoomWidget? {
|
||||
return widgets[name]
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
protected open fun onEnterRoom(){
|
||||
|
||||
}
|
||||
|
||||
protected open fun onInitMusicPlayerView(view: MusicPlayerView) {
|
||||
|
||||
}
|
||||
}
|
@@ -10,16 +10,14 @@ import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.adapter.GameMicroViewAdapter
|
||||
import com.yizhuan.erban.avroom.adapter.GameMiniMicroViewAdapter
|
||||
import com.yizhuan.erban.avroom.adapter.OnMicroItemClickListener
|
||||
import com.yizhuan.erban.avroom.banner.RoomBannerWidget
|
||||
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.rank.RoomRankWidget
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageWidget
|
||||
import com.yizhuan.erban.avroom.view.IGameRoomView
|
||||
import com.yizhuan.erban.databinding.FragmentGameRoomBinding
|
||||
import com.yizhuan.erban.ui.widget.GiftDialog.OnGiftDialogBtnClickListener
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.music.model.PlayerModel
|
||||
import com.yizhuan.xchat_android_core.pay.event.FirstChargeEvent
|
||||
@@ -69,9 +67,9 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
|
||||
AvRoomDataManager.get().mCurrentRoomInfo?.mgId
|
||||
)
|
||||
gameDelegate.setOnGameStatusChangeListener(this)
|
||||
gameBinding.rankWidget.setContentBackgroundResource(R.drawable.room_rank_widget_bg_game)
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun initiate() {
|
||||
gameBinding.microView.bindAdapter(GameMicroViewAdapter(context))
|
||||
@@ -79,6 +77,7 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
|
||||
//游戏模式暂时不需要这个
|
||||
PlayerModel.get().stop()
|
||||
gameBinding.roomInfo = AvRoomDataManager.get().mCurrentRoomInfo
|
||||
mvpPresenter?.getBannerList()
|
||||
gameBinding.tvShowMiniMic.setOnClickListener { showMiniMic() }
|
||||
gameBinding.ivShowMic.setOnClickListener { showMic() }
|
||||
}
|
||||
@@ -150,6 +149,10 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
|
||||
}
|
||||
}
|
||||
|
||||
override fun onShowBanner(dialogInfos: List<BannerInfo>) {
|
||||
initRoomAct(gameBinding.activityImg, dialogInfos)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onFinishAvRoomEvent(event: FinishAvRoomEvent) {
|
||||
gameDelegate.exitGame()
|
||||
@@ -157,8 +160,6 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onFirstRechargeEvent(event: FirstChargeEvent) {
|
||||
// banner里可能有首充入口:刷新下
|
||||
gameBinding.bannerWidget.refreshData()
|
||||
FirstChargePrizeDialog(
|
||||
requireContext(),
|
||||
event.chargeProdTitle,
|
||||
@@ -192,11 +193,4 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
override fun initWidget() {
|
||||
super.initWidget()
|
||||
gameBinding.bannerWidget.disabledIndicator()
|
||||
registerWidget(RedPackageWidget::class.java.simpleName, gameBinding.redPackageWidget)
|
||||
registerWidget(RoomRankWidget::class.java.simpleName, gameBinding.rankWidget)
|
||||
registerWidget(RoomBannerWidget::class.java.simpleName, gameBinding.bannerWidget)
|
||||
}
|
||||
}
|
@@ -16,11 +16,8 @@ import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.util.Consumer;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.netease.nim.uikit.common.util.string.StringUtil;
|
||||
@@ -40,9 +37,7 @@ import com.yizhuan.erban.base.BaseFragment;
|
||||
import com.yizhuan.erban.databinding.FragmentChatroomGameMainBinding;
|
||||
import com.yizhuan.erban.friend.view.SelectFriendActivity;
|
||||
import com.yizhuan.erban.home.helper.OpenRoomHelper;
|
||||
import com.yizhuan.erban.ui.widget.GiftDialog;
|
||||
import com.yizhuan.erban.ui.widget.ShareDialog;
|
||||
import com.yizhuan.erban.ui.widget.UserInfoDialog;
|
||||
import com.yizhuan.erban.utils.RegexUtil;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftMultiReceiverInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftReceiveInfo;
|
||||
@@ -119,7 +114,6 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
private String FOLLOW_ROOM_TYPE = "";
|
||||
private SelectGameAdapter gameAdapter;
|
||||
|
||||
public final MutableLiveData<Boolean> playNotifyStateLiveData = new MutableLiveData<Boolean>(false);
|
||||
|
||||
public static HomePartyFragment newInstance() {
|
||||
HomePartyFragment homePartyFragment = new HomePartyFragment();
|
||||
@@ -219,22 +213,11 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
ivRoomShare.setOnClickListener(this);
|
||||
gameMainBinding.llRoomInfo.setOnClickListener(this);
|
||||
gameMainBinding.ivBack.setOnClickListener(this);
|
||||
mRoomEffectView.setShowUserCardAction(s -> {
|
||||
if (roomFragment instanceof GiftDialog.OnGiftDialogBtnClickListener) {
|
||||
UserInfoDialog.showNewUserInfoDialog(
|
||||
mContext,
|
||||
JavaUtil.str2long(s),
|
||||
true,
|
||||
true,
|
||||
true, (GiftDialog.OnGiftDialogBtnClickListener) roomFragment
|
||||
);
|
||||
}
|
||||
});
|
||||
mRoomEffectView.setPlayNotifyStateListener(playNotifyStateLiveData);
|
||||
|
||||
mRoomEffectView.setOnPlayAnimCallback(new Function0<Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke() {
|
||||
return isShowingGiftNotify();
|
||||
return getIsAnim();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -377,22 +360,18 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean isShowingGiftNotify() {
|
||||
if ((getActivity() instanceof AVRoomActivity)) {
|
||||
return ((AVRoomActivity) getActivity()).isShowingGiftNotify();
|
||||
private boolean getIsAnim() {
|
||||
if (giftView != null) {
|
||||
return giftView.getIsPlayAnim();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public LiveData<Boolean> getPlayNotifyState(){
|
||||
return playNotifyStateLiveData;
|
||||
}
|
||||
|
||||
public boolean isShowingPlayNotify(){
|
||||
if(playNotifyStateLiveData.getValue()==null) {
|
||||
return false;
|
||||
}
|
||||
return playNotifyStateLiveData.getValue();
|
||||
/**
|
||||
* 获取玩法飘屏是否展示
|
||||
*/
|
||||
private boolean getIsPlayAnim() {
|
||||
return mRoomEffectView.getIsPlayAnim();
|
||||
}
|
||||
|
||||
private void onReceiveLuckyGiftToMultiMsg(LuckyBagGifts giftMultiReceiverInfo) {
|
||||
|
@@ -5,7 +5,6 @@ import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
@@ -20,18 +19,13 @@ import com.yizhuan.erban.avroom.adapter.MicroViewAdapter;
|
||||
import com.yizhuan.erban.avroom.anotherroompk.RoomPkFinishDialog;
|
||||
import com.yizhuan.erban.avroom.anotherroompk.RoomPkForceFinishDialog;
|
||||
import com.yizhuan.erban.avroom.anotherroompk.RoomPkReceivedDialog;
|
||||
import com.yizhuan.erban.avroom.banner.RoomBannerWidget;
|
||||
import com.yizhuan.erban.avroom.dialog.MicQueueDialog;
|
||||
import com.yizhuan.erban.avroom.dialog.PKMicQueueDialog;
|
||||
import com.yizhuan.erban.avroom.dialog.PKResultDialog;
|
||||
import com.yizhuan.erban.avroom.dialog.PKScoreBoardDialog;
|
||||
import com.yizhuan.erban.avroom.firstcharge.FirstChargePrizeDialog;
|
||||
import com.yizhuan.erban.avroom.gameplay.RoomGameplayListWidget;
|
||||
import com.yizhuan.erban.avroom.gameplay.RoomGameplayWidget;
|
||||
import com.yizhuan.erban.avroom.giftvalue.GiftValueDialogUiHelper;
|
||||
import com.yizhuan.erban.avroom.presenter.HomePartyPresenter;
|
||||
import com.yizhuan.erban.avroom.rank.RoomRankWidget;
|
||||
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;
|
||||
@@ -41,7 +35,6 @@ import com.yizhuan.erban.treasure_box.widget.GoldBoxHelper;
|
||||
import com.yizhuan.erban.ui.webview.DatingRuleWebViewActivity;
|
||||
import com.yizhuan.erban.ui.webview.DialogWebViewActivity;
|
||||
import com.yizhuan.erban.utils.UserUtils;
|
||||
import com.yizhuan.tutu.music.widget.MusicPlayerView;
|
||||
import com.yizhuan.xchat_android_core.Constants;
|
||||
import com.yizhuan.xchat_android_core.UriProvider;
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
@@ -140,16 +133,6 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
bottomView.setBottomViewListener(new PartyRoomBottomViewWrapper());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initWidget() {
|
||||
super.initWidget();
|
||||
registerWidget(RedPackageWidget.class.getSimpleName(), gameBinding.redPackageWidget);
|
||||
registerWidget(RoomRankWidget.class.getSimpleName(), gameBinding.rankWidget);
|
||||
registerWidget(RoomBannerWidget.class.getSimpleName(), gameBinding.bannerWidget);
|
||||
registerWidget(RoomGameplayListWidget.class.getSimpleName(), gameBinding.gameplayListWidget);
|
||||
registerWidget(RoomGameplayWidget.class.getSimpleName(), gameBinding.gameplayWidget);
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@Override
|
||||
public void initiate() {
|
||||
@@ -161,6 +144,7 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
updateQueuingMicBtn();
|
||||
updatePkScoreBoard();
|
||||
initRoomPkOrder(AvRoomDataManager.get().showPkBeginTime, AvRoomDataManager.get().pkBeginTime);
|
||||
getMvpPresenter().getBannerList();
|
||||
// if (!GoldBoxHelper.needIntegrateBoxEntrance()) {
|
||||
// UserModel.get().getCurrentUserInfo()
|
||||
// .compose(bindToLifecycle())
|
||||
@@ -542,6 +526,7 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (mDisposable != null) {
|
||||
@@ -612,7 +597,7 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
getMvpPresenter().cancelDragon();
|
||||
});
|
||||
break;
|
||||
case R.id.layout_hour_rank:
|
||||
case R.id.tv_hour_rank:
|
||||
DialogWebViewActivity.start(
|
||||
mContext,
|
||||
UriProvider.getRoomHourRankUrl(AvRoomDataManager.get().getRoomUid())
|
||||
@@ -796,6 +781,7 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
|
||||
private void hideKtvRelaView() {
|
||||
gameBinding.setKtvModel(false);
|
||||
gameBinding.contributeList.setVisibility(View.VISIBLE);
|
||||
changeModelShowView();
|
||||
gameBinding.bottomView.showKtvBottom(false);
|
||||
}
|
||||
@@ -807,10 +793,41 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
}
|
||||
|
||||
if (AvRoomDataManager.get().mCurrentRoomInfo.getIsPermitRoom() == 1) {
|
||||
gameBinding.layoutHourRank.setVisibility(View.VISIBLE);
|
||||
gameBinding.tvHourRank.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
gameBinding.layoutHourRank.setVisibility(View.GONE);
|
||||
gameBinding.tvHourRank.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (!GoldBoxHelper.needIntegrateBoxEntrance()) {
|
||||
GoldBoxHelper.isHideBox().subscribe(
|
||||
hide -> {
|
||||
if (hide != null && !hide) {
|
||||
if (AvRoomDataManager.get().isCpRoom()) {
|
||||
gameBinding.ivTreasureBoxCp.setVisibility(View.VISIBLE);
|
||||
gameBinding.ivTreasureBox.setVisibility(View.GONE);
|
||||
} 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)
|
||||
.into(gameBinding.ivTreasureBox);
|
||||
}
|
||||
} else {
|
||||
gameBinding.ivTreasureBoxCp.setVisibility(View.GONE);
|
||||
gameBinding.ivTreasureBox.setVisibility(View.GONE);
|
||||
}
|
||||
},
|
||||
throwable -> {
|
||||
gameBinding.ivTreasureBoxCp.setVisibility(View.GONE);
|
||||
gameBinding.ivTreasureBox.setVisibility(View.GONE);
|
||||
});
|
||||
} else {
|
||||
gameBinding.ivTreasureBoxCp.setVisibility(View.GONE);
|
||||
gameBinding.ivTreasureBox.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
setDragonView();
|
||||
}
|
||||
|
||||
@@ -944,11 +961,15 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
return pkMicQueueDialog != null && pkMicQueueDialog.isShowing();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShowBanner(List<BannerInfo> bannerInfos) {
|
||||
initRoomAct(gameBinding.activityImg, bannerInfos, 11f);
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onFirstRechargeEvent(FirstChargeEvent event) {
|
||||
// banner里可能有首充入口:刷新下
|
||||
gameBinding.bannerWidget.refreshData();
|
||||
gameBinding.ivFirstChargeEnter.setVisibility(View.GONE);
|
||||
new FirstChargePrizeDialog(requireContext(), event.getChargeProdTitle(), event.getFirstChargeRewardList()).openDialog();
|
||||
}
|
||||
|
||||
@@ -1044,10 +1065,4 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInitMusicPlayerView(@NonNull MusicPlayerView view) {
|
||||
super.onInitMusicPlayerView(view);
|
||||
view.linkIconView(gameBinding.ivMusic, gameBinding.ivMusic);
|
||||
}
|
||||
}
|
||||
|
@@ -7,24 +7,28 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.netease.nim.uikit.common.util.sys.NetworkUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMember;
|
||||
import com.orhanobut.logger.Logger;
|
||||
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadmoreListener;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.avroom.adapter.OnlineUserAdapter;
|
||||
import com.yizhuan.erban.avroom.presenter.HomePartyUserListPresenter;
|
||||
import com.yizhuan.erban.avroom.view.IHomePartyUserListView;
|
||||
import com.yizhuan.erban.base.BaseMvpFragment;
|
||||
import com.yizhuan.erban.ui.widget.UserInfoDialog;
|
||||
import com.yizhuan.xchat_android_core.Constants;
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
|
||||
import com.yizhuan.xchat_android_core.room.bean.OnlineChatMember;
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomOnlineUserBean;
|
||||
import com.yizhuan.xchat_android_core.super_admin.util.SuperAdminUtil;
|
||||
import com.yizhuan.xchat_android_library.base.factory.CreatePresenter;
|
||||
import com.yizhuan.xchat_android_library.utils.JavaUtil;
|
||||
import com.yizhuan.xchat_android_library.utils.ListUtils;
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -40,6 +44,7 @@ public class OnlineUserFragment extends BaseMvpFragment<IHomePartyUserListView,
|
||||
private SmartRefreshLayout mRefreshLayout;
|
||||
|
||||
private OnlineUserAdapter mOnlineUserAdapter;
|
||||
private int mPage = Constants.PAGE_START;
|
||||
private boolean isShowToUser = false;
|
||||
|
||||
@Override
|
||||
@@ -53,12 +58,24 @@ public class OnlineUserFragment extends BaseMvpFragment<IHomePartyUserListView,
|
||||
public void onFindViews() {
|
||||
mRecyclerView = mView.findViewById(R.id.recycler_view);
|
||||
mRefreshLayout = mView.findViewById(R.id.refresh_layout);
|
||||
mRefreshLayout.setEnableLoadmore(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetListener() {
|
||||
mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
||||
mRefreshLayout.setOnRefreshLoadmoreListener(new OnRefreshLoadmoreListener() {
|
||||
@Override
|
||||
public void onLoadmore(RefreshLayout refreshLayout) {
|
||||
if (!NetworkUtil.isNetAvailable(mContext)) {
|
||||
mRefreshLayout.finishLoadmore();
|
||||
return;
|
||||
}
|
||||
List<OnlineChatMember> data = mOnlineUserAdapter.getData();
|
||||
if (ListUtils.isListEmpty(data)) {
|
||||
mRefreshLayout.finishLoadmore();
|
||||
return;
|
||||
}
|
||||
loadData(data.get(data.size() - 1).chatRoomMember.getEnterTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh(RefreshLayout refreshLayout) {
|
||||
@@ -89,24 +106,53 @@ public class OnlineUserFragment extends BaseMvpFragment<IHomePartyUserListView,
|
||||
|
||||
|
||||
public void firstLoad() {
|
||||
loadData();
|
||||
mPage = Constants.PAGE_START;
|
||||
loadData(0);
|
||||
}
|
||||
|
||||
private void loadData() {
|
||||
getMvpPresenter().requestRoomOnlineList(AvRoomDataManager.get().getRoomUid());
|
||||
private void loadData(long time) {
|
||||
getMvpPresenter().requestChatMemberByPage(mPage, time,
|
||||
mOnlineUserAdapter == null ? null : mOnlineUserAdapter.getData());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRequestRoomOnlineListSuccess(List<RoomOnlineUserBean> list) {
|
||||
mOnlineUserAdapter.setNewData(list);
|
||||
mRefreshLayout.finishRefresh();
|
||||
public void onRequestChatMemberByPageSuccess(List<OnlineChatMember> chatRoomMemberList, int page) {
|
||||
mPage = page;
|
||||
if (!ListUtils.isListEmpty(chatRoomMemberList)) {
|
||||
//超管不显示
|
||||
Iterator<OnlineChatMember> iterator = chatRoomMemberList.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
OnlineChatMember member = iterator.next();
|
||||
if (member != null && SuperAdminUtil.isSuperAdmin(member.chatRoomMember)) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
mOnlineUserAdapter.setNewData(chatRoomMemberList);
|
||||
if (mPage == Constants.PAGE_START) {
|
||||
mRefreshLayout.finishRefresh();
|
||||
} else {
|
||||
mRefreshLayout.finishLoadmore(0);
|
||||
}
|
||||
mPage++;
|
||||
} else {
|
||||
if (mPage == Constants.PAGE_START) {
|
||||
mRefreshLayout.finishRefresh();
|
||||
} else {
|
||||
mRefreshLayout.finishLoadmore(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestChatMemberByPageFail(String errorStr, int page) {
|
||||
Logger.i(ResUtil.getString(R.string.avroom_fragment_onlineuserfragment_01) + page);
|
||||
mRefreshLayout.finishRefresh();
|
||||
mPage = page;
|
||||
if (mPage == Constants.PAGE_START) {
|
||||
mRefreshLayout.finishRefresh();
|
||||
} else {
|
||||
mRefreshLayout.finishLoadmore(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -120,15 +166,16 @@ public class OnlineUserFragment extends BaseMvpFragment<IHomePartyUserListView,
|
||||
public void onItemClick(BaseQuickAdapter baseQuickAdapter, View view, int position) {
|
||||
RoomInfo currentRoom = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (currentRoom != null) {
|
||||
List<RoomOnlineUserBean> chatRoomMembers = mOnlineUserAdapter.getData();
|
||||
List<OnlineChatMember> chatRoomMembers = mOnlineUserAdapter.getData();
|
||||
if (ListUtils.isListEmpty(chatRoomMembers)) return;
|
||||
RoomOnlineUserBean onlineChatMember = chatRoomMembers.get(position);
|
||||
if (onlineChatMember != null) {
|
||||
OnlineChatMember onlineChatMember = chatRoomMembers.get(position);
|
||||
ChatRoomMember chatRoomMember = onlineChatMember.chatRoomMember;
|
||||
if (chatRoomMember != null) {
|
||||
if (onlineChatMember.getItemType() == OnlineChatMember.NOBLE) {
|
||||
return;
|
||||
}
|
||||
UserInfoDialog.showNewUserInfoDialog(mContext,
|
||||
onlineChatMember.getUid(),
|
||||
JavaUtil.str2long(chatRoomMember.getAccount()),
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
@@ -138,25 +185,28 @@ public class OnlineUserFragment extends BaseMvpFragment<IHomePartyUserListView,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMemberIn(String account) {
|
||||
|
||||
public void onMemberIn(String account, List<OnlineChatMember> dataList) {
|
||||
// if (!isResumed()) return;
|
||||
// getMvpPresenter().onMemberInRefreshData(account, dataList, mPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMemberExit(String account) {
|
||||
public void onMemberExit(String account, List<OnlineChatMember> dataList) {
|
||||
// if (!isResumed()) return;
|
||||
// if (!isShowToUser()) return;
|
||||
// firstLoad();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMemberDownUpMic(String account, boolean isUpMic) {
|
||||
|
||||
public void onMemberDownUpMic(String account, boolean isUpMic, List<OnlineChatMember> dataList) {
|
||||
if (!isResumed()) return;
|
||||
getMvpPresenter().onMemberDownUpMic(account, isUpMic, dataList, mPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateMemberManager(String account, boolean isRemoveManager) {
|
||||
|
||||
public void onUpdateMemberManager(String account, boolean isRemoveManager, List<OnlineChatMember> dataList) {
|
||||
if (!isResumed()) return;
|
||||
getMvpPresenter().onUpdateMemberManager(account, dataList, isRemoveManager, mPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -13,14 +13,9 @@ import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.adapter.OnMicroItemClickListener
|
||||
import com.yizhuan.erban.avroom.adapter.SingleAnchorMicroViewAdapter
|
||||
import com.yizhuan.erban.avroom.adapter.SingleRoomPKMicroViewAdapter
|
||||
import com.yizhuan.erban.avroom.banner.RoomBannerWidget
|
||||
import com.yizhuan.erban.avroom.dialog.RequestUpMicDialog
|
||||
import com.yizhuan.erban.avroom.firstcharge.FirstChargePrizeDialog
|
||||
import com.yizhuan.erban.avroom.gameplay.RoomGameplayListWidget
|
||||
import com.yizhuan.erban.avroom.gameplay.RoomGameplayWidget
|
||||
import com.yizhuan.erban.avroom.presenter.SingleRoomPresenter
|
||||
import com.yizhuan.erban.avroom.rank.RoomRankWidget
|
||||
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
|
||||
@@ -29,12 +24,14 @@ import com.yizhuan.erban.databinding.FragmentSingleRoomBinding
|
||||
import com.yizhuan.erban.fansteam.FansTeamJoinActivity
|
||||
import com.yizhuan.erban.fansteam.FansTeamJoinedActivity
|
||||
import com.yizhuan.erban.fansteam.FansTeamViewModel
|
||||
import com.yizhuan.erban.treasure_box.widget.GoldBoxHelper
|
||||
import com.yizhuan.erban.ui.utils.load
|
||||
import com.yizhuan.erban.ui.webview.CommonWebViewActivity
|
||||
import com.yizhuan.erban.ui.webview.DialogWebViewActivity
|
||||
import com.yizhuan.tutu.music.widget.MusicPlayerView
|
||||
import com.yizhuan.xchat_android_core.UriProvider
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.fansteam.FansTeamInitInfo
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.FansTeamMsgAttachment
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RequestUpmicAttachment
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomPKAttachment
|
||||
@@ -85,7 +82,24 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
|
||||
@SuppressLint("CheckResult")
|
||||
override fun initiate() {
|
||||
super.initiate()
|
||||
mvpPresenter?.getBannerList()
|
||||
initSpeedyMessage(gameBinding.flSpeedyMessage)
|
||||
GoldBoxHelper.isHideBox().subscribe(
|
||||
{
|
||||
if (it == false) {
|
||||
gameBinding.ivTreasureBox.visibility = View.VISIBLE
|
||||
gameBinding.ivTreasureBox.load(
|
||||
GoldBoxHelper.getBoxIcon(),
|
||||
defaultRes = R.drawable.icon_room_treasure_box
|
||||
)
|
||||
} else {
|
||||
gameBinding.ivTreasureBox.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
) {
|
||||
gameBinding.ivTreasureBox.visibility = View.GONE
|
||||
}
|
||||
|
||||
fansTeamViewModel.loadFansTeamInitInfo()
|
||||
|
||||
fansTeamViewModel.fansTeamInitInfoLiveData.observe(viewLifecycleOwner) {
|
||||
@@ -94,7 +108,7 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
|
||||
}
|
||||
}
|
||||
|
||||
gameBinding.layoutHourRank.setOnClickListener {
|
||||
gameBinding.tvHourRank.setOnClickListener {
|
||||
DialogWebViewActivity.start(
|
||||
mContext,
|
||||
UriProvider.getSingleRoomHourRankUrl(AvRoomDataManager.get().roomUid)
|
||||
@@ -105,10 +119,16 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun updateFansTeamInfo(initInfo: FansTeamInitInfo) {
|
||||
var clickListener: View.OnClickListener? = null
|
||||
if (!AvRoomDataManager.get().isRoomOwner && !initInfo.isAnchorFans && initInfo.hasFansTeamCurrentRoom) {
|
||||
gameBinding.flFansTeamJoinTip.isVisible = true
|
||||
gameBinding.tvFansTeamOpt.isVisible = false
|
||||
} else {
|
||||
gameBinding.flFansTeamJoinTip.isVisible = false
|
||||
gameBinding.tvFansTeamOpt.isVisible = true
|
||||
}
|
||||
|
||||
if (initInfo.hasFansTeamCurrentRoom) {
|
||||
if (AvRoomDataManager.get().isRoomOwner) {
|
||||
gameBinding.flFansTeamJoinTip.isVisible = false
|
||||
gameBinding.tvFansTeamOpt.isVisible = true
|
||||
gameBinding.tvFansTeamOpt.text = "粉絲團(${initInfo.anchorFansNum})"
|
||||
clickListener = View.OnClickListener {
|
||||
DialogWebViewActivity.start(
|
||||
@@ -118,16 +138,12 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
|
||||
}
|
||||
} else {
|
||||
if (initInfo.isAnchorFans) {
|
||||
gameBinding.flFansTeamJoinTip.isVisible = false
|
||||
gameBinding.tvFansTeamOpt.isVisible = true
|
||||
gameBinding.tvFansTeamOpt.text =
|
||||
"粉絲LV.${if (initInfo.fansLevelSeq == 0) 1 else initInfo.fansLevelSeq}"
|
||||
clickListener = View.OnClickListener {
|
||||
FansTeamJoinedActivity.start(requireContext())
|
||||
}
|
||||
} else {
|
||||
gameBinding.flFansTeamJoinTip.isVisible = true
|
||||
gameBinding.tvFansTeamOpt.isVisible = false
|
||||
clickListener = View.OnClickListener {
|
||||
FansTeamJoinActivity.start(requireContext())
|
||||
}
|
||||
@@ -135,8 +151,6 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
|
||||
}
|
||||
} else {
|
||||
if (AvRoomDataManager.get().isRoomOwner) {
|
||||
gameBinding.flFansTeamJoinTip.isVisible = false
|
||||
gameBinding.tvFansTeamOpt.isVisible = true
|
||||
gameBinding.tvFansTeamOpt.text = "開通粉絲團"
|
||||
clickListener = View.OnClickListener {
|
||||
CommonWebViewActivity.start(
|
||||
@@ -145,9 +159,7 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
|
||||
)
|
||||
}
|
||||
} else {
|
||||
gameBinding.flFansTeamJoinTip.isVisible = false
|
||||
gameBinding.tvFansTeamOpt.isVisible = true
|
||||
gameBinding.tvFansTeamOpt.text = "TA暫未開通粉絲團"
|
||||
gameBinding.tvFansTeamOpt.text = "該主播暫未開通粉絲團"
|
||||
}
|
||||
}
|
||||
gameBinding.flFansTeam.setOnClickListener(clickListener)
|
||||
@@ -217,11 +229,6 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
|
||||
bottomView.setBottomViewListener(BaseRoomBottomViewWrapper())
|
||||
}
|
||||
|
||||
override fun onEnterRoom() {
|
||||
super.onEnterRoom()
|
||||
fansTeamViewModel.loadFansTeamInitInfo()
|
||||
}
|
||||
|
||||
override fun updateView() {
|
||||
super.updateView()
|
||||
if (AvRoomDataManager.get().isOpenAnotherPKMode && gameBinding.microView.adapter !is SingleRoomPKMicroViewAdapter) {
|
||||
@@ -241,10 +248,13 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
|
||||
}
|
||||
}
|
||||
|
||||
override fun onShowBanner(dialogInfos: List<BannerInfo>) {
|
||||
initRoomAct(gameBinding.activityImg, dialogInfos, 10f)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onFirstRechargeEvent(event: FirstChargeEvent) {
|
||||
// banner里可能有首充入口:刷新下
|
||||
gameBinding.bannerWidget.refreshData()
|
||||
gameBinding.ivFirstChargeEnter.visibility = View.GONE
|
||||
FirstChargePrizeDialog(
|
||||
requireContext(),
|
||||
event.chargeProdTitle,
|
||||
@@ -252,17 +262,4 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
|
||||
).openDialog()
|
||||
}
|
||||
|
||||
override fun initWidget() {
|
||||
super.initWidget()
|
||||
registerWidget(RedPackageWidget::class.java.simpleName, gameBinding.redPackageWidget)
|
||||
registerWidget(RoomRankWidget::class.java.simpleName, gameBinding.rankWidget)
|
||||
registerWidget(RoomBannerWidget::class.java.simpleName, gameBinding.bannerWidget)
|
||||
registerWidget(RoomGameplayListWidget::class.java.simpleName, gameBinding.gameplayListWidget)
|
||||
registerWidget(RoomGameplayWidget::class.java.simpleName, gameBinding.gameplayWidget)
|
||||
}
|
||||
|
||||
override fun onInitMusicPlayerView(view: MusicPlayerView) {
|
||||
super.onInitMusicPlayerView(view)
|
||||
view.linkIconView(gameBinding.ivMusic, gameBinding.ivMusic)
|
||||
}
|
||||
}
|
@@ -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 :String get() = AvRoomDataManager.get().roomUid.toString()
|
||||
private val mRoomID = AvRoomDataManager.get().roomUid.toString()
|
||||
private val mLanguage = "zh-TW" //語言
|
||||
|
||||
//調用遊戲SDK的接口,成功加載遊戲後可用:
|
||||
@@ -84,10 +84,7 @@ class GameDelegate(val activity: Activity, val container: FrameLayout, var mgId:
|
||||
}
|
||||
|
||||
fun updateGame(mgId: Long?) {
|
||||
if (mgId == null || mgId == 0L) return
|
||||
if (mgId == mMGID && iSudFSTAPP != null) {
|
||||
return
|
||||
}
|
||||
if (mgId == null || mgId == 0L || mgId == mMGID || iSudFSTAPP == null) return
|
||||
mMGID = mgId
|
||||
updateMyMicQueue(GameStatus.STATUS_NOT_JOIN)
|
||||
loadMG(activity, mUid, mRoomID, APP_CODE, mMGID, mLanguage)
|
||||
|
@@ -1,25 +0,0 @@
|
||||
package com.yizhuan.erban.avroom.gameplay
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
/**
|
||||
* Created by Max on 2024/2/23 16:09
|
||||
* Desc:
|
||||
**/
|
||||
class GameplayRecyclerView : RecyclerView {
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
)
|
||||
|
||||
override fun onInterceptTouchEvent(e: MotionEvent?): Boolean {
|
||||
parent.requestDisallowInterceptTouchEvent(true)
|
||||
return super.onInterceptTouchEvent(e)
|
||||
}
|
||||
}
|
@@ -1,70 +0,0 @@
|
||||
package com.yizhuan.erban.avroom.gameplay
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewConfiguration
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.databinding.RoomGameplayListWidgetBinding
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomIcon
|
||||
import com.yizhuan.xchat_android_core.support.room.FrameLayoutRoomWidget
|
||||
|
||||
/**
|
||||
* Created by Max on 2024/2/20 10:42
|
||||
* Desc:玩法活动
|
||||
**/
|
||||
class RoomGameplayListWidget : FrameLayoutRoomWidget {
|
||||
private val adapter = RoomPlayListAdapter()
|
||||
private val binding: RoomGameplayListWidgetBinding =
|
||||
DataBindingUtil.inflate(
|
||||
LayoutInflater.from(
|
||||
context
|
||||
), R.layout.room_gameplay_list_widget, this, true
|
||||
)
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
)
|
||||
|
||||
constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet?,
|
||||
defStyleAttr: Int,
|
||||
defStyleRes: Int
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
init {
|
||||
binding.recyclerView.adapter = adapter
|
||||
binding.ivSwitch.setOnClickListener {
|
||||
getGameplayIconWidget()?.switchUI(false)
|
||||
}
|
||||
adapter.setOnItemClickListener { adapter, view, position ->
|
||||
(adapter.getItem(position) as? RoomIcon)?.let {
|
||||
getGameplayIconWidget()?.jump(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getGameplayIconWidget(): RoomGameplayWidget? {
|
||||
return roomView?.findWidget(
|
||||
RoomGameplayWidget::class.simpleName ?: ""
|
||||
) as? RoomGameplayWidget
|
||||
}
|
||||
|
||||
fun loadData(list: List<RoomIcon>) {
|
||||
adapter.setNewData(list)
|
||||
if (list.size > 6) {
|
||||
binding.recyclerView.isScrollbarFadingEnabled = false
|
||||
binding.recyclerView.scrollBarFadeDuration = 0
|
||||
} else {
|
||||
binding.recyclerView.isScrollbarFadingEnabled = true
|
||||
binding.recyclerView.scrollBarFadeDuration =
|
||||
ViewConfiguration.getScrollBarFadeDuration()
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,131 +0,0 @@
|
||||
package com.yizhuan.erban.avroom.gameplay
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.chuhai.utils.ktx.singleClick
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.firstcharge.FirstChargeDialog
|
||||
import com.yizhuan.erban.databinding.RoomGameplayWidgetBinding
|
||||
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.load
|
||||
import com.yizhuan.erban.ui.webview.CommonWebViewActivity
|
||||
import com.yizhuan.erban.ui.webview.room_banner.RoomWebDialogActivity
|
||||
import com.yizhuan.erban.utils.CommonJumpHelper
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomIcon
|
||||
import com.yizhuan.xchat_android_core.room.model.AvRoomModel
|
||||
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
|
||||
|
||||
/**
|
||||
* Created by Max on 2024/2/20 10:42
|
||||
* Desc:玩法活动
|
||||
**/
|
||||
class RoomGameplayWidget : FrameLayoutRoomWidget {
|
||||
private val binding: RoomGameplayWidgetBinding =
|
||||
DataBindingUtil.inflate(
|
||||
LayoutInflater.from(
|
||||
context
|
||||
), R.layout.room_gameplay_widget, this, true
|
||||
)
|
||||
|
||||
private var isOpened = false
|
||||
|
||||
private var list: List<RoomIcon>? = null
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
)
|
||||
|
||||
constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet?,
|
||||
defStyleAttr: Int,
|
||||
defStyleRes: Int
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
init {
|
||||
binding.ivSwitch.setOnClickListener {
|
||||
switchUI(!isOpened)
|
||||
}
|
||||
binding.ivIcon.singleClick {
|
||||
list?.getOrNull(0)?.let {
|
||||
jump(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInitialize(roomView: RoomView, roomContext: RoomContext) {
|
||||
super.onInitialize(roomView, roomContext)
|
||||
refreshData()
|
||||
}
|
||||
|
||||
private fun refreshData() {
|
||||
val disposable = AvRoomModel.get().roomGamePlayList
|
||||
.subscribe { list: List<RoomIcon> ->
|
||||
loadData(list)
|
||||
}
|
||||
getCompositeDisposable().add(disposable)
|
||||
}
|
||||
|
||||
fun switchUI(openListWidget: Boolean) {
|
||||
this.isOpened = openListWidget
|
||||
if (openListWidget) {
|
||||
this.visibility = View.INVISIBLE
|
||||
getGameplayListWidget()?.visibility = View.VISIBLE
|
||||
} else {
|
||||
this.visibility = View.VISIBLE
|
||||
getGameplayListWidget()?.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadData(list: List<RoomIcon>) {
|
||||
this.list = list
|
||||
this.isVisible = list.isNotEmpty()
|
||||
val listWidget = getGameplayListWidget()
|
||||
if (list.isEmpty()) {
|
||||
listWidget?.isVisible = false
|
||||
}
|
||||
listWidget?.loadData(list)
|
||||
binding.ivIcon.load(list.firstOrNull()?.icon)
|
||||
}
|
||||
|
||||
fun jump(data: RoomIcon) {
|
||||
if (data.isSeizeTreasure()) {
|
||||
HomeFairyActivity.start(context)
|
||||
} else if (data.isFirstCharge()) {
|
||||
FirstChargeDialog.start(context)
|
||||
} else if (data.isFindLove()) {
|
||||
GoldBoxHelper.handleBoxClick(context)
|
||||
} else if (data.isNauticalAdventure()) {
|
||||
PullRadishActivity.start(context)
|
||||
} else {
|
||||
val url = data.skipContent
|
||||
if (data.skipType == 3 && !url.isNullOrEmpty()) {
|
||||
if (data.showType == 2) {
|
||||
RoomWebDialogActivity.start(context, url, false)
|
||||
} else {
|
||||
CommonWebViewActivity.start(context, url)
|
||||
}
|
||||
} else {
|
||||
CommonJumpHelper.bannerJump(context, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getGameplayListWidget(): RoomGameplayListWidget? {
|
||||
return roomView?.findWidget(
|
||||
RoomGameplayListWidget::class.simpleName ?: ""
|
||||
) as? RoomGameplayListWidget
|
||||
}
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
package com.yizhuan.erban.avroom.gameplay
|
||||
|
||||
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.room.bean.RoomIcon
|
||||
|
||||
/**
|
||||
* Created by Max on 2024/2/20 11:38
|
||||
* Desc:
|
||||
**/
|
||||
class RoomPlayListAdapter :
|
||||
BaseQuickAdapter<RoomIcon, BaseViewHolder>(R.layout.room_gameplay_item) {
|
||||
override fun convert(helper: BaseViewHolder, item: RoomIcon?) {
|
||||
helper.getView<ImageView>(R.id.iv_icon).load(item?.icon)
|
||||
}
|
||||
}
|
@@ -20,9 +20,6 @@ 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.im.custom.bean.RoomPkBean;
|
||||
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;
|
||||
@@ -121,6 +118,7 @@ public class AvRoomPresenter extends BaseMvpPresenter<IAvRoomView> {
|
||||
exitRoom();
|
||||
}
|
||||
AvRoomDataManager.get().updateServiceRoomInfo(roomInfo);
|
||||
initAnotherPKData();
|
||||
mAvRoomModel.enterRoom(roomInfo.getRoomId(), 3, fromType, fromNick, fromUid)
|
||||
.flatMap(this::dealServerMicInfo)
|
||||
.map(this::dealMicMemberFromIMNet)
|
||||
@@ -130,8 +128,6 @@ 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();
|
||||
}
|
||||
@@ -143,7 +139,6 @@ public class AvRoomPresenter extends BaseMvpPresenter<IAvRoomView> {
|
||||
.subscribe((stringServiceResult) -> EventBus.getDefault().post(new AudioPartyOpenEvent()));
|
||||
mAvRoomModel.loadMessageHistory(AvRoomDataManager.get().clearScreenTime);
|
||||
IMNetEaseManager.get().joinAvRoom();
|
||||
initAnotherPKData();
|
||||
}, this::dealEnterRoomError);
|
||||
}
|
||||
|
||||
@@ -152,15 +147,7 @@ public class AvRoomPresenter extends BaseMvpPresenter<IAvRoomView> {
|
||||
if (AvRoomDataManager.get().isOpenAnotherPKMode()) {
|
||||
RoomPKModel.INSTANCE.getRoomPKData(AvRoomDataManager.get().getRoomUid())
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(roomPkBean -> {
|
||||
AvRoomDataManager.get().roomPkLiveData.setValue(roomPkBean);
|
||||
if (AvRoomDataManager.get().isSingleRoom()){
|
||||
AudioEngineManager.get().setRemoteMute(roomPkBean.getAUid(), roomPkBean.getAMicStatus() == 0);
|
||||
if (AvRoomDataManager.get().isRoomOwner()) {
|
||||
AudioEngineManager.get().connectOtherRoom(String.valueOf(roomPkBean.getARoomId()), roomPkBean.getAUid());
|
||||
}
|
||||
}
|
||||
});
|
||||
.subscribe(roomPkBean -> AvRoomDataManager.get().roomPkLiveData.setValue(roomPkBean));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -525,6 +525,20 @@ public class BaseRoomPresenter<V extends IBaseRoomView> extends BaseMvpPresenter
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public void loadRoomRank() {
|
||||
String type = AvRoomDataManager.get().isSingleRoom() ? RoomContributeDataInfo.TYPE_ROOM_WEEK_RANKING : RoomContributeDataInfo.TYPE_ROOM_DAY_RANKING;
|
||||
RoomContributeListModel.get().getSingleRoomRanking(1, type)
|
||||
.compose(bindToLifecycle())
|
||||
.compose(RxHelper.handleBeanData())
|
||||
.subscribe(roomContributeDataInfo -> {
|
||||
if (getMvpView() == null) {
|
||||
return;
|
||||
}
|
||||
getMvpView().updateRoomRanks(roomContributeDataInfo.getRankings());
|
||||
});
|
||||
}
|
||||
|
||||
/***
|
||||
* 發送房間消息
|
||||
* @param message
|
||||
|
@@ -1,7 +1,15 @@
|
||||
package com.yizhuan.erban.avroom.presenter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
import com.yizhuan.erban.avroom.view.IGameRoomView;
|
||||
import com.yizhuan.erban.treasure_box.widget.GoldBoxHelper;
|
||||
import com.yizhuan.erban.utils.UserUtils;
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo;
|
||||
import com.yizhuan.xchat_android_core.room.model.AvRoomModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -12,4 +20,37 @@ import com.yizhuan.erban.avroom.view.IGameRoomView;
|
||||
*/
|
||||
public class GameRoomPresenter extends BaseRoomPresenter<IGameRoomView> {
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public void getBannerList() {
|
||||
AvRoomModel.get().getRoomBanner()
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(bannerInfos -> {
|
||||
if (bannerInfos == null) bannerInfos = new ArrayList<>();
|
||||
final boolean firstCharge = UserUtils.getUserInfo().isFirstCharge();
|
||||
if (firstCharge) {
|
||||
BannerInfo bannerInfo = new BannerInfo();
|
||||
bannerInfo.setFirstCharge(true);
|
||||
bannerInfos.add(0, bannerInfo);
|
||||
}
|
||||
if(GoldBoxHelper.isShowFairy()){
|
||||
BannerInfo bannerInfo = new BannerInfo();
|
||||
bannerInfo.setFairy(true);
|
||||
bannerInfos.add(firstCharge ? 1 : 0, bannerInfo);
|
||||
}
|
||||
List<BannerInfo> finalBannerInfos = bannerInfos;
|
||||
GoldBoxHelper.isHideBox()
|
||||
.subscribe(isHide -> {
|
||||
if (!isHide) {
|
||||
BannerInfo bannerInfo = new BannerInfo();
|
||||
bannerInfo.setBox(true);
|
||||
int index = 0;
|
||||
if (firstCharge) index++;
|
||||
if (GoldBoxHelper.isShowFairy()) index++;
|
||||
finalBannerInfos.add(index, bannerInfo);
|
||||
}
|
||||
getMvpView().onShowBanner(finalBannerInfos);
|
||||
}, throwable -> getMvpView().onShowBanner(finalBannerInfos));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -12,10 +12,12 @@ import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.avroom.view.IHomePartyView;
|
||||
import com.yizhuan.erban.treasure_box.widget.GoldBoxHelper;
|
||||
import com.yizhuan.erban.utils.UserUtils;
|
||||
import com.yizhuan.xchat_android_core.Constants;
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
import com.yizhuan.xchat_android_core.bean.RoomQueueInfo;
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.FaceAttachment;
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
|
||||
@@ -295,4 +297,49 @@ public class HomePartyPresenter extends BaseRoomPresenter<IHomePartyView> {
|
||||
.subscribe(s -> SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_presenter_homepartypresenter_01))
|
||||
, e -> SingleToastUtil.showToast(e.getMessage()));
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public void getBannerList() {
|
||||
mAvRoomModel.getRoomBanner()
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(bannerInfos -> {
|
||||
final boolean firstCharge = UserUtils.getUserInfo().isFirstCharge();
|
||||
if (GoldBoxHelper.needIntegrateBoxEntrance()) {
|
||||
if (firstCharge) {
|
||||
BannerInfo bannerInfo = new BannerInfo();
|
||||
bannerInfo.setFirstCharge(true);
|
||||
bannerInfos.add(0, bannerInfo);
|
||||
}
|
||||
if (GoldBoxHelper.isShowRadish()) {
|
||||
BannerInfo bannerInfo = new BannerInfo();
|
||||
bannerInfo.setRadish(true);
|
||||
bannerInfos.add(firstCharge ? 1 : 0, bannerInfo);
|
||||
}
|
||||
GoldBoxHelper.isHideBox()
|
||||
.subscribe(isHide -> {
|
||||
if (!isHide) {
|
||||
BannerInfo bannerInfo = new BannerInfo();
|
||||
bannerInfo.setBox(true);
|
||||
int index = 0;
|
||||
if (firstCharge) index++;
|
||||
if (GoldBoxHelper.isShowRadish()) index++;
|
||||
bannerInfos.add(index, bannerInfo);
|
||||
}
|
||||
getMvpView().onShowBanner(bannerInfos);
|
||||
}, throwable -> getMvpView().onShowBanner(bannerInfos));
|
||||
} else {
|
||||
if(GoldBoxHelper.isShowFairy()){
|
||||
BannerInfo bannerInfo = new BannerInfo();
|
||||
bannerInfo.setFairy(true);
|
||||
bannerInfos.add(0, bannerInfo);
|
||||
}
|
||||
if (firstCharge) {
|
||||
BannerInfo bannerInfo = new BannerInfo();
|
||||
bannerInfo.setFirstCharge(true);
|
||||
bannerInfos.add(0, bannerInfo);
|
||||
}
|
||||
getMvpView().onShowBanner(bannerInfos);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -2,9 +2,15 @@ package com.yizhuan.erban.avroom.presenter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
import com.orhanobut.logger.Logger;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.avroom.view.IHomePartyUserListView;
|
||||
import com.yizhuan.erban.base.BaseMvpPresenter;
|
||||
import com.yizhuan.xchat_android_core.room.bean.OnlineChatMember;
|
||||
import com.yizhuan.xchat_android_core.room.model.HomePartyUserListModel;
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p> </p>
|
||||
@@ -20,17 +26,49 @@ public class HomePartyUserListPresenter extends BaseMvpPresenter<IHomePartyUserL
|
||||
mHomePartyUserListMode = new HomePartyUserListModel();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分页获取房间成员:第一页包含队列成员,固定成员,游客50人,之后每一页获取游客50人
|
||||
*
|
||||
* @param page 页数
|
||||
* @param time 固定成员列表用updateTime,
|
||||
* 游客列表用进入enterTime,
|
||||
* 填0会使用当前服务器最新时间开始查询,即第一页,单位毫秒
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
public void requestRoomOnlineList(long roomUid){
|
||||
mHomePartyUserListMode.getRoomOnlineList(roomUid).compose(bindToLifecycle()).subscribe((data, throwable) -> {
|
||||
if (getMvpView() != null) {
|
||||
if (data != null) {
|
||||
getMvpView().onRequestRoomOnlineListSuccess(data);
|
||||
} else {
|
||||
getMvpView().onRequestChatMemberByPageFail(throwable.getMessage(), 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
public void requestChatMemberByPage(final int page, long time, List<OnlineChatMember> oldList) {
|
||||
mHomePartyUserListMode.getOnLinePageMembers(page, time, oldList)
|
||||
.subscribe(onlineChatMembers -> {
|
||||
Logger.i(ResUtil.getString(R.string.avroom_presenter_homepartyuserlistpresenter_01), page, onlineChatMembers.size());
|
||||
if (getMvpView() != null) {
|
||||
getMvpView().onRequestChatMemberByPageSuccess(onlineChatMembers, page);
|
||||
}
|
||||
}, throwable -> {
|
||||
throwable.printStackTrace();
|
||||
Logger.i(ResUtil.getString(R.string.avroom_presenter_homepartyuserlistpresenter_02), page, throwable.getMessage());
|
||||
if (getMvpView() != null) {
|
||||
getMvpView().onRequestChatMemberByPageFail(throwable.getMessage(), page);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onMemberDownUpMic(String account, boolean isUpMic, List<OnlineChatMember> dataList,
|
||||
final int page) {
|
||||
mHomePartyUserListMode.onMemberDownUpMic(account, isUpMic, dataList)
|
||||
.subscribe(onlineChatMembers -> {
|
||||
if (getMvpView() != null)
|
||||
getMvpView().onRequestChatMemberByPageSuccess(onlineChatMembers, page);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void onUpdateMemberManager(String account, List<OnlineChatMember> dataList,
|
||||
boolean isRemoveManager, final int page) {
|
||||
mHomePartyUserListMode.onUpdateMemberManager(account, isRemoveManager, dataList)
|
||||
.subscribe(onlineChatMembers -> {
|
||||
if (getMvpView() != null)
|
||||
getMvpView().onRequestChatMemberByPageSuccess(onlineChatMembers, page);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -70,20 +70,10 @@ public class RoomManagerPresenter extends BaseMvpPresenter<IRoomManagerView> {
|
||||
Iterator<ChatRoomMember> iterator = paramList.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ChatRoomMember member = iterator.next();
|
||||
if (member != null && !TextUtils.isEmpty(member.getAccount())) {
|
||||
if (map.containsKey(member.getAccount())) {
|
||||
iterator.remove();
|
||||
} else {
|
||||
if (member.getNick() == null || member.getAvatar() == null) {
|
||||
for (UserInfo info : userInfos) {
|
||||
if (String.valueOf(info.getUid()).equals(member.getAccount())) {
|
||||
member.setNick(info.getNick());
|
||||
member.setAvatar(info.getAvatar());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (member != null
|
||||
&& !TextUtils.isEmpty(member.getAccount())
|
||||
&& map.containsKey(member.getAccount())) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
return paramList;
|
||||
|
@@ -1,7 +1,11 @@
|
||||
package com.yizhuan.erban.avroom.presenter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
import com.yizhuan.erban.avroom.view.ISingleRoomView;
|
||||
import com.yizhuan.erban.treasure_box.widget.GoldBoxHelper;
|
||||
import com.yizhuan.erban.utils.UserUtils;
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo;
|
||||
|
||||
/**
|
||||
* <p> </p>
|
||||
@@ -10,4 +14,50 @@ import com.yizhuan.erban.avroom.view.ISingleRoomView;
|
||||
* @date 2017/12/8
|
||||
*/
|
||||
public class SingleRoomPresenter extends BaseRoomPresenter<ISingleRoomView> {
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
public void getBannerList() {
|
||||
mAvRoomModel.getRoomBanner()
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(bannerInfos -> {
|
||||
final boolean firstCharge = UserUtils.getUserInfo().isFirstCharge();
|
||||
if (GoldBoxHelper.needIntegrateBoxEntrance()) {
|
||||
if (firstCharge) {
|
||||
BannerInfo bannerInfo = new BannerInfo();
|
||||
bannerInfo.setFirstCharge(true);
|
||||
bannerInfos.add(0, bannerInfo);
|
||||
}
|
||||
if (GoldBoxHelper.isShowRadish()) {
|
||||
BannerInfo bannerInfo = new BannerInfo();
|
||||
bannerInfo.setRadish(true);
|
||||
bannerInfos.add(firstCharge ? 1 : 0, bannerInfo);
|
||||
}
|
||||
GoldBoxHelper.isHideBox()
|
||||
.subscribe(isHide -> {
|
||||
if (!isHide) {
|
||||
BannerInfo bannerInfo = new BannerInfo();
|
||||
bannerInfo.setBox(true);
|
||||
int index = 0;
|
||||
if (firstCharge) index++;
|
||||
if (GoldBoxHelper.isShowRadish()) index++;
|
||||
bannerInfos.add(index, bannerInfo);
|
||||
}
|
||||
getMvpView().onShowBanner(bannerInfos);
|
||||
}, throwable -> getMvpView().onShowBanner(bannerInfos));
|
||||
} else {
|
||||
if(GoldBoxHelper.isShowFairy()){
|
||||
BannerInfo bannerInfo = new BannerInfo();
|
||||
bannerInfo.setFairy(true);
|
||||
bannerInfos.add(0, bannerInfo);
|
||||
}
|
||||
if (firstCharge) {
|
||||
BannerInfo bannerInfo = new BannerInfo();
|
||||
bannerInfo.setFirstCharge(true);
|
||||
bannerInfos.add(0, bannerInfo);
|
||||
}
|
||||
getMvpView().onShowBanner(bannerInfos);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,94 +0,0 @@
|
||||
package com.yizhuan.erban.avroom.rank
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import com.chuhai.utils.ktx.singleClick
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.databinding.RoomRankWidgetBinding
|
||||
import com.yizhuan.erban.ui.utils.loadAvatar
|
||||
import com.yizhuan.erban.ui.webview.DialogWebViewActivity
|
||||
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_core.UriProvider
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomContributeDataInfo
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomContributeUserInfo
|
||||
import com.yizhuan.xchat_android_core.room.model.RoomContributeListModel
|
||||
import com.yizhuan.xchat_android_core.utils.net.RxHelper
|
||||
|
||||
/**
|
||||
* 房间榜单入口
|
||||
*/
|
||||
class RoomRankWidget : FrameLayoutRoomWidget, RoomWidget {
|
||||
|
||||
private val binding: RoomRankWidgetBinding =
|
||||
DataBindingUtil.inflate(
|
||||
LayoutInflater.from(
|
||||
context
|
||||
), R.layout.room_rank_widget, this, true
|
||||
)
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr
|
||||
)
|
||||
|
||||
constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet?,
|
||||
defStyleAttr: Int,
|
||||
defStyleRes: Int
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
init {
|
||||
this.singleClick {
|
||||
DialogWebViewActivity.start(context, UriProvider.getRoomRanking())
|
||||
refreshData()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInitialize(roomView: RoomView, roomContext: RoomContext) {
|
||||
super.onInitialize(roomView, roomContext)
|
||||
refreshData()
|
||||
}
|
||||
|
||||
override fun onUnbindContext() {
|
||||
super.onUnbindContext()
|
||||
updateView(null)
|
||||
}
|
||||
|
||||
private fun refreshData() {
|
||||
val disposable = RoomContributeListModel.get()
|
||||
.getSingleRoomRanking(1, RoomContributeDataInfo.TYPE_ROOM_DAY_RANKING)
|
||||
.compose(RxHelper.handleBeanData())
|
||||
.subscribe { roomContributeDataInfo: RoomContributeDataInfo ->
|
||||
updateView(roomContributeDataInfo.rankings)
|
||||
}
|
||||
getCompositeDisposable().add(disposable)
|
||||
}
|
||||
|
||||
private fun updateView(list: List<RoomContributeUserInfo>?) {
|
||||
arrayListOf(
|
||||
binding.ivRank0, binding.ivRank1, binding.ivRank2
|
||||
).forEachIndexed { index, imageView ->
|
||||
val url = list?.getOrNull(index)?.avatar
|
||||
if (url.isNullOrEmpty()) {
|
||||
imageView.isVisible = false
|
||||
} else {
|
||||
imageView.loadAvatar(url)
|
||||
imageView.isVisible = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setContentBackgroundResource(resId: Int) {
|
||||
binding.layoutRoot.setBackgroundResource(resId)
|
||||
}
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,169 +0,0 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,188 @@
|
||||
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()
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,274 @@
|
||||
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()
|
||||
}
|
||||
|
||||
}
|
@@ -1,239 +0,0 @@
|
||||
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
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
this.dialogManager?.dismissDialog()
|
||||
this.dialogManager = null
|
||||
}
|
||||
|
||||
override fun onUnbindContext() {
|
||||
super.onUnbindContext()
|
||||
loadData(null)
|
||||
}
|
||||
|
||||
override fun onBindContext(roomContext: RoomContext) {
|
||||
super.onBindContext(roomContext)
|
||||
}
|
||||
|
||||
private fun stopCountDown() {
|
||||
if (countDownDisposable?.isDisposed == false) {
|
||||
countDownDisposable?.dispose()
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,557 +0,0 @@
|
||||
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
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,46 +0,0 @@
|
||||
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
|
||||
}
|
||||
}
|
@@ -1,284 +0,0 @@
|
||||
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
|
||||
}
|
||||
}
|
@@ -1,157 +0,0 @@
|
||||
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
|
||||
}
|
||||
}
|
@@ -1,172 +0,0 @@
|
||||
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()
|
||||
}
|
||||
}
|
@@ -1,76 +0,0 @@
|
||||
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)
|
||||
}
|
||||
}
|
@@ -1,116 +0,0 @@
|
||||
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) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,84 +0,0 @@
|
||||
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)
|
||||
}
|
||||
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
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
|
||||
}
|
||||
}
|
@@ -1,114 +0,0 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,201 +0,0 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,68 +0,0 @@
|
||||
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("成功")
|
||||
})
|
||||
}
|
||||
|
||||
}
|
@@ -1,100 +0,0 @@
|
||||
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>>>
|
||||
}
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
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)
|
||||
})
|
||||
}
|
||||
}
|
@@ -1,59 +0,0 @@
|
||||
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)
|
||||
}
|
||||
}
|
@@ -1,294 +0,0 @@
|
||||
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
|
||||
}
|
||||
|
||||
}
|
@@ -17,10 +17,8 @@ import com.yizhuan.erban.ui.user.activity.UserInfoActivity
|
||||
import com.yizhuan.erban.ui.utils.load
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomPkBean
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.room.anotherroompk.SingleRoomPKModel
|
||||
import com.yizhuan.xchat_android_core.utils.CurrentTimeUtils
|
||||
import com.yizhuan.xchat_android_core.utils.subAndReplaceDot
|
||||
import com.yizhuan.xchat_android_core.utils.toast
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
@@ -32,7 +30,7 @@ class SingleRoomPKBoardView @JvmOverloads constructor(
|
||||
) : FrameLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
private val binding = LayoutSingleRoomPkBoardViewBinding.inflate(LayoutInflater.from(context))
|
||||
private val observer = Observer<RoomPkBean?> { updateView(it) }
|
||||
private val observer = Observer<RoomPkBean> { updateView(it) }
|
||||
private var disposable: Disposable? = null
|
||||
private var roomPkBean: RoomPkBean? = null
|
||||
|
||||
@@ -57,20 +55,6 @@ class SingleRoomPKBoardView @JvmOverloads constructor(
|
||||
SingleRoomPkRuleDialog.newInstance().show(context)
|
||||
}
|
||||
|
||||
binding.ivMuteAnother.setOnClickListener {
|
||||
if (AvRoomDataManager.get().isRoomOwner) {
|
||||
roomPkBean?.let {
|
||||
if (it.roundId == null) {
|
||||
return@let
|
||||
}
|
||||
SingleRoomPKModel
|
||||
.muteSingleRoomPkOtherMic(it.roundId, it.aMicStatus xor 1)
|
||||
.subscribe()
|
||||
}
|
||||
} else {
|
||||
"主播已關閉對方房間的聲音".toast()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
@@ -134,13 +118,7 @@ class SingleRoomPKBoardView @JvmOverloads constructor(
|
||||
binding.ivPkResult.isVisible = true
|
||||
binding.ivPkResult.setImageResource(R.drawable.single_room_pk_ic_result_win)
|
||||
}
|
||||
if (roomPkBean?.aMicStatus == 0) {
|
||||
binding.ivMuteAnother.isVisible = true
|
||||
binding.ivMuteAnother.setImageResource(R.drawable.single_room_pk_ic_another_mic_close)
|
||||
} else {
|
||||
binding.ivMuteAnother.setImageResource(R.drawable.single_room_pk_ic_another_mic_open)
|
||||
binding.ivMuteAnother.isVisible = AvRoomDataManager.get().isRoomOwner
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -20,7 +20,6 @@ import com.yizhuan.xchat_android_core.utils.ifNotNullOrEmpty
|
||||
import com.yizhuan.xchat_android_core.utils.subAndReplaceDot
|
||||
import com.yizhuan.xchat_android_core.utils.toIntOrDef
|
||||
import com.yizhuan.xchat_android_core.utils.toast
|
||||
import com.yizhuan.xchat_android_library.common.application.Env
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil
|
||||
|
||||
class SingleRoomPKCreateActivity : BaseViewBindingActivity<ActivitySingleRoomPkCreateBinding>() {
|
||||
@@ -95,8 +94,7 @@ class SingleRoomPKCreateActivity : BaseViewBindingActivity<ActivitySingleRoomPkC
|
||||
|
||||
binding.tvOk.setOnClickListener {
|
||||
if (pkTime < 5 || pkTime > 30) {
|
||||
ResUtil.getString(R.string.avroom_singleroompk_singleroompkcreateactivity_01)
|
||||
.toast()
|
||||
ResUtil.getString(R.string.avroom_singleroompk_singleroompkcreateactivity_01).toast()
|
||||
return@setOnClickListener
|
||||
}
|
||||
currSimpleRoomInfo?.let {
|
||||
|
@@ -71,4 +71,6 @@ interface IBaseRoomView : IMvpBaseView {
|
||||
|
||||
fun updateMicView()
|
||||
|
||||
fun updateRoomRanks(data: List<RoomContributeUserInfo>)
|
||||
|
||||
}
|
@@ -1,5 +1,8 @@
|
||||
package com.yizhuan.erban.avroom.view;
|
||||
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p> 轰趴房View层 </p>
|
||||
@@ -9,4 +12,6 @@ package com.yizhuan.erban.avroom.view;
|
||||
*/
|
||||
public interface IGameRoomView extends IBaseRoomView {
|
||||
|
||||
void onShowBanner(List<BannerInfo> dialogInfos);
|
||||
|
||||
}
|
||||
|
@@ -3,7 +3,6 @@ package com.yizhuan.erban.avroom.view;
|
||||
|
||||
|
||||
import com.yizhuan.xchat_android_core.room.bean.OnlineChatMember;
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomOnlineUserBean;
|
||||
import com.yizhuan.xchat_android_library.base.IMvpBaseView;
|
||||
|
||||
import java.util.List;
|
||||
@@ -15,8 +14,7 @@ import java.util.List;
|
||||
* @date 2017/12/8
|
||||
*/
|
||||
public interface IHomePartyUserListView extends IMvpBaseView {
|
||||
|
||||
void onRequestRoomOnlineListSuccess(List<RoomOnlineUserBean> list);
|
||||
void onRequestChatMemberByPageSuccess(List<OnlineChatMember> memberList, int page);
|
||||
|
||||
void onRequestChatMemberByPageFail(String errorStr, int page);
|
||||
|
||||
|
@@ -1,7 +1,9 @@
|
||||
package com.yizhuan.erban.avroom.view;
|
||||
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo;
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p> 轰趴房View层 </p>
|
||||
@@ -18,4 +20,6 @@ public interface IHomePartyView extends IBaseRoomView {
|
||||
* 礼物值模式下换麦
|
||||
*/
|
||||
void onGiftValueChangeMic(int micPosition, String uId, boolean isInviteUpMic, RoomInfo roomInfo);
|
||||
|
||||
void onShowBanner(List<BannerInfo> bannerInfos);
|
||||
}
|
||||
|
@@ -1,5 +1,8 @@
|
||||
package com.yizhuan.erban.avroom.view;
|
||||
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p> 轰趴房View层 </p>
|
||||
@@ -9,4 +12,6 @@ package com.yizhuan.erban.avroom.view;
|
||||
*/
|
||||
public interface ISingleRoomView extends IBaseRoomView {
|
||||
|
||||
void onShowBanner(List<BannerInfo> dialogInfos);
|
||||
|
||||
}
|
||||
|
@@ -296,24 +296,17 @@ 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()) {
|
||||
if (svgaUrl != null && !svgaUrl.isEmpty()) {
|
||||
isPlaySvga = true;
|
||||
SVGAImageView imageView = playLuckyBagAnim(svgaUrl);
|
||||
handler.postDelayed(() -> {
|
||||
removeView(imageView);
|
||||
imageView.stopAnimation(true);
|
||||
}, 1800);
|
||||
}
|
||||
SVGAImageView imageView = playLuckyBagAnim(svgaUrl);
|
||||
handler.postDelayed(() -> {
|
||||
removeView(imageView);
|
||||
imageView.stopAnimation(true);
|
||||
}, 1800);
|
||||
}
|
||||
|
||||
if (isPlaySvga) {
|
||||
handler.postDelayed(() -> drawLuckyGiftAnimation(roomInfo, giftReceiveInfos, totalCoin, targetUsers, giftReceiveType, isShowAnimation, pos), 1200);
|
||||
} else {
|
||||
drawLuckyGiftAnimation(roomInfo, giftReceiveInfos, totalCoin, targetUsers, giftReceiveType, isShowAnimation, pos);
|
||||
}
|
||||
handler.postDelayed(() -> drawLuckyGiftAnimation(roomInfo, giftReceiveInfos, totalCoin, targetUsers, giftReceiveType, isShowAnimation, pos), 1200);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,7 +354,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
|
||||
targetUsers.add(giftReceiver);
|
||||
if (!isShowAnimation) return;
|
||||
giftInfo = giftReceiveInfo.getDisplayGift().get(pos);
|
||||
if (giftInfo != null && giftInfo.isHasEffect()) {
|
||||
if (totalCoin >= 520 || (giftInfo != null && giftInfo.isHasEffect())) {
|
||||
Message msg = Message.obtain();
|
||||
msg.what = 0;
|
||||
GiftEffectInfo giftEffectInfo = new GiftEffectInfo();
|
||||
|
@@ -2,10 +2,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_GUARDIAN_PLANET;
|
||||
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_ROOM_TEMPLATE;
|
||||
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;
|
||||
@@ -20,14 +17,12 @@ 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_DRAW_GIFT_L5;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_FANS_TEAM_JOIN;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_GIFT_COMPOUND;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUPER_LUCKY_GIFT_TEMPLATE;
|
||||
import static com.yizhuan.xchat_android_core.redpackage.RedPackageTypeKt.ALL_DIAMOND;
|
||||
import static com.yizhuan.xchat_android_core.redpackage.RedPackageTypeKt.ALL_GIFT;
|
||||
import static com.yizhuan.xchat_android_core.redpackage.RedPackageTypeKt.ROOM_DIAMOND;
|
||||
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;
|
||||
@@ -47,7 +42,6 @@ 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;
|
||||
@@ -58,7 +52,6 @@ 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;
|
||||
@@ -66,7 +59,6 @@ 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;
|
||||
@@ -75,18 +67,13 @@ 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;
|
||||
@@ -106,7 +93,6 @@ 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;
|
||||
@@ -122,7 +108,6 @@ import com.yizhuan.xchat_android_core.im.custom.bean.GiftAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.GiftBatchAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.GiftCompoundAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.GiftCompoundMsgBean;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.GuardianPlanetAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.JoinMiniWorldAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.JoinMiniWorldNoticeAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.MagicAllMicAttachment;
|
||||
@@ -134,21 +119,16 @@ 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.TemplateMessageAttachment;
|
||||
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;
|
||||
@@ -258,7 +238,6 @@ public class MessageView extends FrameLayout {
|
||||
private OnClick onClick;
|
||||
|
||||
private OnMsgLongClickListener onLongClickListener;
|
||||
private TemplateMessageAdapter templateMessageAdapter;
|
||||
|
||||
public MessageView(Context context) {
|
||||
this(context, null);
|
||||
@@ -439,17 +418,7 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private TemplateMessageAdapter getTemplateMessageAdapter() {
|
||||
if (templateMessageAdapter == null) {
|
||||
templateMessageAdapter = new TemplateMessageAdapter(uid -> {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(String.valueOf(uid)).subscribe(clickConsumer);
|
||||
}
|
||||
});
|
||||
}
|
||||
return templateMessageAdapter;
|
||||
}
|
||||
|
||||
public void onCurrentRoomReceiveNewMsg(List<ChatRoomMessage> messages) {
|
||||
@@ -633,19 +602,6 @@ public class MessageView extends FrameLayout {
|
||||
builder.setSpan(imageSpan, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* @param drawable -icon url
|
||||
* @return -返回一個spannableStringBuilder
|
||||
*/
|
||||
public SpannableBuilder appendImg(String drawable, Object what) {
|
||||
if (TextUtils.isEmpty(drawable)) return this;
|
||||
int start = builder.length();
|
||||
builder.append("-");
|
||||
CustomImageSpan imageSpan = new CustomImageSpan(new ColorDrawable(Color.TRANSPARENT), textView, drawable);
|
||||
builder.setSpan(imageSpan, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
builder.setSpan(what, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param drawable -icon url
|
||||
@@ -662,16 +618,6 @@ public class MessageView extends FrameLayout {
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpannableBuilder append(String drawable, int width, int height, Object what) {
|
||||
if (TextUtils.isEmpty(drawable)) return this;
|
||||
int start = builder.length();
|
||||
builder.append("-");
|
||||
CustomImageSpan imageSpan = new CustomImageSpan(new ColorDrawable(Color.TRANSPARENT), textView, drawable, width, height);
|
||||
builder.setSpan(imageSpan, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
builder.setSpan(what, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文本和背景分離的情況
|
||||
*/
|
||||
@@ -713,16 +659,6 @@ public class MessageView extends FrameLayout {
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpannableBuilder append(String imgUrl, int height, Object what) {
|
||||
if (TextUtils.isEmpty(imgUrl)) return this;
|
||||
int start = builder.length();
|
||||
builder.append("-");
|
||||
builder.setSpan(new CustomAutoWidthImageSpan(new ColorDrawable(Color.TRANSPARENT), textView, imgUrl, height)
|
||||
, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
builder.setSpan(what, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param drawable -icon
|
||||
* @param width 寬
|
||||
@@ -799,28 +735,8 @@ 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));
|
||||
}
|
||||
@@ -1079,24 +995,6 @@ 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 if (first == CUSTOM_MSG_GUARDIAN_PLANET) {
|
||||
setGuardianPlanetMsg(chatRoomMessage, tvContent);
|
||||
} else if (first == CUSTOM_MSG_ROOM_TEMPLATE) {
|
||||
TemplateMessageAttachment templateMessageAttachment = (TemplateMessageAttachment) chatRoomMessage.getAttachment();
|
||||
if (templateMessageAttachment != null) {
|
||||
getTemplateMessageAdapter().convert(tvContent, templateMessageAttachment.getTemplateMessage());
|
||||
} else {
|
||||
getTemplateMessageAdapter().convert(tvContent, null);
|
||||
}
|
||||
} else if (first == CUSTOM_MSG_SUPER_LUCKY_GIFT_TEMPLATE) {
|
||||
TemplateMessageAttachment templateMessageAttachment = (TemplateMessageAttachment) chatRoomMessage.getAttachment();
|
||||
if (templateMessageAttachment != null) {
|
||||
getTemplateMessageAdapter().convert(tvContent, templateMessageAttachment.getTemplateMessage());
|
||||
} else {
|
||||
getTemplateMessageAdapter().convert(tvContent, null);
|
||||
}
|
||||
} else {
|
||||
tvContent.setTextColor(Color.WHITE);
|
||||
tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip));
|
||||
@@ -1110,103 +1008,6 @@ 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();
|
||||
@@ -1525,7 +1326,7 @@ public class MessageView extends FrameLayout {
|
||||
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(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;
|
||||
@@ -2013,37 +1814,6 @@ public class MessageView extends FrameLayout {
|
||||
tvContent.setText(text.build());
|
||||
}
|
||||
|
||||
private void setGuardianPlanetMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) {
|
||||
GuardianPlanetAttachment attachment = (GuardianPlanetAttachment) chatRoomMessage.getAttachment();
|
||||
// 內容
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
.append(ResUtil.getString(R.string.congratulation), new ForegroundColorSpan(greyColor))
|
||||
.append(attachment.getNick(), new ForegroundColorSpan(roomTipNickColor),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(String.valueOf(attachment.getUid())).subscribe(clickConsumer);
|
||||
}
|
||||
}
|
||||
})
|
||||
.append(
|
||||
ResUtil.getString(R.string.guardian_planet_msg_1),
|
||||
new ForegroundColorSpan(greyColor)
|
||||
)
|
||||
.append(
|
||||
String.valueOf(attachment.getDiamonds()),
|
||||
new ForegroundColorSpan(whiteColor)
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.guardian_planet_msg_2),
|
||||
new ForegroundColorSpan(greyColor)
|
||||
);
|
||||
tvContent.setText(text.build());
|
||||
tvContent.setOnClickListener(null);
|
||||
tvContent.setMovementMethod(new LinkMovementMethod());
|
||||
}
|
||||
|
||||
private void setLuckySeaMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) {
|
||||
RoomLuckySeaAttachment attachment = (RoomLuckySeaAttachment) chatRoomMessage.getAttachment();
|
||||
RoomLuckySeaMsgBean bean = attachment.getRoomLuckySeaMsgInfo();
|
||||
@@ -2344,12 +2114,8 @@ public class MessageView extends FrameLayout {
|
||||
//等級
|
||||
builder.append(userLevel, expLevelHeight);
|
||||
//銘牌
|
||||
boolean isCustom = NobleUtil.getExtBoolean( chatRoomMessage,UserInfo.NAMEPLATE_IS_CUSTOM,false);
|
||||
String tvNamePlate = NobleUtil.getNamePlate(UserInfo.NAMEPLATE_WORD, chatRoomMessage).trim();
|
||||
String ivNamePlate = NobleUtil.getNamePlate(UserInfo.NAMEPLATE_PIC, chatRoomMessage);
|
||||
if (isCustom) {
|
||||
tvNamePlate = null;
|
||||
}
|
||||
if (!TextUtils.isEmpty(tvNamePlate) && !TextUtils.isEmpty(ivNamePlate)) { // extension != null 表示自己
|
||||
builder.appendBgAndContent(ivNamePlate, tvNamePlate);
|
||||
} else if (!TextUtils.isEmpty(ivNamePlate)) {
|
||||
|
@@ -116,9 +116,6 @@ public class MicroView extends LinearLayout implements View.OnLayoutChangeListen
|
||||
}
|
||||
|
||||
private void subMsg() {
|
||||
if (isInEditMode()) {
|
||||
return;
|
||||
}
|
||||
subscribe = IMNetEaseManager.get()
|
||||
.getChatRoomEventObservable().subscribe(
|
||||
roomEvent -> onReceiveRoomEvent(roomEvent),
|
||||
|
@@ -151,8 +151,8 @@ class RoomEffectBoxView @JvmOverloads constructor(
|
||||
.subscribe { roomEvent: RoomEvent? ->
|
||||
if (roomEvent == null || AvRoomDataManager.get().isSelfGamePlaying) return@subscribe
|
||||
when (roomEvent.event) {
|
||||
// RoomEvent.BOX_NOTIFY -> addBoxNotify(roomEvent.chatRoomMessage)
|
||||
// RoomEvent.BOX_NOTIFY_SVGA -> addBoxNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.BOX_NOTIFY -> addBoxNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.BOX_NOTIFY_SVGA -> addBoxNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.DATING_ALL_NOTIFY -> addDatingAllNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.RADISH_NOTIFY,
|
||||
RoomEvent.RADISH_NOTIFY_SVGA -> addRadishNotify(roomEvent.chatRoomMessage)
|
||||
|
@@ -4,7 +4,6 @@ import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.text.Layout
|
||||
import android.text.StaticLayout
|
||||
import android.text.TextPaint
|
||||
@@ -20,49 +19,34 @@ import android.view.animation.AnimationUtils
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.NonNull
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.core.util.Consumer
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.bumptech.glide.request.target.CustomTarget
|
||||
import com.bumptech.glide.request.transition.Transition
|
||||
import com.chuhai.utils.UiUtils
|
||||
import com.chuhai.utils.ktx.setPadding2
|
||||
import com.coorchice.library.SuperTextView
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import com.netease.nim.uikit.support.glide.GlideApp
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomNotificationAttachment
|
||||
import com.opensource.svgaplayer.*
|
||||
import com.opensource.svgaplayer.SVGAParser.Companion.shareParser
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.application.XChatApplication
|
||||
import com.yizhuan.erban.avroom.activity.AVRoomActivity
|
||||
import com.yizhuan.erban.avroom.bean.RoomPlayBean
|
||||
import com.yizhuan.erban.avroom.helper.AnimHelper
|
||||
import com.yizhuan.erban.base.TitleBar
|
||||
import com.yizhuan.erban.common.svga.SimpleSvgaCallback
|
||||
import com.yizhuan.erban.databinding.LayoutRoomEffectBinding
|
||||
import com.yizhuan.erban.treasure_box.activity.TreasureBoxActivity
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtils
|
||||
import com.yizhuan.erban.ui.utils.isDestroyed
|
||||
import com.yizhuan.erban.ui.utils.load
|
||||
import com.yizhuan.erban.ui.utils.loadAnim
|
||||
import com.yizhuan.erban.ui.webview.CommonWebViewActivity
|
||||
import com.yizhuan.erban.ui.widget.SimpleAnimListener
|
||||
import com.yizhuan.erban.ui.widget.dialog.AllServiceGiftGoRoomTipsDialog
|
||||
import com.yizhuan.erban.ui.widget.dialog.AllServiceGiftGoRoomTipsDialog.Companion.isNeedTips
|
||||
import com.yizhuan.erban.ui.widget.drawgift.DrawGiftPlayHelper
|
||||
import com.yizhuan.erban.utils.CommonJumpHelper
|
||||
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
|
||||
import com.yizhuan.xchat_android_core.decoration.car.bean.CarInfo
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
|
||||
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
|
||||
@@ -150,37 +134,14 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
|
||||
private val drawGiftPlayHelper: DrawGiftPlayHelper by lazy { DrawGiftPlayHelper(context as Activity) }
|
||||
|
||||
private var playNotifyStateLiveData: MutableLiveData<Boolean>? = null
|
||||
|
||||
private var showUserCardAction: ((String) -> Unit)? = null
|
||||
|
||||
private val templateMessageAdapter =
|
||||
TemplateMessageAdapter(listener = object : TemplateMessageAdapter.Listener {
|
||||
override fun onShowUserCard(uid: String) {
|
||||
showUserCardAction?.invoke(uid)
|
||||
}
|
||||
})
|
||||
private var isPlayAnim = false
|
||||
|
||||
private var onPlayAnimCallback: (() -> Boolean)? = null
|
||||
fun setPlayNotifyStateListener(stateLiveData: MutableLiveData<Boolean>) {
|
||||
this.playNotifyStateLiveData = stateLiveData
|
||||
}
|
||||
|
||||
fun setOnPlayAnimCallback(onPlayAnimCallback: (() -> Boolean)) {
|
||||
this.onPlayAnimCallback = onPlayAnimCallback
|
||||
}
|
||||
|
||||
fun setShowUserCardAction(call: Consumer<String>) {
|
||||
this.showUserCardAction = {
|
||||
call.accept(it)
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private fun isShowingGiftNotify(): Boolean {
|
||||
return onPlayAnimCallback?.invoke() ?: false
|
||||
}
|
||||
|
||||
private fun loopCarAnim() {
|
||||
if (context.isDestroyed()) return
|
||||
isSvgaPlaying = false
|
||||
@@ -233,18 +194,6 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage)
|
||||
}
|
||||
|
||||
RoomEvent.CRAZY_ZOO_ROOM_NOTIFY -> {// 疯狂动物园-房间
|
||||
addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage)
|
||||
}
|
||||
|
||||
RoomEvent.CRAZY_ZOO_ALL_ROOM_NOTIFY -> {// 疯狂动物园-全服
|
||||
addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage)
|
||||
}
|
||||
|
||||
RoomEvent.TEMPLATE_NOTIFY -> {// 通用模版飘屏
|
||||
addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage)
|
||||
}
|
||||
|
||||
RoomEvent.FAIRY_DRAW_GIFT_L4,
|
||||
RoomEvent.FAIRY_DRAW_GIFT_L5,
|
||||
RoomEvent.FAIRY_CONVERT_L1,
|
||||
@@ -281,7 +230,7 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
|
||||
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
|
||||
@@ -316,11 +265,6 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
loopCarAnim()
|
||||
}
|
||||
})
|
||||
var statusBarHeight = TitleBar.getStatusBarHeight()
|
||||
if (statusBarHeight == 0) {
|
||||
statusBarHeight = UiUtils.dip2px(25f)
|
||||
}
|
||||
binding.clNotify.setPadding2(top = binding.clNotify.paddingTop + statusBarHeight)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -341,18 +285,29 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
if (binding.flPlayNotify.childCount != 0) {
|
||||
return@subscribe
|
||||
}
|
||||
if (binding.flTemplateNotify.childCount != 0) {
|
||||
return@subscribe
|
||||
}
|
||||
if (binding.flLuckyBagNotify.childCount != 0) {
|
||||
return@subscribe
|
||||
}
|
||||
val isPlay = onPlayAnimCallback?.invoke() ?: false
|
||||
|
||||
when (messagesPlay[0].event) {
|
||||
RoomEvent.BOX_NOTIFY -> {//寻爱
|
||||
if ((mContext as AVRoomActivity).isTopActivity || XChatApplication.gStack.topActivity is TreasureBoxActivity) {
|
||||
playNotifyStateLiveData?.value = true
|
||||
resetPlayNotifyMargin()
|
||||
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)
|
||||
)
|
||||
@@ -360,17 +315,51 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
RoomEvent.BOX_NOTIFY_SVGA -> {//寻爱
|
||||
if ((mContext as AVRoomActivity).isTopActivity || XChatApplication.gStack.topActivity is TreasureBoxActivity) {
|
||||
playNotifyStateLiveData?.value = true
|
||||
resetPlayNotifyMargin()
|
||||
if ((mContext as AVRoomActivity).isTopActivity) {
|
||||
isPlayAnim = true
|
||||
val isPlay = onPlayAnimCallback?.invoke() ?: false
|
||||
if (isPlay) {
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, 180.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
} else {
|
||||
margin(
|
||||
binding.clNotify,
|
||||
0,
|
||||
UIUtil.dip2px(context, 60.0),
|
||||
0,
|
||||
0
|
||||
)
|
||||
}
|
||||
showBoxNotifyBySVGA(messagesPlay.removeAt(0))
|
||||
}
|
||||
}
|
||||
|
||||
RoomEvent.TAROT_NOTIFY -> {
|
||||
if ((mContext as AVRoomActivity).isTopActivity) {
|
||||
playNotifyStateLiveData?.value = true
|
||||
resetPlayNotifyMargin()
|
||||
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
|
||||
)
|
||||
}
|
||||
showTarotNotify(
|
||||
messagesPlay.removeAt(0)
|
||||
)
|
||||
@@ -379,8 +368,25 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
|
||||
RoomEvent.TAROT_NOTIFY_SVGA -> {
|
||||
if ((mContext as AVRoomActivity).isTopActivity) {
|
||||
playNotifyStateLiveData?.value = true
|
||||
resetPlayNotifyMargin()
|
||||
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
|
||||
)
|
||||
}
|
||||
showTarotNotifyBySVGA(messagesPlay.removeAt(0))
|
||||
}
|
||||
}
|
||||
@@ -389,8 +395,17 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
if (!(mContext as AVRoomActivity).isTopActivity) {
|
||||
return@subscribe
|
||||
}
|
||||
playNotifyStateLiveData?.value = true
|
||||
resetPlayNotifyMargin()
|
||||
|
||||
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
|
||||
@@ -403,58 +418,56 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
RoomEvent.RECEIVE_ROOM_LUCKY_BAG_NOTICE, RoomEvent.RECEIVE_SERVICE_LUCKY_BAG_NOTICE -> {//福袋
|
||||
playNotifyStateLiveData?.value = true
|
||||
resetPlayNotifyMargin()
|
||||
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 -> {//星级厨房
|
||||
playNotifyStateLiveData?.value = true
|
||||
resetPlayNotifyMargin()
|
||||
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 -> {//星级厨房
|
||||
playNotifyStateLiveData?.value = true
|
||||
resetPlayNotifyMargin()
|
||||
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.CRAZY_ZOO_ROOM_NOTIFY -> {//疯狂动物园-房间(静态)
|
||||
playNotifyStateLiveData?.value = true
|
||||
resetPlayNotifyMargin()
|
||||
showZooNotify(
|
||||
messagesPlay.removeAt(0)
|
||||
)
|
||||
}
|
||||
|
||||
RoomEvent.CRAZY_ZOO_ALL_ROOM_NOTIFY -> {//疯狂动物园-全服(动态)
|
||||
playNotifyStateLiveData?.value = true
|
||||
resetPlayNotifyMargin()
|
||||
showZooNotifyBySVGA(
|
||||
messagesPlay.removeAt(0)
|
||||
)
|
||||
}
|
||||
|
||||
RoomEvent.TEMPLATE_NOTIFY -> {//通用模版飘屏
|
||||
resetPlayNotifyMargin()
|
||||
showTemplateNotify(
|
||||
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 -> {//夺宝
|
||||
playNotifyStateLiveData?.value = true
|
||||
resetPlayNotifyMargin()
|
||||
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)
|
||||
)
|
||||
@@ -481,8 +494,8 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
textView.startAnimation(animationPlay)
|
||||
binding.flPlayNotify.postDelayed(
|
||||
{
|
||||
playNotifyStateLiveData?.value = false
|
||||
binding.flPlayNotify.removeView(textView)
|
||||
isPlayAnim = false
|
||||
},
|
||||
SHOW_TIME.toLong()
|
||||
)
|
||||
@@ -508,8 +521,8 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
svgaImageView.callback = object : SimpleSvgaCallback() {
|
||||
override fun onFinished() {
|
||||
binding.flPlayNotify.post {
|
||||
playNotifyStateLiveData?.value = false
|
||||
binding.flPlayNotify.removeView(svgaImageView)
|
||||
isPlayAnim = false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -628,19 +641,6 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
) + "…"
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置玩法飘窗间距
|
||||
*/
|
||||
private fun resetPlayNotifyMargin() {
|
||||
var top = 0
|
||||
if (isShowingGiftNotify()) {
|
||||
// 有礼物飘窗展示时,需要在它下面展示
|
||||
// 间距 = 礼物飘窗高度(375:69) + 10DP间距
|
||||
top = (width / 375f * 69).toInt() + UiUtils.dip2px(10f)
|
||||
}
|
||||
margin(binding.clNotify, 0, top, 0, 0)
|
||||
}
|
||||
|
||||
private fun margin(v: View, l: Int, t: Int, r: Int, b: Int) {
|
||||
if (v.layoutParams is MarginLayoutParams) {
|
||||
val params = v.layoutParams as MarginLayoutParams
|
||||
@@ -653,69 +653,89 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
val message = roomPlayBean.chatRoomMessage
|
||||
val attachment = message.attachment as? RoomReceivedLuckyGiftAttachment ?: return
|
||||
val noticeInfo = attachment.luckyBagNoticeInfo ?: return
|
||||
val roomView = LayoutInflater.from(mContext)
|
||||
.inflate(R.layout.layout_room_lucky_bag_notify, null)
|
||||
val bagImageView = roomView.findViewById<ImageView>(R.id.iv_bag)
|
||||
bagImageView.load(noticeInfo.luckyBagGiftPic)
|
||||
val giftImageView = roomView.findViewById<ImageView>(R.id.iv_gift)
|
||||
giftImageView.load(noticeInfo.giftPic)
|
||||
val messageTextView = roomView.findViewById<TextView>(R.id.tv_message)
|
||||
val text = SpannableBuilder()
|
||||
.append(
|
||||
noticeInfo.nick.subAndReplaceDot(6),
|
||||
ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_FFF45E))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_027),
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_04),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
noticeInfo.luckyBagName,
|
||||
ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_FFF45E))
|
||||
noticeInfo.nick.subAndReplaceDot(6) + " ",
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_028),
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_05),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
noticeInfo.goldPrice + ResUtil.getString(R.string.diamond_name),
|
||||
ForegroundColorSpan(ContextCompat.getColor(context, R.color.notice_nick))
|
||||
noticeInfo.luckyBagName + " ",
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_029),
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_06),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
noticeInfo.goldPrice + " ",
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.avroom_widget_roomeffectview_07),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
noticeInfo.giftName,
|
||||
ForegroundColorSpan(ContextCompat.getColor(context, R.color.notice_nick))
|
||||
)
|
||||
if (noticeInfo.giftNum > 1) {
|
||||
text.append(
|
||||
"X" + noticeInfo.giftNum,
|
||||
ForegroundColorSpan(ContextCompat.getColor(context, R.color.white))
|
||||
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
|
||||
)
|
||||
|
||||
val svgaImageView = SVGAImageView(mContext)
|
||||
svgaImageView.loops = 1
|
||||
svgaImageView.clearsAfterStop = true
|
||||
shareParser().decodeFromAssets(
|
||||
"svga/lucky_gift_notify.svga",
|
||||
object : SVGAParser.ParseCompletion {
|
||||
override fun onComplete(videoItem: SVGAVideoEntity) {
|
||||
binding.flPlayNotify.addView(svgaImageView)
|
||||
val dynamicEntity = SVGADynamicEntity()
|
||||
val textPaint = TextPaint()
|
||||
textPaint.color = Color.WHITE //字體顏色
|
||||
textPaint.textSize = 24f //字體大小
|
||||
dynamicEntity.setDynamicText(
|
||||
StaticLayout(
|
||||
text.build(),
|
||||
0,
|
||||
text.build().length,
|
||||
textPaint,
|
||||
0,
|
||||
Layout.Alignment.ALIGN_CENTER,
|
||||
1.0f,
|
||||
0.0f,
|
||||
false
|
||||
), "fdpp_copywriting"
|
||||
)
|
||||
if (AvRoomDataManager.get().roomUid == noticeInfo.roomUid) {
|
||||
dynamicEntity.setHidden(true, "img_206")
|
||||
} else {
|
||||
svgaImageView.setOnClickListener {
|
||||
//跳轉房間要移除監聽,不然可能NPE
|
||||
svgaImageView.callback = null
|
||||
AVRoomActivity.start(mContext, noticeInfo.roomUid)
|
||||
}
|
||||
}
|
||||
val drawable = SVGADrawable(videoItem, dynamicEntity)
|
||||
svgaImageView.setImageDrawable(drawable)
|
||||
svgaImageView.stepToFrame(0, true)
|
||||
}
|
||||
|
||||
override fun onError() {}
|
||||
})
|
||||
svgaImageView.callback = object : SimpleSvgaCallback() {
|
||||
override fun onFinished() {
|
||||
binding.flPlayNotify.post {
|
||||
binding.flPlayNotify.removeView(svgaImageView)
|
||||
isPlayAnim = false
|
||||
}
|
||||
}
|
||||
}
|
||||
messageTextView.text = text.build()
|
||||
bagImageView.setOnClickListener {
|
||||
goRoom(noticeInfo.roomTitle, noticeInfo.roomUid)
|
||||
}
|
||||
giftImageView.setOnClickListener {
|
||||
goRoom(noticeInfo.roomTitle, noticeInfo.roomUid)
|
||||
}
|
||||
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
binding.flLuckyBagNotify.addView(roomView)
|
||||
roomView.startAnimation(animationPlay)
|
||||
binding.flLuckyBagNotify.postDelayed(
|
||||
{
|
||||
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
|
||||
roomView.startAnimation(animationPlay)
|
||||
},
|
||||
6500
|
||||
)
|
||||
binding.flLuckyBagNotify.postDelayed({
|
||||
playNotifyStateLiveData?.value = false
|
||||
binding.flLuckyBagNotify.removeView(roomView)
|
||||
}, 7000)
|
||||
}
|
||||
|
||||
private fun showLuckySeaNotify(roomPlayBean: RoomPlayBean) {
|
||||
@@ -760,212 +780,13 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
textView.startAnimation(animationPlay)
|
||||
binding.flPlayNotify.postDelayed(
|
||||
{
|
||||
playNotifyStateLiveData?.value = false
|
||||
binding.flPlayNotify.removeView(textView)
|
||||
isPlayAnim = false
|
||||
},
|
||||
SHOW_TIME.toLong()
|
||||
)
|
||||
}
|
||||
|
||||
private fun showZooNotify(roomPlayBean: RoomPlayBean) {
|
||||
val chatRoomMessage = roomPlayBean.chatRoomMessage
|
||||
val attachment = chatRoomMessage.attachment as RoomLuckySeaAttachment
|
||||
val bean = attachment.roomLuckySeaMsgInfo
|
||||
val textView =
|
||||
LayoutInflater.from(mContext)
|
||||
.inflate(R.layout.layout_room_zoo_notify, null) as TextView
|
||||
val text = SpannableBuilder()
|
||||
.append(
|
||||
ResUtil.getString(R.string.congratulation),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
bean.nick,
|
||||
ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_FEF23E))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.in_the_zoo),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
bean.itemMultiple.toString(),
|
||||
ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_00EAFF))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.times_reward_get),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
bean.diamonds.toString(),
|
||||
ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_00EAFF))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.diamond_point),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
textView.text = text.build()
|
||||
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
binding.flPlayNotify.addView(textView)
|
||||
textView.startAnimation(animationPlay)
|
||||
binding.flPlayNotify.postDelayed(
|
||||
{
|
||||
playNotifyStateLiveData?.value = false
|
||||
binding.flPlayNotify.removeView(textView)
|
||||
},
|
||||
SHOW_TIME.toLong()
|
||||
)
|
||||
}
|
||||
|
||||
private fun showTemplateNotify(roomPlayBean: RoomPlayBean) {
|
||||
val chatRoomMessage = roomPlayBean.chatRoomMessage
|
||||
val attachment =
|
||||
chatRoomMessage.attachment as? RoomTemplateNotifyAttachment
|
||||
val msgBean = attachment?.getTemplateMsg()
|
||||
val resourceType = msgBean?.resourceType
|
||||
if (resourceType == "IMAGE") {
|
||||
showTemplateImageNotify(msgBean)
|
||||
} else if (resourceType == "SVGA") {
|
||||
showTemplateSvgaNotify(msgBean)
|
||||
}
|
||||
}
|
||||
|
||||
private fun showTemplateImageNotify(msgBean: RoomTemplateNotifyMsgBean) {
|
||||
if (msgBean.resourceType != "IMAGE") {
|
||||
return
|
||||
}
|
||||
val resourceContent = msgBean.resourceContent
|
||||
if (resourceContent.isNullOrEmpty()) {
|
||||
return
|
||||
}
|
||||
playNotifyStateLiveData?.value = true
|
||||
val rootView = LayoutInflater.from(mContext)
|
||||
.inflate(R.layout.layout_room_template_notify_image, null)
|
||||
val textView = rootView.findViewById<TextView>(R.id.tv_text)
|
||||
val textSize = msgBean.fontSize?.toFloat() ?: 12f
|
||||
val textColor =
|
||||
templateMessageAdapter.parseColor(msgBean.textColor) ?: Color.WHITE
|
||||
textView.textSize = textSize
|
||||
textView.setTextColor(textColor)
|
||||
val bgView = rootView.findViewById<ImageView>(R.id.iv_bg)
|
||||
val params = ConstraintLayout.LayoutParams(
|
||||
ConstraintLayout.LayoutParams.MATCH_PARENT,
|
||||
ConstraintLayout.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
binding.flTemplateNotify.addView(rootView, params)
|
||||
val endAction = {
|
||||
playNotifyStateLiveData?.value = false
|
||||
binding.flTemplateNotify.removeView(rootView)
|
||||
}
|
||||
GlideApp.with(bgView)
|
||||
.load(resourceContent).into(object : CustomTarget<Drawable>() {
|
||||
override fun onResourceReady(
|
||||
resource: Drawable,
|
||||
transition: Transition<in Drawable>?
|
||||
) {
|
||||
templateMessageAdapter.convert(textView, msgBean)
|
||||
bgView.setImageDrawable(resource)
|
||||
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
|
||||
rootView.startAnimation(animationPlay)
|
||||
val skipType = msgBean.skipType
|
||||
if (skipType != null) {
|
||||
val clickAction = View.OnClickListener {
|
||||
if (skipType == BannerInfo.SKIP_TYPE_ROOM_USER_CARD) {
|
||||
showUserCardAction?.invoke(msgBean.skipContent ?: "")
|
||||
} else {
|
||||
CommonJumpHelper.bannerJump(context, skipType, msgBean.skipContent)
|
||||
}
|
||||
}
|
||||
rootView.setOnClickListener(clickAction)
|
||||
textView.setOnClickListener(clickAction)
|
||||
}
|
||||
binding.flTemplateNotify.postDelayed(endAction, SHOW_TIME.toLong())
|
||||
}
|
||||
|
||||
override fun onLoadCleared(placeholder: Drawable?) {
|
||||
endAction.invoke()
|
||||
}
|
||||
|
||||
override fun onLoadFailed(errorDrawable: Drawable?) {
|
||||
super.onLoadFailed(errorDrawable)
|
||||
endAction.invoke()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun showTemplateSvgaNotify(msgBean: RoomTemplateNotifyMsgBean) {
|
||||
if (msgBean.resourceType != "SVGA") {
|
||||
return
|
||||
}
|
||||
val resourceContent = msgBean.resourceContent
|
||||
if (resourceContent.isNullOrEmpty()) {
|
||||
return
|
||||
}
|
||||
playNotifyStateLiveData?.value = true
|
||||
val svgaImageView = SVGAImageView(mContext)
|
||||
val endAction = {
|
||||
playNotifyStateLiveData?.value = false
|
||||
binding.flTemplateNotify.removeView(svgaImageView)
|
||||
}
|
||||
svgaImageView.loops = 1
|
||||
svgaImageView.clearsAfterDetached = true
|
||||
val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, 0)
|
||||
params.dimensionRatio = msgBean.getDimensionRatio() ?: "75:11"
|
||||
svgaImageView.layoutParams = params
|
||||
svgaImageView.callback = object : SimpleSvgaCallback() {
|
||||
override fun onFinished() {
|
||||
endAction.invoke()
|
||||
}
|
||||
}
|
||||
binding.flTemplateNotify.addView(svgaImageView)
|
||||
shareParser().decodeFromURL(
|
||||
URL(resourceContent),
|
||||
object : SVGAParser.ParseCompletion {
|
||||
override fun onComplete(videoItem: SVGAVideoEntity) {
|
||||
val text = templateMessageAdapter.parse(context, msgBean) ?: ""
|
||||
val textKey = msgBean.getSvgaTextKey()
|
||||
val textSize = msgBean.fontSize?.toFloat() ?: 24f
|
||||
val textColor =
|
||||
templateMessageAdapter.parseColor(msgBean.textColor) ?: Color.WHITE
|
||||
val dynamicEntity = SVGADynamicEntity()
|
||||
val textPaint = TextPaint()
|
||||
textPaint.color = textColor //字體顏色
|
||||
textPaint.textSize = textSize //字體大小
|
||||
dynamicEntity.setDynamicText(
|
||||
StaticLayout(
|
||||
text,
|
||||
0,
|
||||
text.length,
|
||||
textPaint,
|
||||
0,
|
||||
Layout.Alignment.ALIGN_CENTER,
|
||||
1.0f,
|
||||
0.0f,
|
||||
false
|
||||
), textKey
|
||||
)
|
||||
val skipType = msgBean.skipType
|
||||
if (skipType != null) {
|
||||
svgaImageView.setOnClickListener {
|
||||
if (skipType == BannerInfo.SKIP_TYPE_ROOM_USER_CARD) {
|
||||
showUserCardAction?.invoke(msgBean.skipContent?:"")
|
||||
} else {
|
||||
CommonJumpHelper.bannerJump(context, skipType, msgBean.skipContent)
|
||||
}
|
||||
}
|
||||
}
|
||||
val drawable = SVGADrawable(videoItem, dynamicEntity)
|
||||
svgaImageView.setImageDrawable(drawable)
|
||||
svgaImageView.stepToFrame(0, true)
|
||||
}
|
||||
|
||||
override fun onError() {
|
||||
endAction.invoke()
|
||||
}
|
||||
},
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
private fun showLuckySeaNotifyBySVGA(roomPlayBean: RoomPlayBean) {
|
||||
val chatRoomMessage = roomPlayBean.chatRoomMessage
|
||||
val attachment = chatRoomMessage.attachment as RoomLuckySeaAttachment
|
||||
@@ -1007,8 +828,8 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
svgaImageView.callback = object : SimpleSvgaCallback() {
|
||||
override fun onFinished() {
|
||||
binding.flPlayNotify.post {
|
||||
playNotifyStateLiveData?.value = false
|
||||
binding.flPlayNotify.removeView(svgaImageView)
|
||||
isPlayAnim = false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1050,93 +871,9 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
)
|
||||
}
|
||||
|
||||
private fun showZooNotifyBySVGA(roomPlayBean: RoomPlayBean) {
|
||||
val chatRoomMessage = roomPlayBean.chatRoomMessage
|
||||
val attachment = chatRoomMessage.attachment as RoomLuckySeaAttachment
|
||||
val bean = attachment.roomLuckySeaMsgInfo
|
||||
val text = SpannableBuilder()
|
||||
.append(
|
||||
ResUtil.getString(R.string.congratulation),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
bean.nick + " ",
|
||||
ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_FEF23E))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.in_the_zoo),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
bean.itemMultiple.toString(),
|
||||
ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_00EAFF))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.times_reward_get),
|
||||
ForegroundColorSpan(Color.WHITE)
|
||||
)
|
||||
.append(
|
||||
bean.diamonds.toString(),
|
||||
ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_00EAFF))
|
||||
)
|
||||
.append(
|
||||
ResUtil.getString(R.string.diamond_point),
|
||||
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() {
|
||||
binding.flPlayNotify.post {
|
||||
playNotifyStateLiveData?.value = false
|
||||
binding.flPlayNotify.removeView(svgaImageView)
|
||||
}
|
||||
}
|
||||
}
|
||||
binding.flPlayNotify.addView(svgaImageView)
|
||||
shareParser().decodeFromAssets(
|
||||
"svga/zoo_notify.svga",
|
||||
object : SVGAParser.ParseCompletion {
|
||||
override fun onComplete(videoItem: SVGAVideoEntity) {
|
||||
val dynamicEntity = SVGADynamicEntity()
|
||||
val textPaint = TextPaint()
|
||||
textPaint.color = Color.WHITE //字體顏色
|
||||
textPaint.textSize = 24f //字體大小
|
||||
dynamicEntity.setDynamicText(
|
||||
StaticLayout(
|
||||
text.build(),
|
||||
0,
|
||||
text.build().length,
|
||||
textPaint,
|
||||
0,
|
||||
Layout.Alignment.ALIGN_CENTER,
|
||||
1.0f,
|
||||
0.0f,
|
||||
false
|
||||
), "noble_text_tx"
|
||||
)
|
||||
svgaImageView.setOnClickListener {
|
||||
if (!TextUtils.isEmpty(bean.skipUrl)) {
|
||||
CommonWebViewActivity.start(mContext, bean.skipUrl)
|
||||
}
|
||||
}
|
||||
val drawable = SVGADrawable(videoItem, dynamicEntity)
|
||||
svgaImageView.setImageDrawable(drawable)
|
||||
svgaImageView.stepToFrame(0, true)
|
||||
}
|
||||
|
||||
override fun onError() {}
|
||||
},
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
private fun showNotifyH5(data: NotifyH5Info) {
|
||||
val textView = LayoutInflater.from(mContext)
|
||||
.inflate(R.layout.layout_notify_h5, null) as TextView
|
||||
.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)
|
||||
@@ -1149,8 +886,8 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
SHOW_TIME.toLong()
|
||||
)
|
||||
binding.flPlayNotify.postDelayed({
|
||||
playNotifyStateLiveData?.value = false
|
||||
binding.flPlayNotify.removeView(textView)
|
||||
isPlayAnim = false
|
||||
}, CLOSE_TIME.toLong())
|
||||
}
|
||||
|
||||
@@ -1164,8 +901,8 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
svgaImageView.callback = object : SimpleSvgaCallback() {
|
||||
override fun onFinished() {
|
||||
binding.flPlayNotify.post {
|
||||
playNotifyStateLiveData?.value = false
|
||||
binding.flPlayNotify.removeView(svgaImageView)
|
||||
isPlayAnim = false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1225,8 +962,8 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
SHOW_TIME.toLong()
|
||||
)
|
||||
binding.flPlayNotify.postDelayed({
|
||||
playNotifyStateLiveData?.value = false
|
||||
binding.flPlayNotify.removeView(textView)
|
||||
isPlayAnim = false
|
||||
}, CLOSE_TIME.toLong())
|
||||
}
|
||||
|
||||
@@ -1268,8 +1005,8 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
SHOW_TIME.toLong()
|
||||
)
|
||||
binding.flPlayNotify.postDelayed({
|
||||
playNotifyStateLiveData?.value = false
|
||||
binding.flPlayNotify.removeView(textView)
|
||||
isPlayAnim = false
|
||||
}, CLOSE_TIME.toLong())
|
||||
}
|
||||
|
||||
@@ -1291,8 +1028,8 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
svgaImageView.callback = object : SimpleSvgaCallback() {
|
||||
override fun onFinished() {
|
||||
binding.flPlayNotify.post {
|
||||
playNotifyStateLiveData?.value = false
|
||||
binding.flPlayNotify.removeView(svgaImageView)
|
||||
isPlayAnim = false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1363,8 +1100,8 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
|
||||
animationPlay!!.setAnimationListener(object : SimpleAnimationListener() {
|
||||
override fun onAnimationEnd(animation: Animation?) {
|
||||
playNotifyStateLiveData?.value = false
|
||||
binding.flPlayNotify.removeView(svgaImageView)
|
||||
isPlayAnim = false
|
||||
}
|
||||
})
|
||||
binding.flPlayNotify.startAnimation(animationPlay)
|
||||
@@ -2170,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) {
|
||||
@@ -2219,6 +1935,10 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
}, SHOW_TIME.toLong())
|
||||
}
|
||||
|
||||
fun getIsPlayAnim(): Boolean {
|
||||
return isPlayAnim
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
playDisposable?.dispose()
|
||||
@@ -2232,20 +1952,7 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
disposableRoomPK?.dispose()
|
||||
disposableSingleRoomPK?.dispose()
|
||||
disposableGiftCompound?.dispose()
|
||||
playNotifyStateLiveData?.value = false
|
||||
isPlayAnim = false
|
||||
}
|
||||
|
||||
private fun goRoom(roomTitle: String, roomUid: Long) {
|
||||
if (roomUid <= 0L) {
|
||||
return
|
||||
}
|
||||
if (roomUid == AvRoomDataManager.get().roomUid) {
|
||||
return
|
||||
}
|
||||
if (isNeedTips()) {
|
||||
AllServiceGiftGoRoomTipsDialog(context, roomTitle, roomUid).show()
|
||||
} else {
|
||||
AVRoomActivity.start(context, roomUid)
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,179 +0,0 @@
|
||||
package com.yizhuan.erban.avroom.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import com.chuhai.utils.UiUtils
|
||||
import com.yizhuan.erban.common.widget.OriginalDrawStatusClickSpan
|
||||
import com.yizhuan.erban.utils.CommonJumpHelper
|
||||
import com.yizhuan.erban.utils.SpannableBuilder
|
||||
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.TemplateMessage
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.TemplateMessage.TemplateNode
|
||||
|
||||
/**
|
||||
* Created by Max on 2024/2/22 17:20
|
||||
* Desc:模版消息适配器
|
||||
**/
|
||||
class TemplateMessageAdapter(val listener: Listener?) {
|
||||
|
||||
/**
|
||||
* 解析为文本(子节点只支持TEXT类型)
|
||||
*/
|
||||
fun parse(context: Context, attachment: TemplateMessage?): SpannableStringBuilder? {
|
||||
val builder = SpannableBuilder()
|
||||
if (attachment == null) {
|
||||
return null
|
||||
}
|
||||
val nodeList = attachment.getNodeList()
|
||||
nodeList.forEach {
|
||||
if (it is TemplateNode.NormalNode) {
|
||||
val textColor = parseColor(it.textColor)
|
||||
if (textColor != null) {
|
||||
builder.append(it.text, ForegroundColorSpan(textColor))
|
||||
} else {
|
||||
builder.append(it.text)
|
||||
}
|
||||
} else if (it is TemplateNode.SpecialNode) {
|
||||
when (it.content.type) {
|
||||
TemplateMessage.Content.TEXT -> {
|
||||
val text = it.content.text?.getFirstText()
|
||||
if (!text.isNullOrEmpty()) {
|
||||
val textColor = parseColor(it.content.textColor)
|
||||
val clickSpan = createClickSpan(context, it.content, listener)
|
||||
val list = ArrayList<Any>()
|
||||
if (textColor != null) {
|
||||
list.add(ForegroundColorSpan(textColor))
|
||||
}
|
||||
if (clickSpan != null) {
|
||||
list.add(clickSpan)
|
||||
}
|
||||
builder.append(text, *list.toArray())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return builder.build()
|
||||
}
|
||||
|
||||
fun convert(textView: TextView, attachment: TemplateMessage?) {
|
||||
if (attachment == null) {
|
||||
textView.text = ""
|
||||
return
|
||||
}
|
||||
val nodeList = attachment.getNodeList()
|
||||
val textBuilder = MessageView.SpannableBuilder(textView)
|
||||
nodeList.forEach {
|
||||
if (it is TemplateNode.NormalNode) {
|
||||
val textColor = parseColor(it.textColor)
|
||||
if (textColor != null) {
|
||||
textBuilder.append(it.text, ForegroundColorSpan(textColor))
|
||||
} else {
|
||||
textBuilder.append(it.text)
|
||||
}
|
||||
} else if (it is TemplateNode.SpecialNode) {
|
||||
when (it.content.type) {
|
||||
TemplateMessage.Content.TEXT -> {
|
||||
val text = it.content.text?.getFirstText()
|
||||
if (!text.isNullOrEmpty()) {
|
||||
val textColor = parseColor(it.content.textColor)
|
||||
val clickSpan = createClickSpan(textView.context, it.content, listener)
|
||||
val list = ArrayList<Any>()
|
||||
if (textColor != null) {
|
||||
list.add(ForegroundColorSpan(textColor))
|
||||
}
|
||||
if (clickSpan != null) {
|
||||
list.add(clickSpan)
|
||||
}
|
||||
textBuilder.append(text, *list.toArray())
|
||||
}
|
||||
}
|
||||
|
||||
TemplateMessage.Content.IMAGE -> {
|
||||
val image = it.content.image
|
||||
val width = it.content.width ?: 0
|
||||
val height = it.content.height ?: 0
|
||||
val clickSpan = createClickSpan(textView.context, it.content, listener)
|
||||
if (height > 0 && width == 0) {
|
||||
if (clickSpan != null) {
|
||||
textBuilder.append(
|
||||
image,
|
||||
UiUtils.dip2px(height.toFloat()),
|
||||
clickSpan
|
||||
)
|
||||
} else {
|
||||
textBuilder.append(image, UiUtils.dip2px(height.toFloat()))
|
||||
}
|
||||
} else if (height > 0 && width > 0) {
|
||||
if (clickSpan != null) {
|
||||
textBuilder.append(
|
||||
image,
|
||||
UiUtils.dip2px(width.toFloat()),
|
||||
UiUtils.dip2px(height.toFloat()), clickSpan
|
||||
)
|
||||
} else {
|
||||
textBuilder.append(
|
||||
image,
|
||||
UiUtils.dip2px(width.toFloat()),
|
||||
UiUtils.dip2px(height.toFloat())
|
||||
)
|
||||
}
|
||||
} else {
|
||||
if (clickSpan != null) {
|
||||
textBuilder.appendImg(image, clickSpan)
|
||||
} else {
|
||||
textBuilder.appendImg(image)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
textView.text = textBuilder.build()
|
||||
textView.setOnClickListener(null)
|
||||
textView.movementMethod = LinkMovementMethod()
|
||||
}
|
||||
|
||||
private fun createClickSpan(
|
||||
context: Context,
|
||||
content: TemplateMessage.Content,
|
||||
listener: Listener?
|
||||
): OriginalDrawStatusClickSpan? {
|
||||
val skipType = content.getSkipType()
|
||||
val skipUri = content.getSkipUri()
|
||||
if (skipType > 0 && !skipUri.isNullOrEmpty()) {
|
||||
return object : OriginalDrawStatusClickSpan() {
|
||||
override fun onClick(widget: View) {
|
||||
if (skipType == BannerInfo.SKIP_TYPE_ROOM_USER_CARD) {
|
||||
listener?.onShowUserCard(skipUri)
|
||||
} else {
|
||||
CommonJumpHelper.bannerJump(context, content)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
fun parseColor(color: String?): Int? {
|
||||
if (color == null) {
|
||||
return null
|
||||
}
|
||||
try {
|
||||
return Color.parseColor(color)
|
||||
} catch (e: java.lang.Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
interface Listener {
|
||||
fun onShowUserCard(uid: String)
|
||||
}
|
||||
}
|
@@ -6,8 +6,6 @@ import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUS
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MESS_SUB_RENEWNOBLE;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_BOX;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_CRAZY_ZOO;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_CRAZY_ZOO_SUB_ALL_ROOM;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAIRY;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT;
|
||||
@@ -19,8 +17,6 @@ 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_BOX_ALL_ROOM_NOTIFY_BY_SVGA;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_GIFT_L5;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_DIAMOND;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY_ALL;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_VIP;
|
||||
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_VIP_USER_ALL_UPGRADE;
|
||||
import static com.yizhuan.xchat_android_library.utils.UIUtils.getActivityByContext;
|
||||
@@ -39,6 +35,7 @@ import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@@ -49,7 +46,6 @@ 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;
|
||||
|
||||
@@ -73,8 +69,7 @@ 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.RedPackageHandler;
|
||||
import com.yizhuan.erban.avroom.redpackage.open.RedPackageOpenDialog;
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageOpenDialog;
|
||||
import com.yizhuan.erban.common.LoadingFragment;
|
||||
import com.yizhuan.erban.common.NetworkErrorFragment;
|
||||
import com.yizhuan.erban.common.NoDataFragment;
|
||||
@@ -94,7 +89,10 @@ import com.yizhuan.erban.ui.setting.ResetPasswordActivity;
|
||||
import com.yizhuan.erban.ui.webview.CommonWebViewActivity;
|
||||
import com.yizhuan.erban.ui.widget.DefaultToolBar;
|
||||
import com.yizhuan.erban.ui.widget.dialog.AllPlayEffectDialog;
|
||||
import com.yizhuan.erban.ui.widget.dialog.AllServiceGiftLevelDialog;
|
||||
import com.yizhuan.erban.ui.widget.dialog.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.AllServiceVipLevelUPDialog;
|
||||
import com.yizhuan.erban.ui.widget.dialog.OpenNobleGlobalNoticeDialog;
|
||||
import com.yizhuan.erban.utils.UserUtils;
|
||||
@@ -105,11 +103,11 @@ 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.NotifyH5Attachment;
|
||||
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.RoomTemplateNotifyMsgBean;
|
||||
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;
|
||||
@@ -125,7 +123,6 @@ 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;
|
||||
@@ -133,6 +130,7 @@ 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;
|
||||
@@ -888,10 +886,6 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
return rxPermissions.request(mPerms);
|
||||
}
|
||||
|
||||
public RxPermissions getRxPermissions(){
|
||||
return rxPermissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收到全局广播信息
|
||||
*
|
||||
@@ -964,19 +958,10 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
return;
|
||||
RedPackageNotifyInfo notifyInfo = new Gson().fromJson(String.valueOf(baseProtocol.getData()), RedPackageNotifyInfo.class);
|
||||
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
RoomContext roomContext = RoomContext.Companion.get();
|
||||
RedPackageHandler redPackageHandler = null;
|
||||
if (roomContext != null) {
|
||||
redPackageHandler = roomContext.findAbility(RedPackageHandler.class.getSimpleName());
|
||||
}
|
||||
if (redPackageHandler != null) {
|
||||
redPackageHandler.onAllServiceSignaling(this, notifyInfo);
|
||||
if (roomInfo != null && roomInfo.getUid() == notifyInfo.getRoomUid() && context instanceof AVRoomActivity) {
|
||||
RedPackageOpenDialog.Companion.newInstance(notifyInfo).show(BaseActivity.this);
|
||||
} else {
|
||||
if (roomInfo != null && roomInfo.getUid() == notifyInfo.getRoomUid() && context instanceof AVRoomActivity) {
|
||||
RedPackageOpenDialog.Companion.newInstance(notifyInfo).show(BaseActivity.this);
|
||||
} else {
|
||||
RedPackageGoRoomDialog.Companion.newInstance(notifyInfo).show(this);
|
||||
}
|
||||
RedPackageGoRoomDialog.Companion.newInstance(notifyInfo).show(this);
|
||||
}
|
||||
}
|
||||
case CUSTOM_MSG_VIP:
|
||||
@@ -1001,10 +986,17 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
if (data == null || data.getGiftUrl() == null) return;
|
||||
giftList.add(data);
|
||||
if (second2 == CUSTOM_MSG_ALL_SERVICE_GIFT) {
|
||||
if (isShowingPlayNotify()) {
|
||||
return;
|
||||
if (giftDialog != null && giftDialog.isShowing()) {
|
||||
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
|
||||
AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst();
|
||||
if (dataBean != null) {
|
||||
return;
|
||||
} else {
|
||||
giftDialog.dismiss();
|
||||
}
|
||||
} else {
|
||||
showGiftDialog();
|
||||
}
|
||||
showGiftDialog();
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_BOX://寻爱之旅
|
||||
@@ -1108,7 +1100,7 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
if (roomLuckySeaMsgBean == null) return;
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL) {
|
||||
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
|
||||
playEffectInfo.setSecond(baseProtocol.getSecond());
|
||||
playEffectInfo.setSecond(CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL);
|
||||
playEffectInfo.setRoomLuckySeaMsgBean(roomLuckySeaMsgBean);
|
||||
playEffectList.add(playEffectInfo);
|
||||
if (playEffectDialog != null && playEffectDialog.isShowing()) {
|
||||
@@ -1124,64 +1116,6 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_CRAZY_ZOO://疯狂动物园
|
||||
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
|
||||
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|
||||
|| this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|
||||
|| UserUtils.getUserInfo() == null)
|
||||
return;
|
||||
if (playEffectList == null) {
|
||||
playEffectList = new LinkedList<>();
|
||||
}
|
||||
RoomLuckySeaMsgBean roomLuckySeaMsgBean2 = JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomLuckySeaMsgBean.class);
|
||||
if (roomLuckySeaMsgBean2 == null) return;
|
||||
if (baseProtocol.getSecond() == CUSTOM_MSG_CRAZY_ZOO_SUB_ALL_ROOM) {
|
||||
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
|
||||
playEffectInfo.setSecond(baseProtocol.getSecond());
|
||||
playEffectInfo.setRoomLuckySeaMsgBean(roomLuckySeaMsgBean2);
|
||||
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_TEMPLATE_NOTIFY://通用飘屏
|
||||
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() == CUSTOM_MSG_TEMPLATE_NOTIFY_ALL) {
|
||||
RoomTemplateNotifyMsgBean templateNotifyMsgBean = new Gson().fromJson(String.valueOf(baseProtocol.getData()), RoomTemplateNotifyMsgBean.class);
|
||||
if (templateNotifyMsgBean == null) return;
|
||||
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
|
||||
playEffectInfo.setSecond(baseProtocol.getSecond());
|
||||
playEffectInfo.setTemplateNotifyMsgBean(templateNotifyMsgBean);
|
||||
playEffectList.add(playEffectInfo);
|
||||
if (playEffectDialog != null && playEffectDialog.isShowing()) {
|
||||
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
|
||||
PlayEffectInfo dataBean = playEffectList.peekFirst();
|
||||
if (dataBean != null) {
|
||||
return;
|
||||
} else {
|
||||
playEffectDialog.dismiss();
|
||||
}
|
||||
} else {
|
||||
showPlayEffectDialog();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_LUCKY_GIFT://福袋
|
||||
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
|
||||
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|
||||
@@ -1247,11 +1181,8 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
|
||||
private void showPlayEffectDialog() {
|
||||
if (playEffectList.size() == 0) return;
|
||||
PlayEffectInfo info = playEffectList.peekFirst();
|
||||
if (info == null) return;
|
||||
playEffectDialog = new AllPlayEffectDialog(this, info, isShowingGiftNotify());
|
||||
playEffectDialog = new AllPlayEffectDialog(this, playEffectList.peekFirst());
|
||||
playEffectDialog.setOnDismissListener(dialog -> {
|
||||
tryShowGiftDialog();
|
||||
playEffectList.pollFirst();
|
||||
PlayEffectInfo dataBean = playEffectList.peekFirst();
|
||||
if (dataBean != null) {
|
||||
@@ -1269,24 +1200,10 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
}
|
||||
}
|
||||
|
||||
private void tryShowGiftDialog() {
|
||||
showGiftDialog();
|
||||
}
|
||||
|
||||
private void showGiftDialog() {
|
||||
if (giftList == null) return;
|
||||
if (giftList.size() == 0) return;
|
||||
AllServiceGiftProtocol.DataBean data = giftList.peekFirst();
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
if (giftDialog != null && giftDialog.isShowing()) {
|
||||
return;
|
||||
}
|
||||
if (!data.isHomeShow()) {
|
||||
return;
|
||||
}
|
||||
giftDialog = generateAllServiceGiftDialog(this, data);
|
||||
if (giftList.peekFirst() != null && !giftList.peekFirst().isHomeShow()) return;
|
||||
giftDialog = generateAllServiceGiftDialog(this, giftList.peekFirst());
|
||||
giftDialog.setOnDismissListener(dialog -> {
|
||||
giftList.pollFirst();
|
||||
AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst();
|
||||
@@ -1305,22 +1222,19 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isShowingGiftNotify() {
|
||||
if (giftDialog != null && giftDialog.isShowing()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
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);
|
||||
|
||||
private boolean isShowingPlayNotify() {
|
||||
if (playEffectDialog != null && playEffectDialog.isShowing()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case AllServiceGiftDialog.ALL_SERVICE_GIFT_LEVEL_2:
|
||||
|
||||
private AllServiceGiftLevelDialog generateAllServiceGiftDialog(@NonNull Context context, @NonNull AllServiceGiftProtocol.DataBean dataBean) {
|
||||
return new AllServiceGiftLevelDialog(context, dataBean);
|
||||
return new AllServiceGiftLevelTwoDialog(context, dataBean);
|
||||
|
||||
case AllServiceGiftDialog.ALL_SERVICE_GIFT_LEVEL_3:
|
||||
return new AllServiceGiftLevelThreeDialog(context, dataBean);
|
||||
}
|
||||
}
|
||||
|
||||
public void onGrabApprenticesEvent(GrabApprenticesEvent event) {
|
||||
@@ -1503,15 +1417,14 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
JSONObject jsonObject;
|
||||
try {
|
||||
jsonObject = JSON.parseObject(contentStr);
|
||||
if (jsonObject == null) return;
|
||||
if (jsonObject.containsKey("body")) {
|
||||
String body = jsonObject.getString("body");
|
||||
if (TextUtils.isEmpty(body)) return;
|
||||
baseMvpActivity.onReceivedNimBroadcastMessage(body);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
jsonObject = null;
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (jsonObject == null) return;
|
||||
if (jsonObject.containsKey("body")) {
|
||||
String body = jsonObject.getString("body");
|
||||
if (TextUtils.isEmpty(body)) return;
|
||||
baseMvpActivity.onReceivedNimBroadcastMessage(body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -14,10 +14,9 @@ import java.lang.reflect.ParameterizedType
|
||||
|
||||
abstract class BaseDialog<T : ViewBinding> : RxDialogFragment() {
|
||||
|
||||
val isViewLoaded: Boolean get() = _binding != null
|
||||
protected var _binding: T? = 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
|
||||
@@ -71,7 +70,6 @@ abstract class BaseDialog<T : ViewBinding> : RxDialogFragment() {
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
this.onDismissListener = null
|
||||
}
|
||||
|
||||
abstract fun init()
|
||||
|
@@ -2,24 +2,33 @@ package com.yizhuan.erban.common.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Outline;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap.Config;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.view.ViewOutlineProvider;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.google.android.material.imageview.ShapeableImageView;
|
||||
import com.google.android.material.shape.CornerFamily;
|
||||
import com.google.android.material.shape.ShapeAppearanceModel;
|
||||
import com.yizhuan.erban.R;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
|
||||
/**
|
||||
* 自定义View,实现圆角,圆形等效果
|
||||
*
|
||||
* @author zhy
|
||||
*/
|
||||
public class RectRoundImageView extends ShapeableImageView {
|
||||
public class RectRoundImageView extends ImageView {
|
||||
|
||||
/**
|
||||
* TYPE_CIRCLE / TYPE_ROUND
|
||||
@@ -28,11 +37,42 @@ public class RectRoundImageView extends ShapeableImageView {
|
||||
public static final int TYPE_CIRCLE = 0;
|
||||
public static final int TYPE_ROUND = 1;
|
||||
|
||||
/**
|
||||
* 图片
|
||||
*/
|
||||
private Bitmap mSrc;
|
||||
|
||||
/**
|
||||
* 圆角的大小
|
||||
*/
|
||||
private int mRadius = 8;
|
||||
|
||||
/**
|
||||
* 控件的宽度
|
||||
*/
|
||||
private int mWidth;
|
||||
/**
|
||||
* 控件的高度
|
||||
*/
|
||||
private int mHeight;
|
||||
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getmRadius() {
|
||||
return mRadius;
|
||||
}
|
||||
|
||||
public void setmRadius(int mRadius) {
|
||||
this.mRadius = mRadius;
|
||||
}
|
||||
|
||||
public RectRoundImageView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
@@ -58,6 +98,17 @@ public class RectRoundImageView extends ShapeableImageView {
|
||||
for (int i = 0; i < n; i++) {
|
||||
int attr = a.getIndex(i);
|
||||
switch (attr) {
|
||||
case R.styleable.RectRoundImageView_src:
|
||||
// mSrc = BitmapFactory.decodeResource(getResources(),
|
||||
// a.getResourceId(attr, 0));
|
||||
InputStream is = getResources().openRawResource(a.getResourceId(attr, 0));
|
||||
BitmapFactory.Options opts = new BitmapFactory.Options();
|
||||
opts.inTempStorage = new byte[100 * 1024];
|
||||
opts.inPreferredConfig = Config.RGB_565;
|
||||
opts.inPurgeable = true;
|
||||
opts.inSampleSize = 4;
|
||||
mSrc = BitmapFactory.decodeStream(is, null, opts);
|
||||
break;
|
||||
case R.styleable.RectRoundImageView_type:
|
||||
type = a.getInt(attr, 0);// 默认为Circle
|
||||
break;
|
||||
@@ -70,25 +121,197 @@ public class RectRoundImageView extends ShapeableImageView {
|
||||
}
|
||||
setScaleType(ScaleType.CENTER_CROP);
|
||||
a.recycle();
|
||||
setup(type, mRadius);
|
||||
}
|
||||
|
||||
private void setup(int type, int cornerSize) {
|
||||
if (type == TYPE_CIRCLE) {
|
||||
setOutlineProvider(new ViewOutlineProvider() {
|
||||
@Override
|
||||
public void getOutline(View view, Outline outline) {
|
||||
int min = Math.min(view.getWidth(), view.getHeight());
|
||||
int left = (view.getWidth() - min) / 2;
|
||||
int top = (view.getHeight() - min) / 2;
|
||||
outline.setOval(left, top, min, min);
|
||||
}
|
||||
});
|
||||
setClipToOutline(true);
|
||||
} else if (type == TYPE_ROUND) {
|
||||
setShapeAppearanceModel(ShapeAppearanceModel.builder()
|
||||
.setAllCorners(CornerFamily.ROUNDED, cornerSize)
|
||||
.build());
|
||||
|
||||
/**
|
||||
* 计算控件的高度和宽度
|
||||
*/
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
Drawable drawable = getDrawable();
|
||||
if (null != drawable) {
|
||||
mSrc = drawableToBitmap(getDrawable());
|
||||
}
|
||||
/**
|
||||
* 设置宽度
|
||||
*/
|
||||
int specMode = MeasureSpec.getMode(widthMeasureSpec);
|
||||
int specSize = MeasureSpec.getSize(widthMeasureSpec);
|
||||
|
||||
if (specMode == MeasureSpec.EXACTLY)// match_parent , accurate
|
||||
{
|
||||
mWidth = specSize;
|
||||
} else {
|
||||
// 由图片决定的宽
|
||||
int desireByImg = getPaddingLeft() + getPaddingRight()
|
||||
+ mSrc.getWidth();
|
||||
if (specMode == MeasureSpec.AT_MOST)// wrap_content
|
||||
{
|
||||
mWidth = Math.min(desireByImg, specSize);
|
||||
} else
|
||||
mWidth = desireByImg;
|
||||
}
|
||||
|
||||
/***
|
||||
* 设置高度
|
||||
*/
|
||||
|
||||
specMode = MeasureSpec.getMode(heightMeasureSpec);
|
||||
specSize = MeasureSpec.getSize(heightMeasureSpec);
|
||||
if (specMode == MeasureSpec.EXACTLY)// match_parent , accurate
|
||||
{
|
||||
mHeight = specSize;
|
||||
} else {
|
||||
int desire = getPaddingTop() + getPaddingBottom()
|
||||
+ mSrc.getHeight();
|
||||
|
||||
if (specMode == MeasureSpec.AT_MOST)// wrap_content
|
||||
{
|
||||
mHeight = Math.min(desire, specSize);
|
||||
} else
|
||||
mHeight = desire;
|
||||
}
|
||||
|
||||
setMeasuredDimension(mWidth, mHeight);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制
|
||||
*/
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
|
||||
switch (type) {
|
||||
// 如果是TYPE_CIRCLE绘制圆形
|
||||
case TYPE_CIRCLE:
|
||||
int min = Math.min(mWidth, mHeight);
|
||||
/**
|
||||
* 长度如果不一致,按小的值进行压缩
|
||||
*/
|
||||
if (null != mSrc) {
|
||||
mSrc = Bitmap.createScaledBitmap(mSrc, min, min, false);
|
||||
canvas.drawBitmap(createCircleImage(mSrc, min), 0, 0, null);
|
||||
}
|
||||
break;
|
||||
case TYPE_ROUND:
|
||||
canvas.drawBitmap(createFramedPhoto(mWidth, mHeight, mSrc, mRadius), 0, 0, null);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Drawable → Bitmap
|
||||
*
|
||||
* @param drawable
|
||||
* @return
|
||||
*/
|
||||
|
||||
public static Bitmap drawableToBitmap(Drawable drawable) {
|
||||
|
||||
|
||||
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
|
||||
|
||||
drawable.getIntrinsicHeight(),
|
||||
|
||||
drawable.getOpacity() != PixelFormat.OPAQUE ? Config.ARGB_8888
|
||||
|
||||
: Config.RGB_565);
|
||||
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
|
||||
//canvas.setBitmap(bitmap);
|
||||
|
||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
||||
|
||||
drawable.draw(canvas);
|
||||
|
||||
return bitmap;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据原图和变长绘制圆形图片
|
||||
*
|
||||
* @param source
|
||||
* @param min
|
||||
* @return
|
||||
*/
|
||||
private Bitmap createCircleImage(Bitmap source, int min) {
|
||||
final Paint paint = new Paint();
|
||||
paint.setAntiAlias(true);
|
||||
Bitmap target = Bitmap.createBitmap(min, min, Config.RGB_565);
|
||||
/**
|
||||
* 产生一个同样大小的画布
|
||||
*/
|
||||
Canvas canvas = new Canvas(target);
|
||||
/**
|
||||
* 首先绘制圆形
|
||||
*/
|
||||
canvas.drawCircle(min / 2, min / 2, min / 2, paint);
|
||||
/**
|
||||
* 使用SRC_IN,参考上面的说明
|
||||
*/
|
||||
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||
/**
|
||||
* 绘制图片
|
||||
*/
|
||||
canvas.drawBitmap(source, 0, 0, paint);
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据原图添加圆角
|
||||
*
|
||||
* @param source
|
||||
* @return
|
||||
*/
|
||||
private Bitmap createRoundConerImage(Bitmap source) {
|
||||
final Paint paint = new Paint();
|
||||
paint.setAntiAlias(true);
|
||||
Bitmap target = Bitmap.createBitmap(mWidth, mHeight, Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(target);
|
||||
RectF rect = new RectF(0, 0, source.getWidth(), source.getHeight());
|
||||
canvas.drawRoundRect(rect, mRadius, mRadius, paint);
|
||||
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||
canvas.drawBitmap(source, 0, 0, paint);
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x 图像的宽度
|
||||
* @param y 图像的高度
|
||||
* @param image 源图片
|
||||
* @param outerRadiusRat 圆角的大小
|
||||
* @return 圆角图片
|
||||
*/
|
||||
Bitmap createFramedPhoto(int x, int y, Bitmap image, float outerRadiusRat) {
|
||||
//根据源文件新建一个darwable对象
|
||||
Drawable imageDrawable = new BitmapDrawable(image);
|
||||
// 新建一个新的输出图片
|
||||
Bitmap output = Bitmap.createBitmap(x, y, Config.ARGB_8888);
|
||||
|
||||
Canvas canvas = new Canvas(output);
|
||||
|
||||
// 新建一个矩形
|
||||
RectF outerRect = new RectF(0, 0, x, y);
|
||||
|
||||
// 产生一个红色的圆角矩形
|
||||
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
paint.setColor(Color.RED);
|
||||
canvas.drawRoundRect(outerRect, outerRadiusRat, outerRadiusRat, paint);
|
||||
|
||||
// 将源图片绘制到这个圆角矩形上
|
||||
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||
imageDrawable.setBounds(0, 0, x, y);
|
||||
canvas.saveLayer(outerRect, paint, Canvas.ALL_SAVE_FLAG);
|
||||
imageDrawable.draw(canvas);
|
||||
canvas.restore();
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
@@ -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 SuperBottomSheetDialog implements OnClickListener {
|
||||
public class CommonPopupDialog extends BottomSheetDialog implements OnClickListener {
|
||||
private static final int BUTTON_ITEM_ID = 135798642;
|
||||
|
||||
private int mId;
|
||||
|
@@ -79,7 +79,7 @@ class FansTeamJoinActivity : BaseViewBindingActivity<ActivityFansTeamJoinBinding
|
||||
?.let { privilegeConfig ->
|
||||
binding.ivJoinLogo.load(privilegeConfig.icon)
|
||||
binding.tvJoin.text = privilegeConfig.name
|
||||
binding.bgJoin.setOnClickListener {
|
||||
binding.tvJoin.setOnClickListener {
|
||||
privilegeConfig.giftVo?.let { giftInfo ->
|
||||
GiftModel.get().sendFansTeamGift(
|
||||
giftInfo.giftId,
|
||||
|
@@ -5,7 +5,6 @@ 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.fansteam.*
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.utils.toast
|
||||
|
||||
class FansTeamViewModel : BaseViewModel() {
|
||||
@@ -38,9 +37,6 @@ class FansTeamViewModel : BaseViewModel() {
|
||||
}
|
||||
|
||||
fun loadFansTeamInitInfo() {
|
||||
if (AvRoomDataManager.get().roomUid == 0L) {
|
||||
return
|
||||
}
|
||||
safeLaunch {
|
||||
_fansTeamInitInfoLiveData.value = FansTeamModel.getFansTeamInitInfo()
|
||||
}
|
||||
|
@@ -14,8 +14,8 @@ import kotlinx.coroutines.async
|
||||
|
||||
class HomeViewModel : BaseViewModel() {
|
||||
|
||||
private val _tabHomeLiveData = MutableLiveData<ListResult<HomeRoomInfo>?>()
|
||||
val tabHomeLiveData: MutableLiveData<ListResult<HomeRoomInfo>?> = _tabHomeLiveData
|
||||
private val _tabHomeLiveData = MutableLiveData<List<HomeTabMapInfo>?>()
|
||||
val tabHomeLiveData: MutableLiveData<List<HomeTabMapInfo>?> = _tabHomeLiveData
|
||||
|
||||
private val _bannerLiveData = MutableLiveData<List<BannerInfo>?>()
|
||||
val bannerLiveData: MutableLiveData<List<BannerInfo>?> = _bannerLiveData
|
||||
@@ -47,8 +47,6 @@ class HomeViewModel : BaseViewModel() {
|
||||
private val _tagLiveData = MutableLiveData<List<HomeTagInfo>>()
|
||||
val tagLiveData: LiveData<List<HomeTagInfo>> = _tagLiveData
|
||||
|
||||
val homeTagLiveData: MutableLiveData<List<HomeTagInfo>> = MutableLiveData<List<HomeTagInfo>>()
|
||||
|
||||
private val _emptyLiveData = MutableLiveData<Boolean>()
|
||||
val emptyLiveData: LiveData<Boolean> = _emptyLiveData
|
||||
|
||||
@@ -64,14 +62,13 @@ class HomeViewModel : BaseViewModel() {
|
||||
private val _newFriendLiveData = MutableLiveData<ListResult<UserInfo>>()
|
||||
val newFriendLiveData: LiveData<ListResult<UserInfo>> = _newFriendLiveData
|
||||
|
||||
fun getHomeTabName(tabId: Int, pageNum: Int) {
|
||||
fun getHomeTabName() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_tabHomeLiveData.value = ListResult.failed(pageNum)
|
||||
_tabHomeLiveData.value = null
|
||||
},
|
||||
block = {
|
||||
val result = HomeModel.getHomeTabHome(tabId, pageNum, 20)
|
||||
_tabHomeLiveData.value = ListResult.success(result, pageNum)
|
||||
_tabHomeLiveData.value = HomeModel.getHomeTabHome()
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -125,12 +122,6 @@ class HomeViewModel : BaseViewModel() {
|
||||
)
|
||||
}
|
||||
|
||||
fun getHomeTagInfo() {
|
||||
safeLaunch {
|
||||
homeTagLiveData.value = HomeModel.getNewHomeTag()
|
||||
}
|
||||
}
|
||||
|
||||
fun getTagInfo() {
|
||||
safeLaunch {
|
||||
_tagLiveData.value = HomeModel.getHomeTag()
|
||||
|
@@ -0,0 +1,95 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@@ -87,6 +87,10 @@ class RoomNewFriendsAdapter :
|
||||
}
|
||||
}
|
||||
|
||||
helper.getView<View>(R.id.iv_avatar).setOnClickListener {
|
||||
UserInfoActivity.Companion.start(mContext, item.uid)
|
||||
}
|
||||
|
||||
val tvNickname = helper.getView<TextView>(R.id.tv_nickname)
|
||||
tvNickname.text = item.nick
|
||||
|
||||
|
@@ -17,7 +17,6 @@ import com.yizhuan.erban.home.HomeViewModel
|
||||
import com.yizhuan.erban.home.adapter.HomeChatAdapter
|
||||
import com.yizhuan.erban.home.adapter.RoomNewFriendsAdapter
|
||||
import com.yizhuan.erban.home.helper.OpenRoomHelper
|
||||
import com.yizhuan.erban.ui.user.activity.UserInfoActivity
|
||||
import com.yizhuan.erban.ui.utils.RVDelegate
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeRoomInfo
|
||||
import com.yizhuan.xchat_android_core.home.event.RefreshHomeDataEvent
|
||||
@@ -117,11 +116,6 @@ class AccompanyFragment : BaseViewBindingFragment<FragmentAccompanyBinding>() {
|
||||
|
||||
private fun initHotRoomTab() {
|
||||
roomNewFriendsAdapter = RoomNewFriendsAdapter()
|
||||
roomNewFriendsAdapter.setOnItemClickListener { adapter, view, position ->
|
||||
(adapter.getItem(position) as? UserInfo)?.let {
|
||||
UserInfoActivity.Companion.start(context, it.uid)
|
||||
}
|
||||
}
|
||||
rvDelegate = RVDelegate.Builder<UserInfo>()
|
||||
.setAdapter(roomNewFriendsAdapter)
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
|
@@ -40,22 +40,20 @@ import com.zhpan.bannerview.BannerViewPager
|
||||
class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClickListener,
|
||||
MainIndicatorAdapter.OnItemSelectListener {
|
||||
|
||||
private val TAB_ID_RECOMMEND = Int.MAX_VALUE - 1
|
||||
|
||||
private val TAB_ID_ACCOMPANY = Int.MAX_VALUE - 2
|
||||
|
||||
private val tabList = mutableListOf<HomeTagInfo>()
|
||||
private val tabTitleList = mutableListOf<String>()
|
||||
private val mFragments = mutableListOf<Class<out Fragment>>()
|
||||
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)
|
||||
initTab()
|
||||
initTitleTab()
|
||||
initListener()
|
||||
homeViewModel.homeTagLiveData.observe(this) {
|
||||
loadTabList(transformTabList(it))
|
||||
}
|
||||
homeViewModel.bannerLiveData.observe(this) {
|
||||
it?.let {
|
||||
if (ListUtils.isListEmpty(it)) {
|
||||
@@ -73,10 +71,7 @@ class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClic
|
||||
ReportManager.get().reportEvent(
|
||||
IReportConstants.MODULE_HOMEPAGE_CLICK, mapOf(
|
||||
Pair(IReportConstants.HOMEPAGE_TYPE, IReportConstants.SIX),
|
||||
Pair(
|
||||
IReportConstants.MODULE,
|
||||
IReportConstants.PEKO_HOMEPAGE
|
||||
)
|
||||
Pair(IReportConstants.MODULE, IReportConstants.PEKO_HOMEPAGE)
|
||||
)
|
||||
)
|
||||
CommonJumpHelper.bannerJump(context, it[position])
|
||||
@@ -88,7 +83,7 @@ class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClic
|
||||
}
|
||||
homeViewModel.currentResourceLiveData.observe(this) {
|
||||
it?.let {
|
||||
if (it.size != 2) {
|
||||
if(it.size != 2){
|
||||
binding.csResource.visibility = View.GONE
|
||||
return@observe
|
||||
}
|
||||
@@ -104,12 +99,10 @@ class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClic
|
||||
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)
|
||||
@@ -138,7 +131,6 @@ class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClic
|
||||
}
|
||||
}
|
||||
}
|
||||
homeViewModel.getHomeTagInfo()
|
||||
homeViewModel.getBannerInfo()
|
||||
homeViewModel.getCurrentResourceInfo()
|
||||
}
|
||||
@@ -165,7 +157,6 @@ class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClic
|
||||
DemoCache.saveAnchorCardView(1)
|
||||
}
|
||||
}
|
||||
|
||||
R.id.iv_ranking -> {
|
||||
//首页_排行榜
|
||||
ReportManager.get().reportEvent(
|
||||
@@ -176,7 +167,6 @@ class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClic
|
||||
)
|
||||
CommonWebViewActivity.start(mContext, UriProvider.getRanking())
|
||||
}
|
||||
|
||||
R.id.iv_my_room -> {
|
||||
//首页_创建房间
|
||||
ReportManager.get().reportEvent(
|
||||
@@ -190,100 +180,63 @@ class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClic
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化推荐
|
||||
*/
|
||||
private fun initTitleTab() {
|
||||
mTabInfoList.add(
|
||||
HomeTagInfo(
|
||||
6,
|
||||
ResUtil.getString(R.string.home_fragment_homefragment_04),
|
||||
0
|
||||
)
|
||||
)
|
||||
mTabInfoList.add(
|
||||
HomeTagInfo(
|
||||
7,
|
||||
ResUtil.getString(R.string.home_fragment_homefragment_07),
|
||||
0
|
||||
)
|
||||
)
|
||||
mFragments.add(RecommendFragment::class.java)
|
||||
mFragments.add(AccompanyFragment::class.java)
|
||||
|
||||
val commonNavigator = CommonNavigator(context)
|
||||
commonNavigator.setTitleWrapContent(false)
|
||||
commonNavigator.titleMargin = ScreenUtil.dip2px(2.0F)
|
||||
commonNavigator.setTitleGravity(Gravity.CENTER_VERTICAL)
|
||||
val magicIndicatorAdapter = MainIndicatorAdapter(context, mTabInfoList.map { it.name })
|
||||
magicIndicatorAdapter.setOnItemSelectListener(this)
|
||||
commonNavigator.adapter = magicIndicatorAdapter
|
||||
binding.magicIndicator.navigator = commonNavigator
|
||||
binding.viewPager.adapter =
|
||||
object : FragmentStateAdapter(childFragmentManager, lifecycle) {
|
||||
override fun createFragment(position: Int): Fragment {
|
||||
return mFragments[position].newInstance()
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return mFragments.size
|
||||
}
|
||||
|
||||
}
|
||||
ViewPagerHelper.bind(binding.magicIndicator, binding.viewPager)
|
||||
binding.viewPager.offscreenPageLimit = 1
|
||||
}
|
||||
|
||||
override fun onItemSelect(position: Int, view: TextView?) {
|
||||
binding.viewPager.currentItem = position
|
||||
//点击顶部tab上报
|
||||
val map = HashMap<String, Any>(3)
|
||||
map[IReportConstants.HOMEPAGE_TAB] = tabList[position].id
|
||||
map[IReportConstants.HOMEPAGE_TAB] = mTabInfoList[position].id
|
||||
map[IReportConstants.MODULE] = IReportConstants.PEKO_HOMEPAGE
|
||||
ReportManager.get().reportEvent(IReportConstants.TAB_HOMEPAGE_CLICK, map)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
tabList.clear()
|
||||
tabTitleList.clear()
|
||||
mTabInfoList.clear()
|
||||
mFragments.clear()
|
||||
}
|
||||
|
||||
private fun initTab() {
|
||||
val commonNavigator = CommonNavigator(context)
|
||||
commonNavigator.setTitleWrapContent(false)
|
||||
commonNavigator.titleMargin = ScreenUtil.dip2px(2.0F)
|
||||
commonNavigator.setTitleGravity(Gravity.CENTER_VERTICAL)
|
||||
val magicIndicatorAdapter = MainIndicatorAdapter(context, tabTitleList)
|
||||
magicIndicatorAdapter.setOnItemSelectListener(this)
|
||||
commonNavigator.adapter = magicIndicatorAdapter
|
||||
binding.magicIndicator.navigator = commonNavigator
|
||||
binding.viewPager.adapter =
|
||||
object : FragmentStateAdapter(childFragmentManager, lifecycle) {
|
||||
override fun getItemId(position: Int): Long {
|
||||
return tabList[position].id.toLong()
|
||||
}
|
||||
|
||||
override fun containsItem(itemId: Long): Boolean {
|
||||
return tabList.firstOrNull { it.id.toLong() == itemId } != null
|
||||
}
|
||||
|
||||
override fun createFragment(position: Int): Fragment {
|
||||
val itemId = getItemId(position)
|
||||
return when (itemId) {
|
||||
TAB_ID_RECOMMEND.toLong() -> {
|
||||
RecommendFragment()
|
||||
}
|
||||
|
||||
TAB_ID_ACCOMPANY.toLong() -> {
|
||||
AccompanyFragment()
|
||||
}
|
||||
|
||||
else -> {
|
||||
HomeTabFragment.newInstance(itemId.toInt())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return tabList.size
|
||||
}
|
||||
}
|
||||
ViewPagerHelper.bind(binding.magicIndicator, binding.viewPager)
|
||||
loadTabList(transformTabList(emptyList()))
|
||||
}
|
||||
|
||||
private fun transformTabList(list: List<HomeTagInfo>): List<HomeTagInfo> {
|
||||
val finalList = ArrayList<HomeTagInfo>()
|
||||
finalList.add(
|
||||
HomeTagInfo(
|
||||
TAB_ID_RECOMMEND,
|
||||
ResUtil.getString(R.string.home_fragment_homefragment_04),
|
||||
0
|
||||
)
|
||||
)
|
||||
finalList.addAll(list)
|
||||
finalList.add(
|
||||
HomeTagInfo(
|
||||
TAB_ID_ACCOMPANY,
|
||||
ResUtil.getString(R.string.home_fragment_homefragment_07),
|
||||
0
|
||||
)
|
||||
)
|
||||
return finalList
|
||||
}
|
||||
|
||||
private fun loadTabList(list: List<HomeTagInfo>) {
|
||||
// 预防脏数据导致fragment复用问题
|
||||
val newList = list.distinctBy {
|
||||
it.id
|
||||
}
|
||||
val currentListId = tabList.joinToString { it.id.toString() }
|
||||
val newListId = newList.joinToString { it.id.toString() }
|
||||
if (currentListId == newListId) {
|
||||
return
|
||||
}
|
||||
tabList.clear()
|
||||
tabList.addAll(newList)
|
||||
tabTitleList.clear()
|
||||
tabTitleList.addAll(tabList.map { it.name })
|
||||
binding.magicIndicator.navigator.notifyDataSetChanged()
|
||||
binding.viewPager.adapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
@@ -1,141 +0,0 @@
|
||||
package com.yizhuan.erban.home.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
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.common.EmptyViewHelper
|
||||
import com.yizhuan.erban.databinding.FragmentRecommendBinding
|
||||
import com.yizhuan.erban.home.HomeViewModel
|
||||
import com.yizhuan.erban.home.adapter.HomeHotAdapter
|
||||
import com.yizhuan.erban.ui.utils.RVDelegate
|
||||
import com.yizhuan.xchat_android_core.home.bean.HomeRoomInfo
|
||||
import com.yizhuan.xchat_android_core.home.event.RefreshHomeDataEvent
|
||||
import com.yizhuan.xchat_android_core.room.event.RoomShieldEvent
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
/**
|
||||
* Peko首页
|
||||
*/
|
||||
class HomeTabFragment : BaseViewBindingFragment<FragmentRecommendBinding>() {
|
||||
|
||||
private lateinit var roomHotAdapter: HomeHotAdapter
|
||||
|
||||
private lateinit var rvDelegate: RVDelegate<HomeRoomInfo>
|
||||
|
||||
private val homeViewModel: HomeViewModel by viewModels()
|
||||
|
||||
//是否需要刷新接口进行屏蔽房间操作
|
||||
private var isShield = false
|
||||
|
||||
private var pageNum = 1
|
||||
private var tabId: Int? = null
|
||||
companion object {
|
||||
fun newInstance(tabId: Int): HomeTabFragment {
|
||||
return HomeTabFragment().apply {
|
||||
arguments = Bundle().apply {
|
||||
putInt("tabId", tabId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
override fun init() {
|
||||
tabId = arguments?.getInt("tabId")
|
||||
initRefreshView()
|
||||
initHotRoomTab()
|
||||
}
|
||||
|
||||
private fun initRefreshView() {
|
||||
binding.refreshLayout.setOnRefreshListener {
|
||||
loadData(true)
|
||||
}
|
||||
binding.refreshLayout.isEnableLoadmore = false
|
||||
binding.refreshLayout.isEnableOverScrollBounce = false
|
||||
}
|
||||
|
||||
private fun initHotRoomTab() {
|
||||
roomHotAdapter = HomeHotAdapter()
|
||||
roomHotAdapter.onItemClickListener =
|
||||
BaseQuickAdapter.OnItemClickListener { _: BaseQuickAdapter<*, *>?, _: View?, position: Int ->
|
||||
val homePlayInfo: HomeRoomInfo? = roomHotAdapter.getItem(position)
|
||||
if (homePlayInfo != null) {
|
||||
//首页_房间派对
|
||||
ReportManager.get().reportEvent(
|
||||
IReportConstants.MODULE_HOMEPAGE_CLICK, mapOf(
|
||||
Pair(IReportConstants.HOMEPAGE_TYPE, IReportConstants.TEN),
|
||||
Pair(IReportConstants.MODULE, IReportConstants.PEKO_HOMEPAGE)
|
||||
)
|
||||
)
|
||||
AVRoomActivity.start(mContext, homePlayInfo.uid)
|
||||
}
|
||||
}
|
||||
rvDelegate = RVDelegate.Builder<HomeRoomInfo>()
|
||||
.setPageSize(20)
|
||||
.setAdapter(roomHotAdapter)
|
||||
.setRecyclerView(binding.mRecyclerRoom)
|
||||
.setEmptyView(EmptyViewHelper.createEmptyTextViewHeight(context, "暂无數據"))
|
||||
.setLayoutManager(GridLayoutManager(mContext, 2))
|
||||
.build()
|
||||
|
||||
roomHotAdapter.setOnLoadMoreListener({
|
||||
loadData(false)
|
||||
}, binding.mRecyclerRoom)
|
||||
|
||||
homeViewModel.tabHomeLiveData.observe(this) {
|
||||
binding.refreshLayout.finishRefresh()
|
||||
rvDelegate.loadData(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onLazyLoad() {
|
||||
super.onLazyLoad()
|
||||
loadData(true)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (isShield) {
|
||||
loadData(true)
|
||||
isShield = false
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadData(isRefresh: Boolean) {
|
||||
if (isRefresh) {
|
||||
pageNum = 1
|
||||
} else {
|
||||
pageNum++
|
||||
}
|
||||
homeViewModel.getHomeTabName(tabId ?: 0, pageNum)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onRefreshHomeDataEvent(event: RefreshHomeDataEvent?) {
|
||||
if (isResumed) {
|
||||
loadData(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onRoomShieldEvent(event: RoomShieldEvent?) {
|
||||
isShield = true
|
||||
}
|
||||
|
||||
}
|
@@ -8,8 +8,6 @@ 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
|
||||
@@ -20,6 +18,7 @@ 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 {
|
||||
|
||||
@@ -43,7 +42,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(findViewById(R.id.recyclerView))
|
||||
.setRecyclerView(recyclerView)
|
||||
.setAdapter(adapter)
|
||||
.build()
|
||||
adapter.setOnItemClickListener { _, _, position ->
|
||||
@@ -54,8 +53,8 @@ class GiveGoldSearchActivity : BaseActivity(), TextWatcher {
|
||||
})
|
||||
finish()
|
||||
}
|
||||
findViewById<EditText>(R.id.editSearch).addTextChangedListener(this)
|
||||
findViewById<TextView>(R.id.tvCancel).setOnClickListener { finish() }
|
||||
editSearch.addTextChangedListener(this)
|
||||
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))
|
||||
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() }
|
||||
tvNickname.text = "轉贈給:${intent.getStringExtra("nickname")}"
|
||||
tvGold.text = "${intent.getStringExtra("gold")?.toInt()}鉆石"
|
||||
tvSure.setOnClickListener { finish() }
|
||||
}
|
||||
|
||||
|
||||
|
@@ -10,7 +10,6 @@ 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
|
||||
@@ -40,6 +39,7 @@ 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, findViewById<EditText>(R.id.mEditGold).text.toString(), DESAndBase64(password))
|
||||
PayModel.get().giveGold(uid, mEditGold.text.toString(), DESAndBase64(password))
|
||||
.compose(bindToLifecycle())
|
||||
.doOnError {
|
||||
toast(it.message)
|
||||
|
@@ -120,7 +120,7 @@ public class NimTeamMessageFragment extends MessageFragment {
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
@SuppressLint("CheckResult")
|
||||
public void onNimAudioChatEvent(NimAudioChatEvent event) {
|
||||
checkPermission(Manifest.permission.RECORD_AUDIO)
|
||||
checkPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, 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.CAMERA)
|
||||
checkPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA)
|
||||
.subscribe(result -> {
|
||||
if (result) {
|
||||
event.getSuccess().accept(result);
|
||||
|
@@ -10,19 +10,7 @@ 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.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.treasurefairy.*
|
||||
import com.yizhuan.xchat_android_core.utils.net.ServerException
|
||||
import com.yizhuan.xchat_android_core.utils.toast
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
@@ -66,8 +54,7 @@ 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
|
||||
@@ -75,26 +62,17 @@ 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
|
||||
@@ -107,9 +85,6 @@ class FairyViewModel : BaseViewModel() {
|
||||
val exchangeDebrisRecordLiveData: LiveData<ListResult<ExchangeGiftInfo>> =
|
||||
_exchangeDebrisRecordLiveData
|
||||
|
||||
private val _buyDebrisLiveData = MutableLiveData<Event<Int>>()
|
||||
val buyDebrisLiveData: LiveData<Event<Int>> = _buyDebrisLiveData
|
||||
|
||||
init {
|
||||
initPrizeInfoList()
|
||||
}
|
||||
@@ -222,21 +197,6 @@ 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 = {
|
||||
@@ -298,21 +258,20 @@ 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?.highElves?.forEach {
|
||||
myFairyInfo?.middleElves?.forEach {
|
||||
it.selectedNum = 0
|
||||
}
|
||||
_myFairyInfoLiveData.value = myFairyInfo
|
||||
}
|
||||
|
||||
fun addTestFairy(fairyInfo: FairyInfo, size: Int) {
|
||||
fun addTestFairy(fairyInfo: FairyInfo) {
|
||||
val array = _compoundFairyInfosLiveData.value ?: SparseArray()
|
||||
|
||||
if (array.size() >= size) {
|
||||
if (array.size() >= 3) {
|
||||
"試煉爐已滿!".toast()
|
||||
} else {
|
||||
if (fairyInfo.elfNum == 0) {
|
||||
@@ -354,9 +313,9 @@ class FairyViewModel : BaseViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
fun oneKeyAdd(fairyInfos: List<FairyInfo>, size: Int) {
|
||||
fun oneKeyAdd(fairyInfos: List<FairyInfo>) {
|
||||
val compoundFairyInfos = _compoundFairyInfosLiveData.value ?: SparseArray()
|
||||
var needNum = size - compoundFairyInfos.size()
|
||||
var needNum = 3 - compoundFairyInfos.size()
|
||||
if (needNum == 0) {
|
||||
"試煉爐已滿!".toast()
|
||||
return
|
||||
@@ -368,7 +327,7 @@ class FairyViewModel : BaseViewModel() {
|
||||
compoundFairyInfos.put(nextIndex(compoundFairyInfos), it)
|
||||
}
|
||||
}
|
||||
if (needNum <= size && needNum != 0) {
|
||||
if (needNum <= 3 && needNum != 0) {
|
||||
"精靈數量不足".toast()
|
||||
return
|
||||
}
|
||||
@@ -383,27 +342,21 @@ class FairyViewModel : BaseViewModel() {
|
||||
fairyInfos.get(1) == null -> {
|
||||
1
|
||||
}
|
||||
fairyInfos.get(2) == null -> {
|
||||
2
|
||||
}
|
||||
fairyInfos.get(3) == null -> {
|
||||
3
|
||||
}
|
||||
else -> {
|
||||
4
|
||||
2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun testFairy(level: Int): Boolean {
|
||||
val fairyInfos = _compoundFairyInfosLiveData.value ?: SparseArray()
|
||||
if (fairyInfos.size() != 5) {
|
||||
if (fairyInfos.size() != 3) {
|
||||
"精靈數量不足".toast()
|
||||
return false
|
||||
}
|
||||
safeLaunch(
|
||||
onError = {
|
||||
if (level == MyFairyItemView.LEGEND) {
|
||||
if (level == MyFairyItemView.EPIC) {
|
||||
_testLegendResultLiveData.value = null
|
||||
} else {
|
||||
_testResultLiveData.value = null
|
||||
@@ -418,7 +371,7 @@ class FairyViewModel : BaseViewModel() {
|
||||
}
|
||||
fairyTestParam.level = level
|
||||
val result = TreasureFairyModel.testFairy(fairyTestParam)
|
||||
(if (level == MyFairyItemView.LEGEND) {
|
||||
(if (level == MyFairyItemView.EPIC) {
|
||||
_testLegendResultLiveData
|
||||
} else {
|
||||
_testResultLiveData
|
||||
@@ -429,30 +382,6 @@ 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
|
||||
@@ -480,18 +409,6 @@ class FairyViewModel : BaseViewModel() {
|
||||
)
|
||||
}
|
||||
|
||||
//精灵召唤列表
|
||||
fun getFairyCallList() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_fairyCallInfoLiveData.value = null
|
||||
},
|
||||
block = {
|
||||
val result = TreasureFairyModel.getFairyCallList()
|
||||
_fairyCallInfoLiveData.value = result
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getDebrisExchangeList() {
|
||||
safeLaunch(
|
||||
@@ -518,7 +435,6 @@ class FairyViewModel : BaseViewModel() {
|
||||
val result = TreasureFairyModel.exchangeGift(itemId)
|
||||
_debrisExchangeLiveData.value = result?.let { Event(it) }
|
||||
_myFairyInfoLiveData.value = TreasureFairyModel.getMyFairyInfo()
|
||||
initDrawInfo()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -552,21 +468,4 @@ 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,26 +10,24 @@ 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.treasure_box.activity.TreasureBoxActivity
|
||||
import com.yizhuan.erban.treasurefairy.dialog.*
|
||||
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.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
|
||||
@@ -42,11 +40,7 @@ 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
|
||||
@@ -70,8 +64,6 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
|
||||
private var isCheck = false
|
||||
|
||||
private var mPrice = -1
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
@@ -104,75 +96,16 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
ScreenUtil.screenHeight - ScreenUtil.getStatusBarHeight(this)
|
||||
)
|
||||
window.setGravity(Gravity.BOTTOM)
|
||||
|
||||
binding.fairyItem0.isSelected = true
|
||||
looperHintPrize()
|
||||
|
||||
binding.viewPrice1.setOnClickListener {
|
||||
setFairyPriceSelect(1)
|
||||
binding.tvKeyNum.setOnClickListener {
|
||||
FairyDialogWebViewActivity.start(this, UriProvider.getFairyKey())
|
||||
}
|
||||
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.ivFairyStore.setOnClickListener {
|
||||
ExchangeFairyDialog.newInstance().show(context)
|
||||
binding.ivFairyTreasure.setOnClickListener {
|
||||
ForestFairyDialog.newInstance().show(this)
|
||||
}
|
||||
binding.ivOpen1.setOnClickListener {
|
||||
if (checkKeyNum(1)) {
|
||||
@@ -219,16 +152,6 @@ 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) {
|
||||
@@ -243,9 +166,6 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
?.indexOfFirst { prize ->
|
||||
it[0].itemIndex == prize.itemIndex
|
||||
} ?: -2
|
||||
if (targetIndex >= fairyItems.size) {
|
||||
targetIndex = 0
|
||||
}
|
||||
if (targetIndex == -2) {
|
||||
viewModel.initPrizeInfoList()
|
||||
}
|
||||
@@ -257,8 +177,6 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
}
|
||||
|
||||
viewModel.drawInfoLiveData.observe(this) {
|
||||
binding.ivRefresh.clearAnimation()
|
||||
|
||||
it?.let {
|
||||
drawInfo = it
|
||||
binding.tvKeyNum.text = FormatUtils.formatBigNum(it.drawTicketNum.toString())
|
||||
@@ -266,12 +184,9 @@ 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 =
|
||||
@@ -287,8 +202,7 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
0f,
|
||||
binding.ivLuckyStone.width.toFloat(),
|
||||
binding.ivLuckyStone.height *
|
||||
(1 - it.luckyNum / (it.luckyNum + it.needLuckyNum).toFloat()
|
||||
.coerceAtLeast(1f)),
|
||||
(1 - it.luckyNum / it.needLuckyNum.toFloat().coerceAtLeast(1f)),
|
||||
Path.Direction.CW
|
||||
)
|
||||
drawable.setSrcPath(path)
|
||||
@@ -299,83 +213,21 @@ 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
|
||||
}
|
||||
FairyBuyDebrisModifyQuantityDialog.newInstance(num).show(this)
|
||||
DialogManager(context).showOkCancelDialog("購買限時裝扮活動奪寶券", "去參与", "取消") {
|
||||
FairyDialogWebViewActivity.start(context, UriProvider.getFairyKey())
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -401,7 +253,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()
|
||||
@@ -468,10 +320,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(
|
||||
@@ -512,7 +364,6 @@ 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,
|
||||
@@ -532,43 +383,6 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
IMNetEaseManager.get()
|
||||
.noticeRoomEvent(message, RoomEvent.LUCKY_SEA_GIFT_SERVER_NOTIFY)
|
||||
}
|
||||
|
||||
CustomAttachment.CUSTOM_MSG_CRAZY_ZOO -> if (baseProtocol.second == CustomAttachment.CUSTOM_MSG_CRAZY_ZOO_SUB_ALL_ROOM) {
|
||||
val attachment = RoomLuckySeaAttachment(
|
||||
CustomAttachment.CUSTOM_MSG_CRAZY_ZOO,
|
||||
CustomAttachment.CUSTOM_MSG_CRAZY_ZOO_SUB_ALL_ROOM
|
||||
)
|
||||
attachment.setRoomLuckySeaMsgBean(
|
||||
JSON.parseObject(
|
||||
baseProtocol.data.toString(),
|
||||
RoomLuckySeaMsgBean::class.java
|
||||
)
|
||||
)
|
||||
val message = ChatRoomMessageBuilder.createChatRoomCustomMessage(
|
||||
AvRoomDataManager.get().roomId.toString(),
|
||||
attachment
|
||||
)
|
||||
IMNetEaseManager.get()
|
||||
.noticeRoomEvent(message, RoomEvent.CRAZY_ZOO_ALL_ROOM_NOTIFY)
|
||||
}
|
||||
|
||||
CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY -> if (baseProtocol.second == CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY_ALL) {
|
||||
val attachment = RoomTemplateNotifyAttachment(
|
||||
CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY,
|
||||
CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY_ALL
|
||||
)
|
||||
attachment.msgBean = JSON.parseObject(
|
||||
baseProtocol.data.toString(),
|
||||
RoomTemplateNotifyMsgBean::class.java
|
||||
)
|
||||
val message = ChatRoomMessageBuilder.createChatRoomCustomMessage(
|
||||
AvRoomDataManager.get().roomId.toString(),
|
||||
attachment
|
||||
)
|
||||
IMNetEaseManager.get()
|
||||
.noticeRoomEvent(message, RoomEvent.TEMPLATE_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)
|
||||
@@ -583,7 +397,6 @@ 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,
|
||||
@@ -599,7 +412,6 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
)
|
||||
IMNetEaseManager.get().noticeRoomEvent(message, RoomEvent.FAIRY_DRAW_GIFT_L5)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
@@ -12,8 +12,7 @@ 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_value, item.expendNum.toString())
|
||||
helper.setText(R.id.tv_need_num, "${item.expendNum}")
|
||||
helper.addOnClickListener(R.id.tv_exchange)
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,13 @@ 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)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
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)
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user