Compare commits

..

36 Commits

Author SHA1 Message Date
wushaocheng
2bba51a7ea [Modify]修改google,facebook的登录配置 2023-03-20 17:13:09 +08:00
wushaocheng
61d01b96c7 [Modify]修改google配置 2023-03-17 21:28:20 +08:00
wushaocheng
4a471bf2d1 [Modify]修改google配置 2023-03-17 19:34:23 +08:00
wushaocheng
e528a65d8c [Modify]修改google配置 2023-03-17 18:57:33 +08:00
wushaocheng
5692744044 [Modify]修改google配置 2023-03-17 18:56:00 +08:00
邱福灿
a1d2159c3a update google-service.json 2023-03-17 04:05:41 +08:00
wushaocheng
8d377f9f19 [Modify]修改google密钥 2023-03-17 02:24:10 +08:00
wushaocheng
8bc6269794 [Modify]修改项目配置和将加密模式修改为So库 2023-03-17 01:06:27 +08:00
wushaocheng
8fe566a240 [BugFix]修改firebase配置 2023-03-16 19:29:11 +08:00
wushaocheng
b9d0c289d2 [BugFix]修改网络安全配置 2023-03-16 18:12:13 +08:00
wushaocheng
dc4f4849ff [BugFix]修改网络安全配置 2023-03-16 18:02:17 +08:00
wushaocheng
792fb3b428 [BugFix]上传1.5.8版本 2023-03-16 17:32:10 +08:00
wushaocheng
f2a426fa2b [BugFix]修复压缩路径遍历和谷歌支付问题 2023-03-16 17:06:51 +08:00
wushaocheng
ead01644f3 [BugFix]修复房间显示cp匹配内容 2023-03-16 16:21:30 +08:00
wushaocheng
896b615946 [BugFix]修改ShareSDK和Facebook 2023-03-16 15:50:35 +08:00
wushaocheng
9714582690 [BugFix]修改Google地址 2023-03-16 15:48:15 +08:00
wushaocheng
6476d6a114 [BugFix]调整代码逻辑 2023-03-16 15:43:42 +08:00
wushaocheng
24665aba7f [BugFix]修复不安全的压缩路径遍历 2023-03-16 11:12:30 +08:00
wushaocheng
a4ed27e532 [Modify]修改项目配置 2023-03-15 21:01:41 +08:00
wushaocheng
cd2041be19 [Modify]修改appsflyer版本 2023-03-15 17:19:45 +08:00
wushaocheng
443041d73d [Modify]修改版本号为1.5.5 2023-03-15 17:12:27 +08:00
wushaocheng
4a56d1a59c [Modify]修改版本号为1.5.5 2023-03-15 15:26:56 +08:00
wushaocheng
449dd0f8b1 [Modify]移除游戏房提示繁体字 2023-03-15 14:53:00 +08:00
wushaocheng
2cf1c6d178 [Modify]移除游戏房 2023-03-15 11:37:25 +08:00
wushaocheng
664d67f44c [Modify]修改peko的配置 2023-03-14 17:52:18 +08:00
wushaocheng
c7665be597 [Modify]修改peko的配置 2023-03-14 17:27:31 +08:00
wushaocheng
8e7b6880c3 [Modify]移除友盟统计 2023-03-14 15:20:06 +08:00
wushaocheng
453a5a78a3 [Modify]混淆修改 2023-03-10 20:20:50 +08:00
wushaocheng
fb4d0319dd [Modify]修改项目中可能违规的地方 2023-03-10 19:07:12 +08:00
wushaocheng
b9ff574fa8 [Modify]混淆修改 2023-03-10 11:15:43 +08:00
wushaocheng
7ce2108b1e [Modify]移除动态详情页分享按钮 2023-03-09 16:45:16 +08:00
wushaocheng
696473d412 [Modify]谷歌下架原因排查 2023-03-09 16:10:26 +08:00
wushaocheng
8542e3381c [Modify]谷歌下架原因排查 2023-03-09 14:09:57 +08:00
wushaocheng
cae2b1ab2d [Modify]谷歌下架原因排查 2023-03-09 12:18:04 +08:00
wushaocheng
6b90f73031 [Modify]移除zego 2023-03-08 17:55:18 +08:00
wushaocheng
6ea2ade4ff [Modify]移除zego 2023-03-08 17:54:52 +08:00
1300 changed files with 10990 additions and 55079 deletions

View File

@@ -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()

View File

@@ -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'
@@ -20,20 +21,20 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
ndk {
//设置支持的SO库架构
if (onlyArm64) {
abiFilters "arm64-v8a"
} else {
abiFilters "armeabi-v7a", "arm64-v8a"
}
}
flavorDimensions 'default'
manifestPlaceholders = [CRASHLYTICS_COLLECTION_ENABLED: CRASHLYTICS_COLLECTION_ENABLED.toBoolean()]
}
splits {
abi {
enable true
reset()
include 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
universalApk true
}
}
bundle {
language {
enableSplit = false
@@ -47,29 +48,20 @@ android {
}
//在apk文件后边生成版本号信息
android.applicationVariants.configureEach { variant ->
variant.outputs.configureEach { output ->
def date = new Date().format("MMddHHmm", TimeZone.getTimeZone("GMT+08"))
def outputFile = output.outputFile
if (outputFile == null || !outputFile.name.endsWith('.apk')) {
return
android.applicationVariants.all {
variant ->
variant.outputs.all {
def date = new Date().format("MMddHHmm", TimeZone.getTimeZone("GMT+08"))
outputFileName = "peko_${buildType.name}_v${defaultConfig.versionName}-${date}.apk"
}
def abi = output.getFilter(com.android.build.OutputFile.ABI)
if (abi == null) {
abi = "universal"
}
outputFileName = "piko_${buildType.name}_v${defaultConfig.versionName}_${defaultConfig.versionCode}_${abi}_${date}.apk"
}
}
lint {
lintOptions {
abortOnError false
disable 'MissingTranslation', 'ExtraTranslation', 'ContentDescription', 'SmallSp'
disable 'MissingTranslation'
disable 'ExtraTranslation'
}
dataBinding {
enabled = true
}
@@ -147,23 +139,19 @@ android {
}
buildTypes {
def server_url_debug = '"http://beta.api.pekolive.com/"'
def server_url_release = '"https://api.pekolive.com/"'
debug {
println("minifyEnabled = " + minify_enabled)
ext.enableCrashlytics = false
ext.alwaysUpdateBuildId = false // Firebase Crashlytics禁用更新构建ID
buildConfigField "String", "BASE_URL", server_url_debug
buildConfigField "String", "BASE_URL", "\"https://beta.api.pekolive.com/\""
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'
buildConfigField "String", "BASE_URL_RELEASE", "BASE_URL"
minifyEnabled false // 是否混淆
crunchPngs false // 停用 PNG 压缩
signingConfig signingConfigs.v2
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
gradle.taskGraph.whenReady {
tasks.each { task ->
if (task.name.contains("Test") || task.name.contains("Lint")) {
@@ -181,7 +169,7 @@ android {
mappingFileUploadEnabled CRASHLYTICS_COLLECTION_ENABLED.toBoolean()
}
buildConfigField "String", "BASE_URL", server_url_release
buildConfigField "String", "BASE_URL", "\"https://api.pekolive.com/\""
buildConfigField "String", "BASE_URL_DEBUG", "BASE_URL"
buildConfigField "String", "BASE_URL_STAGING", "BASE_URL"
buildConfigField "String", "BASE_URL_RELEASE", "BASE_URL"
@@ -215,9 +203,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 +260,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'
@@ -302,8 +287,6 @@ dependencies {
//wheelView
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 {
@@ -311,7 +294,7 @@ channel {
outputDir = new File(project.buildDir, "channelapk")
//多渠道包的命名规则,默认为:${appName}-${versionName}-${versionCode}-${flavorName}-${buildType}-${buildTime}
def only64 = onlyArm64 ? "-only64" : ""
apkNameFormat = 'piko-${buildType}only64-${flavorName}-v${versionName}-${buildTime}'.replace("only64", only64)
apkNameFormat = 'peko-${buildType}only64-${flavorName}-v${versionName}-${buildTime}'.replace("only64", only64)
//快速模式生成渠道包时不进行校验速度可以提升10倍以上默认为false
fastMode = false
//buildTime的时间格式默认格式yyyyMMdd-HHmmss

Binary file not shown.

Binary file not shown.

View File

@@ -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.**
@@ -235,8 +233,6 @@
-keep class org.json.** {*;}
-dontwarn com.yizhuan.xchat_android_core.**
-keep class com.yizhuan.xchat_android_core.** {*;}
-keep class com.yizhuan.treasure_box.bean.** {*;}
-keep class com.yizhuan.erban.avroom.bean.** {*;}
#百度统计

Binary file not shown.

Before

Width:  |  Height:  |  Size: 767 B

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 709 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 692 B

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 470 B

View File

@@ -51,15 +51,8 @@
tools:node="remove" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.BLUETOOTH" /> <!-- 如果需要实时音视频通话模块,下面的权限也是必须的。否则,可以不加 -->
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <!-- SDK 权限申明, 第三方 APP 接入时,请将 com.netease.nim.demo 替换为自己的包名 -->
@@ -79,9 +72,6 @@
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
<!-- AppsFlyer需要参考https://dev.appsflyer.com/hc/docs/install-android-sdk#setting-required-permissions -->
<uses-permission android:name="com.google.android.gms.permission.AD_ID" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<!-- 对于 Android 12.0 及以上设备,还需要添加如下权限: -->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<application
android:name=".application.XChatApplication"
@@ -95,7 +85,6 @@
android:theme="@style/MyMaterialTheme"
tools:replace="android:name,android:allowBackup"
tools:targetApi="n">
<activity
android:name=".other.activity.SplashActivity"
android:exported="true"
@@ -122,7 +111,7 @@
<data
android:host="main"
android:scheme="pikoapp" />
android:scheme="pekoapp" />
</intent-filter>
</activity>
@@ -222,7 +211,7 @@
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="Piko"
android:label="Peko"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan|stateAlwaysHidden" /> <!-- 配置的service和receiver -->
@@ -254,10 +243,6 @@
android:name=".avroom.activity.RoomBlackListActivity"
android:label="@string/main_androidmanifest_09"
android:screenOrientation="portrait" />
<activity
android:name=".module_hall.hall.activity.RoomIncomeActivity"
android:label="房间流水"
android:screenOrientation="portrait" />
<activity
android:name="com.yizhuan.tutu.music.activity.AddLocalMusicListActivity"
android:label="@string/main_androidmanifest_010"
@@ -355,24 +340,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 +506,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 +810,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" />
@@ -1008,16 +967,6 @@
android:configChanges="screenSize|orientation|keyboardHidden|mcc|mnc|locale|touchscreen|screenLayout|keyboard|navigation|fontScale|uiMode|smallestScreenSize|layoutDirection"
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".treasurefairy.HomeFairyActivity"
android:exported="false"
android:theme="@style/transparent_activity" />
<activity
android:name=".ui.webview.FairyDialogWebViewActivity"
android:configChanges="screenSize|orientation|keyboardHidden|mcc|mnc|locale|touchscreen|screenLayout|keyboard|navigation|fontScale|uiMode|smallestScreenSize|layoutDirection"
android:exported="false"
android:theme="@style/transparent_activity" />
<meta-data
android:name="notch.config"
@@ -1041,10 +990,6 @@
android:name="flutterEmbedding"
android:value="2" />
<meta-data
android:name="Mob-Https"
android:value="yes" />
<provider
android:name="com.netease.nimlib.ipc.NIMContentProvider"
android:authorities="${applicationId}.ipc.provider"
@@ -1062,7 +1007,8 @@
android:name="com.netease.nimlib.service.NimReceiver"
android:exported="false"
android:process=":core"
tools:node="remove"></receiver>
tools:node="remove">
</receiver>
<receiver android:name="com.netease.nimlib.service.ResponseReceiver" />
<receiver
android:name=".reciever.IncomingCallReceiver"
@@ -1072,7 +1018,6 @@
</intent-filter>
</receiver>
<receiver android:name=".reciever.NotificationClickReceiver" />
<service
android:name="com.netease.nimlib.service.NimService"
android:process=":core" />
@@ -1087,33 +1032,6 @@
<service
android:name=".service.DaemonService"
android:enabled="true" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
<meta-data
android:name="com.facebook.sdk.ClientToken"
android:value="@string/facebook_client_token" />
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
<activity android:name=".avroom.room_album.RoomAlbumActivity" />
</application>
</manifest>

View File

@@ -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

View File

@@ -214,8 +214,6 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
!TextUtils.isEmpty(linkedInfo.getDynamicId())) {
DynamicDetailActivity.start(context, JavaUtil.str2long(linkedInfo.getDynamicId()),
JavaUtil.str2long(linkedInfo.getWorldId()), 6);
} else if (linkedInfo.getType().equals("7") && !TextUtils.isEmpty(linkedInfo.getUid())) {
NimP2PMessageActivity.start(context, linkedInfo.getUid());
} else {
return false;
}
@@ -410,7 +408,6 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
}
onParseIntent();
handleNimIntent();
InitialModel.get().regionCheck();
}
private void onParseIntent() {
@@ -520,7 +517,6 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
@Subscribe(threadMode = ThreadMode.MAIN)
public void onLoadLoginUserInfoEvent(LoadLoginUserInfoEvent event) {
firstLoadedUserInfo();
InitialModel.get().regionCheck();
}
public void onLogout() {

View File

@@ -9,7 +9,7 @@ import com.yizhuan.erban.relation.cp.dialog.CpGlobalDialog;
import com.yizhuan.erban.ui.widget.LevelUpDialog;
import com.yizhuan.erban.ui.widget.RecallDialog;
import com.yizhuan.erban.ui.widget.lottery_dialog.LotteryDialogManager;
import com.yizhuan.erban.vip.dialog.VipUpgradeDialog;
import com.yizhuan.erban.vip.VipUpgradeDialog;
import com.yizhuan.xchat_android_core.activity.bean.LotteryInfo;
import com.yizhuan.xchat_android_core.level.event.CharmLevelUpEvent;
import com.yizhuan.xchat_android_core.level.event.LevelUpEvent;
@@ -27,6 +27,8 @@ import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.lang.ref.WeakReference;
/**
* 全局处理比如App弹窗
* create by lvzebiao @2019/8/14

View File

@@ -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;
@@ -51,6 +48,7 @@ import com.yizhuan.erban.R;
import com.yizhuan.erban.common.app.ActivityStack;
import com.yizhuan.erban.common.util.AppLifeCycleHelper;
import com.yizhuan.erban.module_hall.HallDataManager;
import com.yizhuan.erban.other.activity.SplashActivity;
import com.yizhuan.erban.radish.wallet.RadishWalletManager;
import com.yizhuan.erban.utils.PushMessageHandler;
import com.yizhuan.xchat_android_constants.XChatConstants;
@@ -67,7 +65,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 +113,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) {
@@ -168,11 +162,6 @@ public class XChatApplication extends BaseApp {
public String makeRevokeMsgTip(String s, IMMessage imMessage) {
return null;
}
@Override
public String makeCategory(IMMessage message) {
return null;
}
};
private static XChatApplication instance;
//生命周期监听
@@ -207,11 +196,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 +238,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 +248,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 +396,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 初始化
@@ -435,11 +413,11 @@ public class XChatApplication extends BaseApp {
SVGAParser.Companion.shareParser().init(BasicConfig.INSTANCE.getAppContext());
try {
/** svga动画缓存路径 */
String cacheDirPath = FileHelper.getRootCacheDir().getAbsolutePath();
File cacheFie = new File(cacheDirPath, "cacheDir");
HttpResponseCache.install(cacheFie, 1024 * 1024 * 128);
File cacheDir = new File(BasicConfig.INSTANCE.getAppContext().getApplicationContext().getExternalCacheDir(), "http");
if (!cacheDir.exists()) cacheDir.mkdirs();
HttpResponseCache.install(cacheDir, 1024 * 1024 * 128);
} catch (IOException e) {
Log.e(TAG, "HttpResponseCache install error :" + e.getMessage());
Log.e(TAG, "testtest", e);
}
initRxNet(BasicConfig.INSTANCE.getAppContext(), UriProvider.JAVA_WEB_URL);
@@ -525,7 +503,10 @@ public class XChatApplication extends BaseApp {
BasicConfig.INSTANCE.setAppContext(this.getApplicationContext());
SharedPreferenceUtils.init(this);
ResUtil.init(this);
initOtherSDK();
boolean isShowPrivacyAgreement = (boolean) SharedPreferenceUtils.get(SplashActivity.SHOW_PRIVACY_AGREEMENT, true);
if (!isShowPrivacyAgreement) {
initOtherSDK();
}
initContext(this);
//首次启动事件
HashMap<String, Object> map = new HashMap<>(2);
@@ -561,18 +542,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()
);
}
}
}

View File

@@ -109,9 +109,6 @@ public class AudioPlayerHelper {
}
public void endPlay() {
if (listener != null) {
listener.onCompletion();
}
handler.removeMessages(WHAT_STATUS.COUNT_PLAY);
if (player != null) {
if (preparing) {

View File

@@ -18,7 +18,7 @@ import com.yizhuan.erban.ui.im.avtivity.NimFriendModel;
import com.yizhuan.erban.ui.im.avtivity.NimP2PMessageActivity;
import com.yizhuan.erban.ui.widget.ButtonItem;
import com.yizhuan.erban.ui.widget.GiftDialog;
import com.yizhuan.erban.vip.util.VipHelper;
import com.yizhuan.erban.vip.VipHelper;
import com.yizhuan.tutu.room_chat.activity.RoomMsgActivity;
import com.yizhuan.xchat_android_core.auth.AuthModel;
import com.yizhuan.xchat_android_core.bean.RoomQueueInfo;

View File

@@ -2,25 +2,13 @@ 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;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ROOM_PK;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_GIFT_L5;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_ROOM_PK_NOTIFY;
import 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 +31,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 +58,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 +74,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;
@@ -101,22 +90,9 @@ import com.yizhuan.xchat_android_core.channel_page.bean.HelloMessageInfo;
import com.yizhuan.xchat_android_core.gift.GiftModel;
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo;
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagNoticeInfo;
import com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.FairyMsgAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.NotifyH5Attachment;
import com.yizhuan.xchat_android_core.im.custom.bean.NotifyH5Info;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeInfo;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomLuckySeaAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomLuckySeaMsgBean;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomPKAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomPkBean;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomReceivedLuckyGiftAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.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;
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager;
import com.yizhuan.xchat_android_core.manager.RoomEvent;
@@ -134,6 +110,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,10 +122,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;
import com.yizhuan.xchat_android_core.user.bean.UserInfo;
@@ -156,6 +129,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,8 +141,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.Objects;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import io.reactivex.Single;
@@ -184,7 +160,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 +198,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 +206,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);
@@ -330,9 +303,11 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
svgaRoomBg.setImageResource(R.drawable.bg_room_cp);
}
} 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");
String singleSvgaPath = "svga/single_back.svga";
if (!singleSvgaPath.equals(bgPicture[0])) {
playSvgaBg(svgaRoomBg, singleSvgaPath);
bgPicture[0] = singleSvgaPath;
}
} else {
bgPicture[0] = "";
if (roomInfo.getRoomModeType() == RoomModeType.OPEN_PK_MODE) {
@@ -409,7 +384,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 +396,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 {
@@ -445,7 +414,6 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
mVsNobleOpen = findViewById(R.id.vs_noble_open_notice);
vsTaskTips = findViewById(R.id.vs_task_tips);
viewpager = findViewById(R.id.fragment_container);
InitialModel.get().getFairyOpenInfo();
IMNetEaseManager.get().getChatRoomEventObservable()
.compose(bindToLifecycle())
@@ -458,7 +426,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 +453,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 +493,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 +598,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 +649,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 +662,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 +698,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 +1058,7 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
DemoCache.readNewUserChargeGift() == 0) {
DemoCache.saveNewUserChargeGift(1);
}
showRedPackage(AvRoomDataManager.get().mCurrentRoomInfo);
dismissLoadingDialog();
}
@@ -1210,9 +1178,10 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
baseProtocol = null;
}
if (baseProtocol == null) return;
if (!isValid()) return;
switch (baseProtocol.getFirst()) {
case CUSTOM_MSG_HEADER_TYPE_GIFT:
if (!isValid()) return;
if (giftList == null) {
giftList = new LinkedList<>();
}
@@ -1222,94 +1191,21 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
return;
giftList.add(data);
if (second2 == CUSTOM_MSG_ALL_SERVICE_GIFT) {
if (mCurrentFragment != null && mCurrentFragment.isShowingPlayNotify()) {
return;
}
showGiftDialog();
}
break;
case CUSTOM_MSG_BOX://寻爱之旅
if (baseProtocol.getSecond() == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
RoomBoxPrizeAttachment roomBoxPrizeAttachment = new RoomBoxPrizeAttachment(CUSTOM_MSG_BOX, CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA);
RoomBoxPrizeInfo roomBoxPrizeBean = JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomBoxPrizeInfo.class);
roomBoxPrizeAttachment.setUid(roomBoxPrizeBean.getUid());
roomBoxPrizeAttachment.setPrizeName(roomBoxPrizeBean.getPrizeName());
roomBoxPrizeAttachment.setNick(roomBoxPrizeBean.getNick());
roomBoxPrizeAttachment.setBoxTypeStr(roomBoxPrizeBean.getBoxTypeStr());
roomBoxPrizeAttachment.setRoomUid(roomBoxPrizeBean.getRoomUid());
roomBoxPrizeAttachment.setPrizeNum(roomBoxPrizeBean.getPrizeNum());
roomBoxPrizeAttachment.setUserLevelLimit(roomBoxPrizeBean.getUserLevelLimit());
if (AvRoomDataManager.get().isOpenPureMode()) {
// 純凈模式打開後,僅能看跟自己相關的砸蛋消息
if (Objects.equals(roomBoxPrizeAttachment.getUid(), AuthModel.get().getCurrentUid())) {
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), roomBoxPrizeAttachment);
IMNetEaseManager.get().addMessages(message);
if (giftDialog != null && giftDialog.isShowing()) {
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst();
if (dataBean != null) {
return;
} else {
giftDialog.dismiss();
}
} else {
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), roomBoxPrizeAttachment);
IMNetEaseManager.get().addMessages(message);
IMNetEaseManager.get().getChatRoomEventObservable()
.onNext(new RoomEvent()
.setEvent(RoomEvent.BOX_NOTIFY_SVGA)
.setChatRoomMessage(message));
showGiftDialog();
}
}
break;
case CustomAttachment.CUSTOM_MESS_TAROT:
if (baseProtocol.getSecond() == CustomAttachment.CUSTOM_MESS_TAROT_SENIOR_PRIZE_WINNING) {
TarotMsgBean tarotMsgBean = JSON.parseObject(String.valueOf(baseProtocol.getData()), TarotMsgBean.class);
TarotAttachment tarotAttachment = new TarotAttachment(CustomAttachment.CUSTOM_MESS_TAROT,
CustomAttachment.CUSTOM_MESS_TAROT_SENIOR_PRIZE_WINNING);
tarotAttachment.setTarotMsgBean(tarotMsgBean);
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(
String.valueOf(AvRoomDataManager.get().getRoomId()), tarotAttachment);
IMNetEaseManager.get().getChatRoomEventObservable()
.onNext(new RoomEvent()
.setEvent(RoomEvent.TAROT_NOTIFY_SVGA)
.setChatRoomMessage(message));
AvRoomDataManager.get().addChatRoomMessage(message);
}
break;
case CustomAttachment.CUSTOM_MSG_NOTIFY_H5:
if (baseProtocol.getSecond() == CustomAttachment.CUSTOM_MSG_NOTIFY_H5_SUB_WHOLE_SERVICE) {
NotifyH5Info bean = JSON.parseObject(String.valueOf(baseProtocol.getData()), NotifyH5Info.class);
NotifyH5Attachment notifyH5Attachment = new NotifyH5Attachment(baseProtocol.getSecond());
notifyH5Attachment.setBean(bean);
ChatRoomMessage notifyH5Msg = ChatRoomMessageBuilder.createChatRoomCustomMessage(
String.valueOf(AvRoomDataManager.get().getRoomId()), notifyH5Attachment);
IMNetEaseManager.get().getChatRoomEventObservable()
.onNext(new RoomEvent()
.setEvent(RoomEvent.NOTIFY_H5)
.setChatRoomMessage(notifyH5Msg));
}
break;
case CUSTOM_MSG_LUCKY_SEA://星级厨房
if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL) {
RoomLuckySeaAttachment attachment = new RoomLuckySeaAttachment(CUSTOM_MSG_LUCKY_SEA, CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL);
attachment.setRoomLuckySeaMsgBean(JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomLuckySeaMsgBean.class));
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), attachment);
IMNetEaseManager.get().addMessages(message);
IMNetEaseManager.get().noticeRoomEvent(message, RoomEvent.LUCKY_SEA_GIFT_SERVER_NOTIFY);
}
break;
case CUSTOM_MSG_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) {
case CUSTOM_MSG_LUCKY_GIFT:
if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY) {
RoomReceivedLuckyGiftAttachment attachment = new RoomReceivedLuckyGiftAttachment(CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY);
attachment.setLuckyBagNoticeInfo(JSON.parseObject(String.valueOf(baseProtocol.getData()), LuckyBagNoticeInfo.class));
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), attachment);
@@ -1317,14 +1213,6 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
IMNetEaseManager.get().addMessages(message);
}
break;
case CUSTOM_MSG_FAIRY://夺宝精灵
if (baseProtocol.getSecond() == CUSTOM_MSG_SUB_DRAW_GIFT_L5) {
FairyMsgAttachment attachment = new FairyMsgAttachment(CUSTOM_MSG_FAIRY, CUSTOM_MSG_SUB_DRAW_GIFT_L5);
attachment.setFairyMsgInfo(JSON.parseObject(String.valueOf(baseProtocol.getData()), FairyMsgInfoBean.class));
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), attachment);
IMNetEaseManager.get().noticeRoomEvent(message, RoomEvent.FAIRY_DRAW_GIFT_L5);
}
break;
case CUSTOM_MSG_ROOM_PK:
if (baseProtocol.getSecond() == CUSTOM_MSG_SUB_ROOM_PK_NOTIFY) {
RoomPKAttachment attachment = new RoomPKAttachment(CUSTOM_MSG_SUB_ROOM_PK_NOTIFY);
@@ -1338,24 +1226,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 +1243,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 +1312,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 +1325,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);
}
}
}
}

View File

@@ -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;

View File

@@ -47,6 +47,7 @@ import com.yizhuan.xchat_android_library.utils.config.BasicConfig;
* @author xiaoyu
* @date 2017/12/18
*/
public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
// 麦位类型用于左右滑动切换房间时判断是否需要更换麦位adapter
public static final String MICRO_TYPE_NULL = "null";
@@ -60,7 +61,7 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
protected static final int TYPE_BOSS = 1;
protected static final int TYPE_NORMAL = 0;
protected static final int TYPE_INVALID = -2;
protected OnMicroItemClickListener onMicroItemClickListener = null;
protected OnMicroItemClickListener onMicroItemClickListener;
protected Context context;
public BaseMicroViewAdapter(Context context) {
@@ -527,7 +528,7 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
/**
* 主席位特有
*/
View frTitle;
FrameLayout frTitle;
TextView tvRoomDesc;
ImageView ivTag;
TextView tvLabelLeaveMode;

View File

@@ -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();
}

View File

@@ -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

View File

@@ -49,7 +49,7 @@ class RoomPKSearchActivity : BaseViewBindingActivity<ActivityRoomPkSearchBinding
rvDelegate = RVDelegate.Builder<SimpleRoomInfo>()
.setPageSize(pageSize)
.setEmptyView(EmptyViewHelper.createEmptyTextView(this, ResUtil.getString(R.string.avroom_anotherroompk_roompksearchactivity_01)))
.setEmptyView(EmptyViewHelper.createEmptyView(this, ResUtil.getString(R.string.avroom_anotherroompk_roompksearchactivity_01)))
.setLayoutManager(LinearLayoutManager(this))
.setRecyclerView(binding.recyclerView)
.setAdapter(roomPKSearchAdapter)

View File

@@ -12,7 +12,7 @@ class RoomPKSearchAdapter :
override fun convert(helper: BaseViewHolder, item: SimpleRoomInfo) {
helper.setText(R.id.tv_room_title,item.title.subAndReplaceDot(7))
.setText(R.id.tv_room_id,"Piko号:${item.erbanNo}")
.setText(R.id.tv_room_id,"Peko号:${item.erbanNo}")
.setChecked(R.id.check_box,item.checked)
ImageLoadUtils.loadImage(mContext,item.avatar,helper.getView(R.id.iv_avatar))
helper.addOnClickListener(R.id.iv_avatar,R.id.check_box)

View File

@@ -30,71 +30,71 @@ class RoomPkFinishDialog : BaseDialog<DialogRoomPkFinishBinding>() {
@SuppressLint("CheckResult", "SetTextI18n")
override fun init() {
binding?.ivClose?.setOnClickListener { dismissAllowingStateLoss() }
binding?.tvTitleRed?.text = roomPkBean.cTitle.subAndReplaceDot(7)
binding?.tvValueRed?.text = "${roomPkBean.cAmount}"
binding?.ivRedWin?.isVisible = roomPkBean.cUid == roomPkBean.winUid && roomPkBean.winUid != 0L
binding.ivClose.setOnClickListener { dismissAllowingStateLoss() }
binding.tvTitleRed.text = roomPkBean.cTitle.subAndReplaceDot(7)
binding.tvValueRed.text = "${roomPkBean.cAmount}"
binding.ivRedWin.isVisible = roomPkBean.cUid == roomPkBean.winUid && roomPkBean.winUid != 0L
ImageLoadUtils.loadImage(
context,
roomPkBean.cAvatar,
binding?.ivAvatarRed,
binding.ivAvatarRed,
R.drawable.default_avatar
)
binding?.tvTitleBlue?.text = roomPkBean.aTitle.subAndReplaceDot(7)
binding?.tvValueBlue?.text = "${roomPkBean.aAmount}"
binding?.ivBlueWin?.isVisible =
binding.tvTitleBlue.text = roomPkBean.aTitle.subAndReplaceDot(7)
binding.tvValueBlue.text = "${roomPkBean.aAmount}"
binding.ivBlueWin.isVisible =
roomPkBean.cUid != roomPkBean.winUid && roomPkBean.winUid != 0L
ImageLoadUtils.loadImage(
context,
roomPkBean.aAvatar,
binding?.ivAvatarBlue,
binding.ivAvatarBlue,
R.drawable.default_avatar
)
roomPkBean.csRank.getOrNull(0)?.let {
binding?.tvNickContribute?.text = it.nick.subAndReplaceDot(7)
binding?.tvValueContribute?.text = "神豪值:${it.amount}"
binding.tvNickContribute.text = it.nick.subAndReplaceDot(7)
binding.tvValueContribute.text = "神豪值:${it.amount}"
ImageLoadUtils.loadImage(
context,
it.avatar,
binding?.ivAvatarContribute,
binding.ivAvatarContribute,
R.drawable.default_avatar
)
}
roomPkBean.crRank.getOrNull(0)?.let {
binding?.tvNickCharm?.text = it.nick.subAndReplaceDot(7)
binding?.tvValueCharm?.text = "魅力值:${it.amount}"
binding.tvNickCharm.text = it.nick.subAndReplaceDot(7)
binding.tvValueCharm.text = "魅力值:${it.amount}"
ImageLoadUtils.loadImage(
context,
it.avatar,
binding?.ivAvatarCharm,
binding.ivAvatarCharm,
R.drawable.default_avatar
)
}
when (roomPkBean.winUid) {
0L -> {
binding?.viewBg?.setBackgroundResource(R.drawable.bg_719cea_radius_10)
binding?.clRoot?.setBackgroundResource(R.drawable.bg_room_pk_finish_deuce)
binding?.viewContribute?.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_deuce)
binding?.viewCharm?.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_deuce)
binding?.ivClose?.setImageResource(R.drawable.ic_room_pk_finish_close_deuce)
binding.viewBg.setBackgroundResource(R.drawable.bg_719cea_radius_10)
binding.clRoot.setBackgroundResource(R.drawable.bg_room_pk_finish_deuce)
binding.viewContribute.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_deuce)
binding.viewCharm.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_deuce)
binding.ivClose.setImageResource(R.drawable.ic_room_pk_finish_close_deuce)
}
roomPkBean.cUid -> {
binding?.viewBg?.setBackgroundResource(R.drawable.bg_edbf89_radius_10)
binding?.clRoot?.setBackgroundResource(R.drawable.bg_room_pk_finish_win)
binding?.viewContribute?.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_win)
binding?.viewCharm?.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_win)
binding?.ivClose?.setImageResource(R.drawable.ic_room_pk_finish_close_win)
binding.viewBg.setBackgroundResource(R.drawable.bg_edbf89_radius_10)
binding.clRoot.setBackgroundResource(R.drawable.bg_room_pk_finish_win)
binding.viewContribute.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_win)
binding.viewCharm.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_win)
binding.ivClose.setImageResource(R.drawable.ic_room_pk_finish_close_win)
}
else -> {
binding?.viewBg?.setBackgroundResource(R.drawable.bg_bfabf6_radius_10)
binding?.clRoot?.setBackgroundResource(R.drawable.bg_room_pk_finish_failed)
binding?.viewContribute?.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_failed)
binding?.viewCharm?.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_failed)
binding?.ivClose?.setImageResource(R.drawable.ic_room_pk_finish_close_failed)
binding.viewBg.setBackgroundResource(R.drawable.bg_bfabf6_radius_10)
binding.clRoot.setBackgroundResource(R.drawable.bg_room_pk_finish_failed)
binding.viewContribute.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_failed)
binding.viewCharm.setBackgroundResource(R.drawable.bg_room_pk_finish_rank_failed)
binding.ivClose.setImageResource(R.drawable.ic_room_pk_finish_close_failed)
}
}

View File

@@ -29,23 +29,23 @@ class RoomPkForceFinishDialog : BaseDialog<DialogRoomPkForceFinishBinding>() {
@SuppressLint("CheckResult", "SetTextI18n")
override fun init() {
binding?.ivClose?.setOnClickListener { dismissAllowingStateLoss() }
binding?.tvTitleRed?.text = roomPkBean.cTitle.subAndReplaceDot(7)
binding?.tvValueRed?.text = "${roomPkBean.cAmount}"
binding.ivClose.setOnClickListener { dismissAllowingStateLoss() }
binding.tvTitleRed.text = roomPkBean.cTitle.subAndReplaceDot(7)
binding.tvValueRed.text = "${roomPkBean.cAmount}"
ImageLoadUtils.loadImage(
context,
roomPkBean.cAvatar,
binding?.ivAvatarRed,
binding.ivAvatarRed,
R.drawable.default_avatar
)
binding?.tvTitleBlue?.text = roomPkBean.aTitle.subAndReplaceDot(7)
binding?.tvValueBlue?.text = "${roomPkBean.aAmount}"
binding.tvTitleBlue.text = roomPkBean.aTitle.subAndReplaceDot(7)
binding.tvValueBlue.text = "${roomPkBean.aAmount}"
ImageLoadUtils.loadImage(
context,
roomPkBean.aAvatar,
binding?.ivAvatarBlue,
binding.ivAvatarBlue,
R.drawable.default_avatar
)

View File

@@ -36,26 +36,26 @@ class RoomPkReceivedDialog : BaseDialog<DialogRoomPkReceivedBinding>() {
@SuppressLint("CheckResult")
override fun init() {
binding?.tvNick?.text = pkBean.inviteRoomTitle.subAndReplaceDot(7)
binding?.tvTime?.text = "${pkBean.pkDuration}分鐘"
binding.tvNick.text = pkBean.inviteRoomTitle.subAndReplaceDot(7)
binding.tvTime.text = "${pkBean.pkDuration}分鐘"
pkBean.pkDesc.ifNotNullOrEmpty {
binding?.tvDescTitle?.isVisible = true
binding?.tvDesc?.isVisible = true
binding?.tvDesc?.text = it
binding.tvDescTitle.isVisible = true
binding.tvDesc.isVisible = true
binding.tvDesc.text = it
}
disposable = Observable.intervalRange(0, 10, 0, 1, TimeUnit.SECONDS)
.compose(bindToLifecycle())
.observeOn(AndroidSchedulers.mainThread())
.doOnComplete { dismissAllowingStateLoss() }
.subscribe {
binding?.tvCloseTime?.text = "${10 - it}"
binding.tvCloseTime.text = "${10 - it}"
}
binding?.tvReceived?.setOnClickListener {
binding.tvReceived.setOnClickListener {
commit(true)
}
binding?.tvRefuse?.setOnClickListener {
binding.tvRefuse.setOnClickListener {
commit(false)
}
}

View File

@@ -14,6 +14,6 @@ class RoomPkRuleDialog : BaseDialog<DialogRoomPkRuleBinding>() {
}
override fun init() {
binding?.ivClose?.setOnClickListener { dismissAllowingStateLoss() }
binding.ivClose.setOnClickListener { dismissAllowingStateLoss() }
}
}

View File

@@ -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
}
}

View File

@@ -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
}
}

View File

@@ -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
)

View File

@@ -1,8 +0,0 @@
package com.yizhuan.erban.avroom.bean
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage
data class RoomPlayBean(
val event: Int,
val chatRoomMessage: ChatRoomMessage
)

View File

@@ -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()
}
}

View File

@@ -33,10 +33,10 @@ class CreateGameRoomDialog : BaseDialog<DialogCreateGameRoomBinding>() {
@SuppressLint("CheckResult")
override fun init() {
binding?.rvGame?.itemAnimator = null
binding.rvGame.itemAnimator = null
rvDelegate = RVDelegate.Builder<GameInfo>()
.setAdapter(gameAdapter)
.setRecyclerView(binding?.rvGame)
.setRecyclerView(binding.rvGame)
.setLayoutManager(GridLayoutManager(context, 2))
.build()
@@ -48,7 +48,7 @@ class CreateGameRoomDialog : BaseDialog<DialogCreateGameRoomBinding>() {
)
}
binding?.ivClose?.setOnClickListener {
binding.ivClose.setOnClickListener {
dismissAllowingStateLoss()
}

View File

@@ -33,14 +33,14 @@ class CreateRoomDialog : BaseDialog<DialogCreateRoomBinding>() {
@SuppressLint("CheckResult")
override fun init() {
if(isHomeGame){
binding?.tvPlayType?.isVisible = false
binding?.rgType?.isVisible = false
binding?.rvGame?.isVisible = true
binding.tvPlayType.isVisible = false
binding.rgType.isVisible = false
binding.rvGame.isVisible = true
}
binding?.rvGame?.itemAnimator = null
binding.rvGame.itemAnimator = null
rvDelegate = RVDelegate.Builder<GameInfo>()
.setAdapter(gameAdapter)
.setRecyclerView(binding?.rvGame)
.setRecyclerView(binding.rvGame)
.setLayoutManager(LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false))
.build()
@@ -55,22 +55,22 @@ class CreateRoomDialog : BaseDialog<DialogCreateRoomBinding>() {
checkCreateEnable()
}
binding?.rbGameRoom?.setOnCheckedChangeListener { _, isChecked ->
binding.rbGameRoom.setOnCheckedChangeListener { _, isChecked ->
checkCreateEnable()
if (isChecked) {
binding?.rvGame?.isVisible = true
binding.rvGame.isVisible = true
}
}
binding?.rbPartyRoom?.setOnCheckedChangeListener { _, isChecked ->
binding.rbPartyRoom.setOnCheckedChangeListener { _, isChecked ->
checkCreateEnable()
if (isChecked) {
binding?.rvGame?.isInvisible = true
binding.rvGame.isInvisible = true
}
}
binding?.tvCreate?.setOnClickListener {
binding.tvCreate.setOnClickListener {
dismissAllowingStateLoss()
if (binding?.rbPartyRoom?.isChecked == true) {
if (binding.rbPartyRoom.isChecked) {
OpenRoomHelper.openHomePartyRoom(requireActivity() as BaseActivity)
} else {
if (selectIndex != -1) {
@@ -84,7 +84,7 @@ class CreateRoomDialog : BaseDialog<DialogCreateRoomBinding>() {
}
}
binding?.ivClose?.setOnClickListener {
binding.ivClose.setOnClickListener {
dismissAllowingStateLoss()
}
@@ -105,10 +105,10 @@ class CreateRoomDialog : BaseDialog<DialogCreateRoomBinding>() {
private fun checkCreateEnable() {
if(isHomeGame){
binding?.tvCreate?.isEnabled = selectIndex != -1
binding.tvCreate.isEnabled = selectIndex != -1
}else {
binding?.tvCreate?.isEnabled = binding?.rbPartyRoom?.isChecked == true ||
(binding?.rbGameRoom?.isChecked == true && selectIndex != -1)
binding.tvCreate.isEnabled = binding.rbPartyRoom.isChecked ||
(binding.rbGameRoom.isChecked && selectIndex != -1)
}
}
}

View File

@@ -9,11 +9,11 @@ class NewUserGiftDialog(val giftInfo: GiftInfo) :
BaseDialog<DialogNewUserGiftBinding>() {
override fun init() {
binding?.ivClose?.setOnClickListener {
binding.ivClose.setOnClickListener {
dismissAllowingStateLoss()
}
binding?.ivGift?.load(giftInfo.giftUrl)
binding?.tvGiftName?.text = "${giftInfo.giftName}*${giftInfo.count}"
binding.ivGift.load(giftInfo.giftUrl)
binding.tvGiftName.text = "${giftInfo.giftName}*${giftInfo.count}"
}
}

View File

@@ -24,14 +24,13 @@ import com.yizhuan.erban.avroom.activity.CreatePKActivity;
import com.yizhuan.erban.avroom.activity.RoomSettingActivity;
import com.yizhuan.erban.avroom.anotherroompk.RoomPKCreateActivity;
import com.yizhuan.erban.avroom.giftvalue.GiftValueDialogUiHelper;
import com.yizhuan.erban.avroom.room_album.RoomAlbumActivity;
import com.yizhuan.erban.avroom.singleroompk.SingleRoomPKCreateActivity;
import com.yizhuan.erban.common.util.Utils;
import com.yizhuan.erban.common.widget.dialog.DialogManager;
import com.yizhuan.erban.ui.widget.ButtonItem;
import com.yizhuan.erban.ui.widget.recyclerview.decoration.ColorDecoration;
import com.yizhuan.erban.ui.widget.recyclerview.layoutmanager.FullyGridLayoutManager;
import com.yizhuan.erban.vip.dialog.VipBroadcastDialog;
import com.yizhuan.erban.vip.VipBroadcastDialog;
import com.yizhuan.tutu.room_chat.activity.RoomInviteFansActivity;
import com.yizhuan.xchat_android_constants.XChatConstants;
import com.yizhuan.xchat_android_core.auth.AuthModel;
@@ -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), () -> {

View File

@@ -44,31 +44,31 @@ class SendBroadcastDialog : BaseDialog<DialogSendBroadcastBinding>() {
@SuppressLint("CheckResult", "SetTextI18n")
override fun init() {
binding?.ivClose?.setOnClickListener {
binding.ivClose.setOnClickListener {
dismissAllowingStateLoss()
}
adapter = SendBroadcastAdapter()
rvDelegate = RVDelegate.Builder<String>()
.setAdapter(adapter)
.setRecyclerView(binding?.rvRecommend)
.setRecyclerView(binding.rvRecommend)
.setLayoutManager(LinearLayoutManager(context))
.build()
adapter.setOnItemClickListener { _, _, position ->
binding?.editContent?.setText(adapter.getItem(position))
binding.editContent.setText(adapter.getItem(position))
}
binding?.editContent?.addTextChangedListener(object : TextWatcherWrapper() {
binding.editContent.addTextChangedListener(object : TextWatcherWrapper() {
override fun afterTextChanged(editable: Editable?) {
val contentLength = editable?.length ?: 0
binding?.tvContentNumLimit?.text =
binding.tvContentNumLimit.text =
"${contentLength}/${broadcastInfo?.maxWords ?: 20}"
binding?.tvSend?.isEnabled = contentLength != 0
binding.tvSend.isEnabled = contentLength != 0
}
})
binding?.tvSend?.setOnClickListener {
binding.tvSend.setOnClickListener {
if (CommonUtils.isFastDoubleClick(1000)) return@setOnClickListener
sendBroadcast()
}
@@ -90,13 +90,13 @@ class SendBroadcastDialog : BaseDialog<DialogSendBroadcastBinding>() {
private fun initData(info: BroadcastInfo) {
broadcastInfo = info
rvDelegate.setNewData(info.recommends)
binding?.tvAvailableCountNum?.text = "${info.availableTimes}/${info.total}"
binding?.editContent?.hint = "输入内容不能少于${info.minWords}个字,请文明发言哦~"
binding?.tvContentNumLimit?.text = "0/${info.maxWords}"
binding.tvAvailableCountNum.text = "${info.availableTimes}/${info.total}"
binding.editContent.hint = "输入内容不能少于${info.minWords}个字,请文明发言哦~"
binding.tvContentNumLimit.text = "0/${info.maxWords}"
if (info.seconds > 0) {
beginIntervalTime(info)
} else {
binding?.tvSendHint?.text = "发布后,${info.minutes}分钟内不可再发布广播"
binding.tvSendHint.text = "发布后,${info.minutes}分钟内不可再发布广播"
}
}
@@ -107,10 +107,10 @@ class SendBroadcastDialog : BaseDialog<DialogSendBroadcastBinding>() {
.observeOn(AndroidSchedulers.mainThread())
.compose(bindToLifecycle())
.doOnComplete {
binding?.tvSendHint?.text = "发布后,${info.minutes}分钟内不可再发布广播"
binding.tvSendHint.text = "发布后,${info.minutes}分钟内不可再发布广播"
}
.subscribe {
binding?.tvSendHint?.text = SpannableBuilder()
binding.tvSendHint.text = SpannableBuilder()
.append(
"${info.seconds - it}",
ForegroundColorSpan(Color.parseColor("#FFFDA615"))
@@ -127,7 +127,7 @@ class SendBroadcastDialog : BaseDialog<DialogSendBroadcastBinding>() {
return
}
broadcastInfo?.let {
val msg = binding?.editContent?.text
val msg = binding.editContent.text
if (msg.isNullOrEmpty() || msg.length < it.minWords) {
"输入内容不能少于${it.minWords}个字!".toast()
return@let

View File

@@ -9,7 +9,7 @@ class SingleRoomTipDialog :
BaseDialog<DialogSingleRoomTipBinding>() {
@SuppressLint("ClickableViewAccessibility")
override fun init() {
binding?.root?.setOnClickListener {
binding.root.setOnClickListener {
dismissAllowingStateLoss()
}
dialog?.window?.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL)

View File

@@ -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) {

View File

@@ -6,9 +6,11 @@ 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.view.KeyEvent
import android.view.MotionEvent
import android.view.View
import android.view.ViewStub
@@ -18,9 +20,6 @@ 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 +43,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 +54,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 +91,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 +102,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 +114,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 +128,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 +137,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 +177,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() {
@@ -180,17 +184,10 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
bottomView = mView.findViewById(R.id.bottom_view)
inputLayout = mView.findViewById(R.id.input_layout)
inputEdit = mView.findViewById(R.id.input_edit)
inputEdit.setOnKeyListener { _, keyCode, event ->
if (keyCode == KeyEvent.KEYCODE_ENTER && event.action == KeyEvent.ACTION_UP) {
sendMsg()
return@setOnKeyListener true
}
false
}
inputSend = mView.findViewById(R.id.input_send)
microView = mView.findViewById(R.id.micro_view)
mVsMusicPlayer = mView.findViewById(R.id.vs_music_player)
ivRadishEntrance = mView.findViewById(R.id.iv_radish_entrance)
messageView.setClickConsumer {
if (!TextUtils.isEmpty(it) && it != "0") {
showUserCardDialog(it)
@@ -231,7 +228,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 +266,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
@@ -301,22 +292,18 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
GiftValueMrg.get().handleReconnect(false)
}
}
RoomEvent.ROOM_EXIT -> {
// 退出房間,把標誌置為 false
AvRoomDataManager.get().isFromMentoring = false
// 退出房間的時候,要停止倒計時
EventBus.getDefault().post(MentoringStopCountingEvent())
}
RoomEvent.DOWN_CROWDED_MIC -> if (AvRoomDataManager.get().isOwner(roomEvent.account)) {
toast(R.string.crowded_down)
}
RoomEvent.ROOM_MANAGER_ADD, RoomEvent.ROOM_MANAGER_REMOVE -> {
updateView()
}
RoomEvent.ROOM_INFO_UPDATE -> {
Logger.i(ResUtil.getString(R.string.avroom_fragment_baseroomfragment_01))
addOpenDatingTips() //一定要放在updateView之前!!!
@@ -326,16 +313,13 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
updateRemoteMuteBtn()
openOrCloseGiftValue(false)
}
RoomEvent.ENTER_ROOM -> {
Logger.i(ResUtil.getString(R.string.avroom_fragment_baseroomfragment_02))
updateView()
updateRemoteMuteBtn()
openOrCloseGiftValue(true)
GiftValueMrg.get().updateRoomGiftValue(false)
onEnterRoom()
}
RoomEvent.ADD_BLACK_LIST -> onChatRoomMemberBlackAdd(roomEvent.account)
RoomEvent.MIC_QUEUE_STATE_CHANGE -> onQueueMicStateChange()
RoomEvent.KICK_DOWN_MIC_BY_S_ADMIN, RoomEvent.KICK_DOWN_MIC -> if (event == RoomEvent.KICK_DOWN_MIC) {
@@ -351,20 +335,16 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
)
)
}
RoomEvent.DOWN_MIC -> {
onDownMicro()
}
RoomEvent.UP_MIC -> {
onUpMicro()
}
RoomEvent.INVITE_UP_MIC -> if (AvRoomDataManager.get().isOwner(roomEvent.account)) {
//自己的消息
onInviteUpMic(roomEvent.micPosition)
}
RoomEvent.KICK_OUT_ROOM -> {
val reason = roomEvent.reason
if (reason != null && reason.reason == ChatRoomKickOutEvent.ChatRoomKickOutReason.CHAT_ROOM_INVALID) {
@@ -382,7 +362,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
AvRoomDataManager.get().removeChatRoomMember(targetUid)
}
}
RoomEvent.LEAVE_MODE -> microView.adapter.notifyDataSetChanged()
RoomEvent.ROOM_CLEAN_SCREEN -> messageView.clear()
}
@@ -443,6 +422,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 +515,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 {
@@ -565,7 +603,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
override fun onDestroyView() {
super.onDestroyView()
releaseView()
unregisterWidgets()
}
override fun onDestroy() {
@@ -595,6 +632,14 @@ 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)
}
}
@@ -662,7 +707,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
}
.subscribe { _, throwable ->
if (throwable != null) {
toast(throwable.message)
callback.onFail()
} else {
callback.onSuccess()
@@ -765,7 +809,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
buttonItems.add(buttonItem4)
}
//個播房只有房主有抱上麥功能
if ((!AvRoomDataManager.get().isSingleRoom || AvRoomDataManager.get().isRoomOwner || AvRoomDataManager.get().isRoomAdmin) &&
if ((!AvRoomDataManager.get().isSingleRoom || AvRoomDataManager.get().isRoomOwner) &&
!AvRoomDataManager.get().isDatingVipMic(micPosition)
) {
buttonItems.add(buttonItem1)
@@ -939,9 +983,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 +1108,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)
@@ -1155,7 +1208,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
AudioEngineManager.get().isMute = !AudioEngineManager.get().isMute
updateMicBtn()
if (AudioEngineManager.get().isMute) {
AudioEngineManager.get().stopLocalAudio()
} else if (AvRoomDataManager.get().isOnMic(myUid)) {
AudioEngineManager.get().setRole(Constants.CLIENT_ROLE_BROADCASTER)
}
@@ -1179,7 +1232,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 +1251,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 +1261,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) {
}
}

View File

@@ -1,202 +0,0 @@
package com.yizhuan.erban.avroom.fragment
import android.annotation.SuppressLint
import android.os.Bundle
import android.view.View
import androidx.core.view.isInvisible
import androidx.core.view.isVisible
import androidx.databinding.DataBindingUtil
import com.yizhuan.erban.R
import com.yizhuan.erban.avroom.adapter.GameMicroViewAdapter
import com.yizhuan.erban.avroom.adapter.GameMiniMicroViewAdapter
import com.yizhuan.erban.avroom.adapter.OnMicroItemClickListener
import com.yizhuan.erban.avroom.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.manager.AvRoomDataManager
import com.yizhuan.xchat_android_core.music.model.PlayerModel
import com.yizhuan.xchat_android_core.pay.event.FirstChargeEvent
import com.yizhuan.xchat_android_core.room.event.FinishAvRoomEvent
import com.yizhuan.xchat_android_library.base.factory.CreatePresenter
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
/**
* 轰趴房间
*
* @author chenran
* @date 2017/7/26
*/
@CreatePresenter(GameRoomPresenter::class)
class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
View.OnClickListener, OnGiftDialogBtnClickListener, IGameRoomView, OnMicroItemClickListener,
OnGameStatusChangeListener {
companion object {
@JvmStatic
fun newInstance(): GameRoomFragment {
val roomFragment = GameRoomFragment()
val bundle = Bundle()
roomFragment.arguments = bundle
return roomFragment
}
}
private lateinit var gameBinding: FragmentGameRoomBinding
private lateinit var gameDelegate: GameDelegate
private var isShowMiniMic = false
override fun getRootLayoutId(): Int {
return R.layout.fragment_game_room
}
override fun onFindViews() {
super.onFindViews()
gameBinding = DataBindingUtil.bind(mView)!!
gameBinding.lifecycleOwner = this
gameBinding.click = this
gameBinding.ktvModel = false
gameDelegate = GameDelegate(
requireActivity(),
gameBinding.flGameContainer,
AvRoomDataManager.get().mCurrentRoomInfo?.mgId
)
gameDelegate.setOnGameStatusChangeListener(this)
gameBinding.rankWidget.setContentBackgroundResource(R.drawable.room_rank_widget_bg_game)
}
@SuppressLint("CheckResult")
override fun initiate() {
gameBinding.microView.bindAdapter(GameMicroViewAdapter(context))
super.initiate()
//游戏模式暂时不需要这个
PlayerModel.get().stop()
gameBinding.roomInfo = AvRoomDataManager.get().mCurrentRoomInfo
gameBinding.tvShowMiniMic.setOnClickListener { showMiniMic() }
gameBinding.ivShowMic.setOnClickListener { showMic() }
}
private fun showMiniMic() {
if (isShowMiniMic) return
isShowMiniMic = true
gameBinding.microView.bindAdapter(GameMiniMicroViewAdapter(context).apply {
setOnClick { showMic() }
})
gameBinding.tvShowMiniMic.isVisible = false
gameBinding.microView.postDelayed({
gameBinding.ivShowMic.isVisible = true
gameBinding.llMicView.setBackgroundResource(R.drawable.bg_mini_mic_entrance)
}, 100)
}
private fun showMic() {
if (!isShowMiniMic) return
isShowMiniMic = false
gameBinding.microView.bindAdapter(GameMicroViewAdapter(context))
gameBinding.tvShowMiniMic.isVisible = true
gameBinding.llMicView.background = null
gameBinding.ivShowMic.isVisible = false
}
override fun onSetListener() {
super.onSetListener()
bottomView.setBottomViewListener(BaseRoomBottomViewWrapper())
}
override fun updateView() {
super.updateView()
gameDelegate.updateGame(AvRoomDataManager.get().mCurrentRoomInfo?.mgId)
gameBinding.roomInfo = AvRoomDataManager.get().mCurrentRoomInfo
if (isSixMic()) {
gameBinding.tvShowMiniMic.isVisible = !isShowMiniMic
gameBinding.ivShowMic.isVisible = isShowMiniMic
} else {
showMic()
gameBinding.tvShowMiniMic.isInvisible = true
gameBinding.ivShowMic.isVisible = false
}
gameBinding.microView.adapter.notifyDataSetChanged()
}
override fun onGameStart() {
if (isSixMic()) {
showMiniMic()
}
}
override fun onGameEnd() {
if (isSixMic()) {
showMic()
}
}
private fun isSixMic(): Boolean {
return AvRoomDataManager.get().mgMicNum == AvRoomDataManager.GAME_DEF_MIC_COUNT
}
override fun onSendMsgSuccess(msg: String?) {
super.onSendMsgSuccess(msg)
msg?.let {
if (AvRoomDataManager.get().isSelfGamePlaying) {
gameDelegate.hitTheMark(msg)
}
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun onFinishAvRoomEvent(event: FinishAvRoomEvent) {
gameDelegate.exitGame()
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun onFirstRechargeEvent(event: FirstChargeEvent) {
// banner里可能有首充入口刷新下
gameBinding.bannerWidget.refreshData()
FirstChargePrizeDialog(
requireContext(),
event.chargeProdTitle,
event.firstChargeRewardList
).openDialog()
}
override fun onStart() {
super.onStart()
gameDelegate.onStart()
}
override fun onResume() {
super.onResume()
gameDelegate.onResume()
}
override fun onPause() {
super.onPause()
gameDelegate.onPause()
}
override fun onStop() {
super.onStop()
gameDelegate.onStop()
}
override fun onDestroy() {
gameDelegate.onDestroy()
super.onDestroy()
}
override fun initWidget() {
super.initWidget()
gameBinding.bannerWidget.disabledIndicator()
registerWidget(RedPackageWidget::class.java.simpleName, gameBinding.redPackageWidget)
registerWidget(RoomRankWidget::class.java.simpleName, gameBinding.rankWidget)
registerWidget(RoomBannerWidget::class.java.simpleName, gameBinding.bannerWidget)
}
}

View File

@@ -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;
@@ -35,14 +32,11 @@ import com.yizhuan.erban.avroom.activity.RoomOnlineUserActivity;
import com.yizhuan.erban.avroom.adapter.SelectGameAdapter;
import com.yizhuan.erban.avroom.dialog.ExitRoomPopupWindow;
import com.yizhuan.erban.avroom.widget.GiftV2View;
import com.yizhuan.erban.avroom.widget.RoomEffectView;
import com.yizhuan.erban.base.BaseFragment;
import com.yizhuan.erban.databinding.FragmentChatroomGameMainBinding;
import com.yizhuan.erban.friend.view.SelectFriendActivity;
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;
@@ -84,7 +78,6 @@ import cn.sharesdk.framework.Platform;
import io.reactivex.SingleObserver;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Action;
import kotlin.jvm.functions.Function0;
/**
* 轰趴房
@@ -105,7 +98,6 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
private ImageView ivRoomShare;
private GiftV2View giftView;
private ViewStub mVsGift2View;
private RoomEffectView mRoomEffectView;
private SVGAImageView svgaRoomBg;
private String[] bgPicture = new String[]{""};
@@ -119,7 +111,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();
@@ -187,7 +178,6 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
mIvGoodNumber = mView.findViewById(R.id.iv_good_number);
ivFollowRoom = mView.findViewById(R.id.iv_follow_room);
svgaRoomBg = mView.findViewById(R.id.svga_image_view_bg);
mRoomEffectView = mView.findViewById(R.id.room_effect_view);
}
/**
@@ -219,24 +209,6 @@ 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();
}
});
}
@SuppressLint("CheckResult")
@@ -372,28 +344,6 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
});
}
/**
* 获取礼物飘屏是否展示
*
* @return
*/
private boolean isShowingGiftNotify() {
if ((getActivity() instanceof AVRoomActivity)) {
return ((AVRoomActivity) getActivity()).isShowingGiftNotify();
}
return false;
}
public LiveData<Boolean> getPlayNotifyState(){
return playNotifyStateLiveData;
}
public boolean isShowingPlayNotify(){
if(playNotifyStateLiveData.getValue()==null) {
return false;
}
return playNotifyStateLiveData.getValue();
}
private void onReceiveLuckyGiftToMultiMsg(LuckyBagGifts giftMultiReceiverInfo) {
if (giftMultiReceiverInfo == null || !isResumed()) return;
@@ -455,9 +405,7 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
Fragment tempFragment = roomFragment;
switch (currentRoomInfo.getType()) {
case RoomInfo.ROOMTYPE_GAME:
if (!(tempFragment instanceof GameRoomFragment)) {
tempFragment = GameRoomFragment.newInstance();
}
toast(getString(R.string.room_game_is_not_open_yet));
break;
case RoomInfo.ROOM_TYPE_SINGLE:
if (!(tempFragment instanceof SingleRoomFragment)) {

View File

@@ -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;
@@ -67,6 +60,7 @@ import com.yizhuan.xchat_android_core.room.queuing_mic.bean.RespQueuingMicListIn
import com.yizhuan.xchat_android_core.room.queuing_mic.event.QueuingMicEmptyEvent;
import com.yizhuan.xchat_android_core.room.queuing_mic.event.QueuingMicNotEmptyEvent;
import com.yizhuan.xchat_android_core.super_admin.util.SuperAdminUtil;
import com.yizhuan.xchat_android_core.user.UserModel;
import com.yizhuan.xchat_android_core.utils.CurrentTimeUtils;
import com.yizhuan.xchat_android_library.base.factory.CreatePresenter;
import com.yizhuan.xchat_android_library.utils.ResUtil;
@@ -140,16 +134,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 +145,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())
@@ -468,7 +453,7 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
if (!microType.equals(BaseMicroViewAdapter.MICRO_TYPE_CP)) {
microView.bindAdapter(new CpMicroViewAdapter(mContext));
}
} else if (AvRoomDataManager.get().isDatingMode()) {
} else if (AvRoomDataManager.get().isDatingMode()) {
if (!microType.equals(BaseMicroViewAdapter.MICRO_TYPE_DATING)) {
microView.bindAdapter(new DatingMicroViewAdapter(mContext));
}
@@ -542,6 +527,7 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
}
}
@Override
public void onDestroy() {
if (mDisposable != null) {
@@ -612,7 +598,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 +782,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 +794,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 +962,18 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
return pkMicQueueDialog != null && pkMicQueueDialog.isShowing();
}
@Override
public void onShowBanner(List<BannerInfo> bannerInfos) {
initRoomAct(gameBinding.activityImg, bannerInfos, 11f);
AvRoomModel.get().getRoomActTimer(AvRoomDataManager.get().getRoomUid())
.compose(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
.subscribe();
}
@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 +1069,4 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
}
}
}
@Override
protected void onInitMusicPlayerView(@NonNull MusicPlayerView view) {
super.onInitMusicPlayerView(view);
view.linkIconView(gameBinding.ivMusic, gameBinding.ivMusic);
}
}

View File

@@ -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

View File

@@ -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,29 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
@SuppressLint("CheckResult")
override fun initiate() {
super.initiate()
mvpPresenter?.getBannerList()
initSpeedyMessage(gameBinding.flSpeedyMessage)
// UserModel.get().currentUserInfo
// .compose(bindToLifecycle())
// .subscribe { userInfo ->
// gameBinding.ivFirstChargeEnter.isVisible = userInfo.isFirstCharge
// }
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 +113,7 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
}
}
gameBinding.layoutHourRank.setOnClickListener {
gameBinding.tvHourRank.setOnClickListener {
DialogWebViewActivity.start(
mContext,
UriProvider.getSingleRoomHourRankUrl(AvRoomDataManager.get().roomUid)
@@ -105,10 +124,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 +143,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 +156,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 +164,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 +234,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 +253,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 +267,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)
}
}

View File

@@ -1,15 +0,0 @@
/*
Copyright © Sud.Tech
https://sud.tech
*/
package com.yizhuan.erban.avroom.game;
import com.yizhuan.xchat_android_library.BuildConfig;
public class AppConfig {
protected static final String APP_ID = "1578948593831571457";
protected static final String APP_KEY = "J9lHOXvFWkAZiTfl4SK7IGt0wDnW3fWd";
protected static boolean isTestEnv = BuildConfig.DEBUG;
}

View File

@@ -1,676 +0,0 @@
package com.yizhuan.erban.avroom.game
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.os.Handler
import android.os.Looper
import android.text.TextUtils
import android.util.Log
import android.view.View
import android.view.ViewTreeObserver.OnGlobalLayoutListener
import android.widget.FrameLayout
import com.google.gson.Gson
import com.yizhuan.erban.R
import com.yizhuan.xchat_android_core.auth.AuthModel
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
import com.yizhuan.xchat_android_core.room.game.GameCfg
import com.yizhuan.xchat_android_core.room.game.GameModel
import com.yizhuan.xchat_android_core.room.game.GameStatus
import com.yizhuan.xchat_android_core.room.model.HomePartyModel
import com.yizhuan.xchat_android_core.user.UserModel
import com.yizhuan.xchat_android_core.utils.LogUtils
import com.yizhuan.xchat_android_core.utils.net.RxHelper
import com.yizhuan.xchat_android_library.net.rxnet.callback.CallBack
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
import okhttp3.*
import org.json.JSONException
import org.json.JSONObject
import tech.sud.mgp.core.*
import java.util.*
class GameDelegate(val activity: Activity, val container: FrameLayout, var mgId: Long?) {
private val TAG = "GameDelegate"
private var APP_CODE = ""
private val mRoomID :String get() = AvRoomDataManager.get().roomUid.toString()
private val mLanguage = "zh-TW" //語言
//調用遊戲SDK的接口,成功加載遊戲後可用:
private var iSudFSTAPP: ISudFSTAPP? = null
private val gson = Gson()
//小遊戲ID
private var mMGID = 0L
//通用狀態-遊戲,關鍵詞
private var mKeyWord: String? = null
private val mUid = AuthModel.get().currentUid.toString()
private val homePartyModel = HomePartyModel()
private var onGameStatusChangeListener: OnGameStatusChangeListener? = null
fun setOnGameStatusChangeListener(onGameStatusChangeListener: OnGameStatusChangeListener) {
this.onGameStatusChangeListener = onGameStatusChangeListener
}
private val loginCallback: AppLoginListener =
object : AppLoginListener {
override fun onLoginFailure(err: String?) {
SingleToastUtil.showToast(err)
}
override fun onLoginSuccess(new_code: String, expire_Date: Long) {
APP_CODE = new_code
Handler(Looper.getMainLooper()).post {
//初始化遊戲SDK
initGameSDK(
activity,
AppConfig.APP_ID,
AppConfig.APP_KEY,
AppConfig.isTestEnv
)
}
}
}
init {
mMGID = mgId ?: 0L
login(loginCallback)
}
fun updateGame(mgId: Long?) {
if (mgId == null || mgId == 0L) return
if (mgId == mMGID && iSudFSTAPP != null) {
return
}
mMGID = mgId
updateMyMicQueue(GameStatus.STATUS_NOT_JOIN)
loadMG(activity, mUid, mRoomID, APP_CODE, mMGID, mLanguage)
}
fun exitGame() {
UserModel.get().cacheLoginUserInfo?.gameStatus = GameStatus.STATUS_NOT_JOIN
notifySelfPlayingState(false)
notifySelfInState(false)
}
/**
* 例如"你畫我猜"遊戲的文字命中
*/
fun hitTheMark(msg: String) {
mKeyWord?.let {
if (msg.contains(it)) {
notifySelfTextHit(it, msg)
}
}
}
/**
* "接入方客戶端"登陸接口, 從"接入方服務端"獲得Code
* "接入方服務端"是通過"服務端接入SDK"獲得Code來返回給"接入方客戶端"的
* @param listener
*/
@SuppressLint("CheckResult")
private fun login(listener: AppLoginListener) {
GameModel.getGameCode()
.compose(RxHelper.bindContext(activity))
.subscribe({
listener.onLoginSuccess(it.code, it.expireDate)
}, {
listener.onLoginFailure(it.message)
})
}
/**
* 1初始化遊戲SDK
*
* @param context 上下文
* @param appID appID
* @param appKey appKey
* @param isTestEnv 是否是測試環境true測試環境false正式環境
*/
private fun initGameSDK(context: Context, appID: String, appKey: String, isTestEnv: Boolean) {
SudMGP.initSDK(context, appID, appKey, isTestEnv, object : ISudListenerInitSDK {
override fun onSuccess() {
loadMG(activity, mUid, mRoomID, APP_CODE, mMGID, mLanguage)
}
override fun onFailure(code: Int, errInfo: String) {
showToast("初始化遊戲SDK失敗:$code--errInfo:$errInfo")
}
})
}
/**
* 2加載遊戲
*
* @param activity 上下文Activity
* @param userID 用戶ID業務系統保證每個用戶擁有唯一ID
* @param roomID 房間ID進入同一房間內的
* @param code 令牌
* @param mgID 小遊戲ID
* @param language 遊戲語言 現支持簡體zh-CN 繁體zh-TW 英語en-US 馬來語ms-MY
*/
private fun loadMG(
activity: Activity,
userID: String,
roomID: String,
code: String,
mgID: Long,
language: String
) {
iSudFSTAPP?.destroyMG()
iSudFSTAPP = SudMGP.loadMG(activity, userID, roomID, code, mgID, language, mISudFSMMG)
iSudFSTAPP?.apply {
addGameView(gameView)
}
}
/**
* 3將遊戲view添加到我們的布局當中
*
* @param gameView
*/
private fun addGameView(gameView: View) {
container.removeAllViews()
container.addView(gameView)
}
private fun showToast(content: String?) {
SingleToastUtil.showToast(content)
}
/**
* 通知"文字命中狀態"到遊戲端
*
* @param iSudFSTAPP
* @param keyWord
*/
private fun notifySelfTextHit(keyWord: String?, msg: String) {
LogUtils.d("notifySelfTextHit")
try {
//狀態名稱
val state: String = SudMGPAPPState.APP_COMMON_SELF_TEXT_HIT
//狀態數據
val jsonObject = JSONObject()
jsonObject.put("isHit", true) // true 命中false 未命中
jsonObject.put("keyWord", keyWord) // true 命中false 未命中
jsonObject.put("text", msg) // 聊天原始內容,這裏的值只是一個示例,意指內容當中包含關鍵詞則命中,具體按業務規則定。
val dataJson = jsonObject.toString()
//調用接口
iSudFSTAPP?.notifyStateChange(state, dataJson, null)
} catch (e: Exception) {
e.printStackTrace()
}
}
/**
* 設置當前關鍵詞
*
* @param keyWord
*/
private fun setKeyWord(keyWord: String?) {
mKeyWord = keyWord
}
/**
* 遊戲SDK調用app的接口
*/
private val mISudFSMMG: ISudFSMMG = object : ISudFSMMG {
override fun onGameLog(p0: String?) {
LogUtils.d(p0)
}
override fun onGameLoadingProgress(p0: Int, p1: Int, p2: Int) {
}
override fun onGameStarted() {
}
override fun onGameDestroyed() {
}
/**
* 回調此方法表示令牌過期此時需要刷新令牌並使用ISudFSMStateHandle回調
* @param handle
* @param dataJson
*/
override fun onExpireCode(handle: ISudFSMStateHandle, dataJson: String) {
login(object : AppLoginListener {
override fun onLoginFailure(err: String?) {
}
override fun onLoginSuccess(new_code: String, expire_Date: Long) {
APP_CODE = new_code
try {
val jsonObject = JSONObject()
jsonObject.put("ret_code", 0)
jsonObject.put("ret_msg", "success")
handle.success(jsonObject.toString())
} catch (e: JSONException) {
e.printStackTrace()
}
iSudFSTAPP?.updateCode(APP_CODE, null)
}
})
}
/**
* 處理獲取遊戲視圖信息
* @param handle
* @param dataJson
*/
override fun onGetGameViewInfo(handle: ISudFSMStateHandle, dataJson: String) {
//拿到遊戲View的寬高
val gameViewWidth = container.measuredWidth
val gameViewHeight = container.measuredHeight
if (gameViewWidth > 0 && gameViewHeight > 0) {
notifyGameViewInfo(handle, gameViewWidth, gameViewHeight)
return
}
//如果遊戲View未加載完成則監聽加載完成時回調
container.viewTreeObserver.addOnGlobalLayoutListener(object : OnGlobalLayoutListener {
override fun onGlobalLayout() {
container.viewTreeObserver.removeOnGlobalLayoutListener(this)
val width = container.measuredWidth
val height = container.measuredHeight
notifyGameViewInfo(handle, width, height)
}
})
}
override fun onGetGameCfg(handle: ISudFSMStateHandle?, p1: String?) {
handle?.success(gson.toJson(GameCfg()))
}
/**
* 通知遊戲,遊戲視圖信息
* @param handle
* @param gameViewWidth
* @param gameViewHeight
*/
private fun notifyGameViewInfo(
handle: ISudFSMStateHandle,
gameViewWidth: Int,
gameViewHeight: Int
) {
try {
val jsonObject = JSONObject()
jsonObject.put("ret_code", 0)
jsonObject.put("ret_msg", "success")
//遊戲View大小
val viewSize = JSONObject()
viewSize.put("width", gameViewWidth)
viewSize.put("height", gameViewHeight)
jsonObject.put("view_size", viewSize)
//遊戲安全操作區域
val viewGameRect = JSONObject()
viewGameRect.put("left", 0)
viewGameRect.put("top", container.context.resources.getDimensionPixelOffset(R.dimen.dp_180))
viewGameRect.put("right", 0)
viewGameRect.put("bottom", container.context.resources.getDimensionPixelOffset(R.dimen.dp_150))
jsonObject.put("view_game_rect", viewGameRect)
//通知遊戲
val json = jsonObject.toString()
Log.d(TAG, "notifyGameViewInfo:$json")
handle.success(json)
} catch (e: JSONException) {
e.printStackTrace()
}
}
/**
* 遊戲狀態變化
* @param handle
* @param state 狀態名
* @param dataJson 狀態數據json字符串
*/
override fun onGameStateChange(
handle: ISudFSMStateHandle,
state: String,
dataJson: String
) {
Log.d(TAG, "onGameStateChange state:$state--dataJson:$dataJson")
when (state) {
//SudMGPMGState.MG_COMMON_PUBLIC_MESSAGE -> showToast("遊戲:公屏消息")
SudMGPMGState.MG_COMMON_KEY_WORD_TO_HIT -> {
if (TextUtils.isEmpty(dataJson)) {
setKeyWord(null)
} else {
try {
val jsonObject = JSONObject(dataJson)
if (jsonObject.isNull("word")) {
setKeyWord(null)
} else {
val keyWord = jsonObject.getString("word")
setKeyWord(keyWord)
}
} catch (e: Exception) {
e.printStackTrace()
}
}
}
SudMGPMGState.APP_COMMON_SELF_CLICK_JOIN_BTN -> {
try {
val jsonObject = JSONObject(dataJson)
val seatIndex = jsonObject.optInt("seatIndex", -1)
updateMyMicQueue(GameStatus.STATUS_NOT_READY, true, seatIndex)
} catch (e: Exception) {
e.printStackTrace()
}
}
SudMGPMGState.APP_COMMON_SELF_CLICK_START_BTN -> {
notifySelfPlayingState(true)
}
SudMGPMGState.MG_COMMON_GAME_STATE -> handleGameState(dataJson)
}
}
/**
* 玩家狀態變化
* @param handle
* @param userId 玩家用戶ID
* @param state 狀態名
* @param dataJson 狀態數據json字符串。參考文檔
*/
override fun onPlayerStateChange(
handle: ISudFSMStateHandle,
userId: String,
state: String,
dataJson: String
) {
Log.d(TAG, "onPlayerStateChange userId:$userId--state:$state--dataJson:$dataJson")
when (state) {
SudMGPMGState.MG_COMMON_PLAYER_IN -> handlePlayerIn(userId, dataJson)
SudMGPMGState.MG_COMMON_PLAYER_READY -> handlePlayerReady(userId, dataJson)
SudMGPMGState.MG_COMMON_PLAYER_CAPTAIN -> handlePlayerCaptain(dataJson)
SudMGPMGState.MG_COMMON_PLAYER_PLAYING -> handlePlayerPlaying(userId, dataJson)
}
}
}
private fun handlePlayerIn(userId: String, dataJson: String) {
if (userId != mUid) return
try {
val jsonObject = JSONObject(dataJson)
val retCode = jsonObject.getInt("retCode")
val isIn = jsonObject.getBoolean("isIn")
if (retCode != 0) {
return
}
if (isIn) { // 已加入
if (AvRoomDataManager.get().isRoomOwner) {
notifySelfCaptainState(mUid)
}
} else { // 未加入
var reason = 0
if (jsonObject.has("reason")) {
reason = jsonObject.getInt("reason")
}
if (reason == 0) {
updateMyMicQueue(GameStatus.STATUS_NOT_JOIN)
} else if (reason == 1) {
updateMyMicQueue(GameStatus.STATUS_NOT_JOIN)
}
}
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun updateMyMicQueue(gameStatus: Int, isJoin: Boolean = false, seatIndex: Int = -1) {
UserModel.get().cacheLoginUserInfo?.gameStatus = gameStatus
val position = AvRoomDataManager.get().getMicPosition(mUid)
if (position != AvRoomDataManager.POSITON_NOT_ON_MIC) {
if (isJoin) notifySelfInState(true, seatIndex)
homePartyModel.updateMyMicQueue(
position,
AvRoomDataManager.get().roomId.toString(),
UserModel.get().cacheLoginUserInfo
).subscribe()
} else if (isJoin) {
val upPosition = AvRoomDataManager.get().findGamePosition()
if (upPosition == Int.MIN_VALUE) {
showToast("當前遊戲人數已滿!")
} else {
UserModel.get().cacheLoginUserInfo?.gameStatus = 1
homePartyModel.upMicroPhone(upPosition,
mUid,
AvRoomDataManager.get().roomId.toString(),
false, object : CallBack<String> {
override fun onSuccess(data: String?) {
notifySelfInState(true, seatIndex)
}
override fun onFail(code: Int, error: String?) {
showToast(error)
}
})
}
}
}
private fun handlePlayerReady(userId: String, dataJson: String) {
if (userId != mUid) return
try {
val jsonObject = JSONObject(dataJson)
val retCode = jsonObject.getInt("retCode")
val isReady = jsonObject.getBoolean("isReady")
if (retCode != 0) {
return
}
updateMyMicQueue(if (isReady) GameStatus.STATUS_READY else GameStatus.STATUS_NOT_READY)
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun handlePlayerCaptain(dataJson: String) {
try {
val jsonObject = JSONObject(dataJson)
val retCode = jsonObject.getInt("retCode")
if (retCode != 0) {
return
}
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun handleGameState(dataJson: String) {
try {
val jsonObject = JSONObject(dataJson)
val gameState = jsonObject.getInt("gameState")
if (gameState == 0) {
onGameStatusChangeListener?.onGameEnd()
} else if (gameState == 2) {
onGameStatusChangeListener?.onGameStart()
}
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun handlePlayerPlaying(userId: String, dataJson: String) {
if (userId != mUid) return
try {
val jsonObject = JSONObject(dataJson)
val retCode = jsonObject.getInt("retCode")
if (retCode != 0) {
return
}
val isPlaying = jsonObject.getBoolean("isPlaying")
if (isPlaying) {
updateMyMicQueue(GameStatus.STATUS_PLAYING)
} else {
updateMyMicQueue(GameStatus.STATUS_NOT_READY)
}
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun notifySelfInState(isIn: Boolean, seatIndex: Int = -1) {
try {
if (!isIn) {
notifySelfReadyState(false)
}
//狀態名稱
val state = SudMGPAPPState.APP_COMMON_SELF_IN
//狀態數據
val jsonObject = JSONObject()
jsonObject.put("isIn", isIn) // true 加入遊戲false 退出遊戲
if (seatIndex != -1) {
jsonObject.put("seatIndex", seatIndex)
}
jsonObject.put("teamId", 1) //哪一隊伍(2v2,4v4)
val dataJson = jsonObject.toString()
//調用接口
iSudFSTAPP?.notifyStateChange(state, dataJson, null)
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun notifySelfReadyState(isReady: Boolean) {
try {
//狀態名稱
val state = SudMGPAPPState.APP_COMMON_SELF_READY
//狀態數據
val jsonObject = JSONObject()
jsonObject.put("isReady", isReady) // true 準備false 取消準備
val dataJson = jsonObject.toString()
//調用接口
iSudFSTAPP?.notifyStateChange(state, dataJson, null)
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun notifySelfPlayingState(isPlaying: Boolean) {
try {
//狀態名稱
val state = SudMGPAPPState.APP_COMMON_SELF_PLAYING
//狀態數據
val jsonObject = JSONObject()
jsonObject.put("isPlaying", isPlaying) // true 開始遊戲false 結束遊戲
val dataJson = jsonObject.toString()
//調用接口
iSudFSTAPP?.notifyStateChange(state, dataJson, null)
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun notifySelfCaptainState(uid: String) {
try {
//狀態名稱
val state = SudMGPAPPState.APP_COMMON_SELF_CAPTAIN
//狀態數據
val jsonObject = JSONObject()
jsonObject.put("curCaptainUID", uid) // 必填指定隊長uid
val dataJson = jsonObject.toString()
//調用接口
iSudFSTAPP?.notifyStateChange(state, dataJson, null)
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun notifySelfKickState(uid: String) {
try {
//狀態名稱
val state = SudMGPAPPState.APP_COMMON_SELF_KICK
//狀態數據
val jsonObject = JSONObject()
jsonObject.put("kickedUID", uid) // 被踢用戶uid
val dataJson = jsonObject.toString()
//調用接口
iSudFSTAPP?.notifyStateChange(state, dataJson, null)
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun notifySelfEndState() {
try {
//狀態名稱
val state = SudMGPAPPState.APP_COMMON_SELF_END
//狀態數據
val jsonObject = JSONObject()
val dataJson = jsonObject.toString()
//調用接口
iSudFSTAPP?.notifyStateChange(state, dataJson, null)
} catch (e: Exception) {
e.printStackTrace()
}
}
fun onStart() {
iSudFSTAPP?.startMG() //啟動遊戲
}
fun onResume() {
iSudFSTAPP?.playMG() //開始遊戲
}
fun onPause() {
iSudFSTAPP?.pauseMG() //暫停遊戲
}
fun onStop() {
iSudFSTAPP?.stopMG() //停止遊戲
}
fun onDestroy() {
updateMyMicQueue(GameStatus.STATUS_NOT_JOIN)
iSudFSTAPP?.destroyMG()
}
}
internal interface AppLoginListener {
/**
* App Server 登陸失敗, App Server 不能返回CODE
*/
fun onLoginFailure(err: String?)
/**
* App Server 登陸成功, App Server調用服務端接入SDK的API獲取Code 返回給 App
* App 就要用CODE和自己生成的UserID去調用SDK的初始化函數登陸小遊戲
* 小遊戲登陸成功後其UserID就是App傳的UserID
*/
fun onLoginSuccess(new_code: String, expire_Date: Long)
}

View File

@@ -1,13 +0,0 @@
package com.yizhuan.erban.avroom.game
interface OnGameStatusChangeListener {
/**
* 游戏开始
*/
fun onGameStart()
/**
* 游戏结束
*/
fun onGameEnd()
}

View File

@@ -1,61 +0,0 @@
/*
Copyright © Sud.Tech
https://sud.tech
*/
package com.yizhuan.erban.avroom.game;
/**
* Time:2021/10/19
* Description: APP to MG 的状态定义
*/
public class SudMGPAPPState {
// region 通用状态
/**
* 加入状态
* 最低版本: v1.1.30.xx
*/
public static final String APP_COMMON_SELF_IN = "app_common_self_in";
/**
* 准备状态
* 最低版本: v1.1.30.xx
*/
public static final String APP_COMMON_SELF_READY = "app_common_self_ready";
/**
* 游戏状态
* 最低版本: v1.1.30.xx
*/
public static final String APP_COMMON_SELF_PLAYING = "app_common_self_playing";
/**
* 队长状态
* 最低版本: v1.1.30.xx
*/
public static final String APP_COMMON_SELF_CAPTAIN = "app_common_self_captain";
/**
* 踢人
* v1.1.30.xx
*/
public static final String APP_COMMON_SELF_KICK = "app_common_self_kick";
/**
* 结束游戏
* v1.1.30.xx
*/
public static final String APP_COMMON_SELF_END = "app_common_self_end";
/**
* 麦克风状态
*/
public static final String APP_COMMON_SELF_MICROPHONE = "app_common_self_microphone";
/**
* 文字命中状态
*/
public static final String APP_COMMON_SELF_TEXT_HIT = "app_common_self_text_hit";
}

View File

@@ -1,125 +0,0 @@
/*
Copyright © Sud.Tech
https://sud.tech
*/
package com.yizhuan.erban.avroom.game;
/**
* Time:2021/10/19
* Description: MG to APP 的状态定义
*/
public class SudMGPMGState {
// region 通用状态-游戏
/**
* 公屏消息 (已修改)
* 最低版本: v1.1.30.xx
*/
public static final String MG_COMMON_PUBLIC_MESSAGE = "mg_common_public_message";
/**
* 关键词状态
*/
public static final String MG_COMMON_KEY_WORD_TO_HIT = "mg_common_key_word_to_hit";
// endregion 通用状态-游戏
// region 通用状态-玩家
/**
* 加入状态 (已修改)
* 最低版本: v1.1.30.xx
*/
public static final String MG_COMMON_PLAYER_IN = "mg_common_player_in";
/**
* 准备状态 (已修改)
* 最低版本: v1.1.30.xx
*/
public static final String MG_COMMON_PLAYER_READY = "mg_common_player_ready";
/**
* 队长状态 (已修改)
* 最低版本: v1.1.30.xx
*/
public static final String MG_COMMON_PLAYER_CAPTAIN = "mg_common_player_captain";
/**
* 游戏状态 (已修改)
* 最低版本: v1.1.30.xx
*/
public static final String MG_COMMON_PLAYER_PLAYING = "mg_common_player_playing";
/**
* 游戏状态(已修改)
* 最低版本: v1.1.30.xx
*/
public static final String MG_COMMON_GAME_STATE = "mg_common_game_state";
// endregion 通用状态-玩家
// region 碰碰我最强
// endregion 碰碰我最强
// region 飞刀达人
// endregion 飞刀达人
// region 你画我猜
/**
* 选词中
*/
public static final String MG_DG_SELECTING = "mg_dg_selecting";
/**
* 作画中
*/
public static final String MG_DG_PAINTING = "mg_dg_painting";
/**
* 错误答案
*/
public static final String MG_DG_ERRORANSWER = "mg_dg_erroranswer";
/**
* 总积分
*/
public static final String MG_DG_TOTALSCORE = "mg_dg_totalscore";
/**
* 本次积分
*/
public static final String MG_DG_SCORE = "mg_dg_score";
// endregion 你画我猜
/**
* 加入游戏按钮点击状态
*/
public static final String APP_COMMON_SELF_CLICK_JOIN_BTN = "mg_common_self_click_join_btn";
/**
* 取消加入游戏按钮点击状态
*/
public static final String APP_COMMON_SELF_CLICK_CANCEL_JOIN_BTN = "mg_common_self_click_cancel_join_btn";
/**
* 准备按钮点击状态
*/
public static final String APP_COMMON_SELF_CLICK_READY_BTN = "mg_common_self_click_ready_btn";
/**
* 取消准备按钮点击状态
*/
public static final String APP_COMMON_SELF_CLICK_CANCEL_READY_BTN = "mg_common_self_click_cancel_ready_btn";
/**
* 开始游戏按钮点击状态
*/
public static final String APP_COMMON_SELF_CLICK_START_BTN = "mg_common_self_click_start_btn";
/**
* 分享按钮点击状态
*/
public static final String APP_COMMON_SELF_CLICK_SHARE_BTN = "mg_common_self_click_share_btn";
}

View File

@@ -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)
}
}

View File

@@ -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()
}
}
}

View File

@@ -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
}
}

View File

@@ -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)
}
}

View File

@@ -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));
}
}
@@ -495,6 +482,7 @@ public class AvRoomPresenter extends BaseMvpPresenter<IAvRoomView> {
public void onNext(Long aLong) {
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
if (roomInfo == null) return;
Log.d(TAG, "onNext: roomInfo in startGetOnlineMemberNumberJob: " + roomInfo);
Log.d(TAG, "onNext: has login in IM: " + AuthModel.get().isImLogin());
Disposable subscribe = mAvRoomModel.startGetOnlineMemberNumberJob(roomInfo.getRoomId())
.observeOn(AndroidSchedulers.mainThread())

View File

@@ -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

View File

@@ -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,29 @@ 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);
}
List<BannerInfo> finalBannerInfos = bannerInfos;
GoldBoxHelper.isHideBox()
.subscribe(isHide -> {
if (!isHide) {
BannerInfo bannerInfo = new BannerInfo();
bannerInfo.setBox(true);
finalBannerInfos.add(firstCharge ? 1 : 0, bannerInfo);
}
getMvpView().onShowBanner(finalBannerInfos);
}, throwable -> getMvpView().onShowBanner(finalBannerInfos));
});
}
}

View File

@@ -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;
@@ -53,12 +55,12 @@ public class HomePartyPresenter extends BaseRoomPresenter<IHomePartyView> {
private boolean isLeaveMode = false;
/**
* 上
* 上
*
* @param micPosition
* @param uId
* @param isInviteUpMic 是否是主false
* @param isReconnect 是否需要清除物值,普通情下上麥傳false斷網重連傳ture
* @param isInviteUpMic 是否是主false
* @param isReconnect 是否需要清除物值,普通情下上麦传false断网重连传ture
*/
public void upMicroPhone(final int micPosition, final String uId, boolean isInviteUpMic, boolean isReconnect) {
final RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
@@ -87,7 +89,7 @@ public class HomePartyPresenter extends BaseRoomPresenter<IHomePartyView> {
upMicroPhone(micPosition, uId, isInviteUpMic, roomInfo, false);
}
//isGiven上次是否常退出
//isGiven上次是否常退出
public void sendDragonBar(FaceInfo faceInfo, String point, boolean isGiven) {
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
if (roomInfo == null) return;
@@ -148,7 +150,7 @@ public class HomePartyPresenter extends BaseRoomPresenter<IHomePartyView> {
faceReceiveInfo.setResultIndexes(integers);
faceReceiveInfos.add(faceReceiveInfo);
// 發送雲信信息所有人
// 发送云信信息所有人
FaceAttachment faceAttachment =
new FaceAttachment(CustomAttachment.CUSTOM_MSG_DRAGON_BAR, second);
faceAttachment.setUid(userInfo.getUid());
@@ -157,7 +159,7 @@ public class HomePartyPresenter extends BaseRoomPresenter<IHomePartyView> {
return ChatRoomMessageBuilder.createChatRoomCustomMessage(
// 聊天室id
roomInfo.getRoomId() + "",
// 自定消息
// 自定消息
faceAttachment
);
}
@@ -176,13 +178,13 @@ public class HomePartyPresenter extends BaseRoomPresenter<IHomePartyView> {
if (chatRoomMessage != null) {
if (chatRoomMessage.getMsgType() == MsgTypeEnum.custom) {
CustomAttachment attachment = (CustomAttachment) chatRoomMessage.getAttachment();
// 顯示錶情在對應的位置
// 显示表情在对应的位置
if (attachment.getFirst() == CustomAttachment.CUSTOM_MSG_DRAGON_BAR) {
FaceAttachment faceAttachment = (FaceAttachment) attachment;
List<FaceReceiveInfo> faceReceiveInfos = faceAttachment.getFaceReceiveInfos();
if (faceReceiveInfos != null && faceReceiveInfos.size() > 0) {
// 显示動畫
// 显示动画
IMNetEaseManager.get().getChatRoomEventObservable()
.onNext(new RoomEvent().setEvent(RoomEvent.DRAGON_BAR_SELF_START).setChatRoomMessage(chatRoomMessage));
}
@@ -213,16 +215,16 @@ public class HomePartyPresenter extends BaseRoomPresenter<IHomePartyView> {
/**
* 本地更新房主位信息或者關閉離線模式
* 本地更新房主位信息或者关闭离线模式
*/
@SuppressWarnings("CheckResult")
public void leaveModeCheck() {
isLeaveMode = AvRoomDataManager.get().isLeaveMode(); // 進房緩存離線模式狀態
isLeaveMode = AvRoomDataManager.get().isLeaveMode(); // 进房缓存离线模式状态
if (!AvRoomDataManager.get().isCpRoom() && !AvRoomDataManager.get().isOpenKTV()) {
RoomQueueInfo queueInfo = AvRoomDataManager.get().getRoomQueueMemberInfoByMicPosition(-1);
// 新版管理首次房,如果房主位有人,且房間是離開模式,需要調用接口關閉離開模式(提高關閉離開模式的率)
// 新版管理首次房,如果房主位有人,且房间是离开模式,需要用接口关闭离开模式(提高关闭离开模式的率)
if (AvRoomDataManager.get().isManager()) {
if (queueInfo != null) {
@@ -243,7 +245,7 @@ public class HomePartyPresenter extends BaseRoomPresenter<IHomePartyView> {
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
int position = AvRoomDataManager.get().getMicPosition(AvRoomDataManager.get().getRoomUid());
if (roomInfo != null && roomInfo.isLeaveMode() && micPosition == position) {
// 新版由管理和房主位上麥用戶共同調接口關閉離開模式(提高關閉離開模式成功率,降低接口調用頻率);
// 新版由管理和房主位上麦用户共同接口关闭离开模式(提高关闭离开模式成功率,降低接口调用频率);
if (AvRoomDataManager.get().isManager() || String.valueOf(AuthModel.get().getCurrentUid()).equals(account)) {
new RoomSettingModel().leaveModeClose(roomInfo.getUid()).subscribe(new BeanObserver<String>() {
@Override
@@ -271,7 +273,7 @@ public class HomePartyPresenter extends BaseRoomPresenter<IHomePartyView> {
isLeaveMode = AvRoomDataManager.get().isLeaveMode();
if (!isLeaveMode && AvRoomDataManager.get().isShowGiftValue()) // 物值模式下關閉離開模式,本地清除物值
if (!isLeaveMode && AvRoomDataManager.get().isShowGiftValue()) // 物值模式下关闭离开模式,本地清除物值
GiftValueMrg.get().handleDownMic(-1, String.valueOf(AvRoomDataManager.get().getRoomUid()));
}
@@ -295,4 +297,44 @@ 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 (firstCharge) {
BannerInfo bannerInfo = new BannerInfo();
bannerInfo.setFirstCharge(true);
bannerInfos.add(0, bannerInfo);
}
getMvpView().onShowBanner(bannerInfos);
}
});
}
}

View File

@@ -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);
});
}
}

View File

@@ -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;

View File

@@ -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,45 @@ 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 (firstCharge) {
BannerInfo bannerInfo = new BannerInfo();
bannerInfo.setFirstCharge(true);
bannerInfos.add(0, bannerInfo);
}
getMvpView().onShowBanner(bannerInfos);
}
});
}
}

View File

@@ -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)
}
}

View File

@@ -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
}
}
}

View File

@@ -42,15 +42,15 @@ class RedPackageGoRoomDialog : BaseDialog<DialogRedPackageGoRoomBinding>() {
override fun init() {
AnimationUtils.loadAnimation(context, R.anim.anim_all_red_package).apply {
binding?.clRed?.animation = this
binding.clRed.animation = this
start()
}
AnimationUtils.loadAnimation(context, R.anim.anim_all_red_package_in_btn).let {
binding?.ivGoRoom?.animation = it
binding.ivGoRoom.animation = it
it.start()
}
binding?.ivClose?.setOnClickListener { dismissAllowingStateLoss() }
binding?.ivGoRoom?.setOnClickListener {
binding.ivClose.setOnClickListener { dismissAllowingStateLoss() }
binding.ivGoRoom.setOnClickListener {
val jump = {
AVRoomActivity.start(context, redPackageNotifyInfo.roomUid,
AVRoomActivity.FROM_TYPE_ALL_RED, redPackageNotifyInfo.sendUserNick, redPackageNotifyInfo)
@@ -69,10 +69,10 @@ class RedPackageGoRoomDialog : BaseDialog<DialogRedPackageGoRoomBinding>() {
}
redPackageNotifyInfo.let {
ImageLoadUtils.loadAvatar(context, it.sendUserAvatar, binding?.ivAvatar)
binding?.tvContent?.text = it.redEnvelopeMessage
binding?.tvNickname?.text = it.sendUserNick.subAndReplaceDot()
binding?.tvRoomName?.text = it.roomTitle.subAndReplaceDot()
ImageLoadUtils.loadAvatar(context, it.sendUserAvatar, binding.ivAvatar)
binding.tvContent.text = it.redEnvelopeMessage
binding.tvNickname.text = it.sendUserNick.subAndReplaceDot()
binding.tvRoomName.text = it.roomTitle.subAndReplaceDot()
}
// StatUtil.onEvent("gethongbao", ResUtil.getString(R.string.avroom_redpackage_redpackagegoroomdialog_03))
}

View File

@@ -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)
}
}
}

View File

@@ -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)
}
}
}
}

View File

@@ -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()
}
}

View File

@@ -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()
}
}

View File

@@ -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()
}
}
}

View File

@@ -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
)
}
}
}

View File

@@ -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
}
}

View File

@@ -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
}
}

View File

@@ -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
}
}

View File

@@ -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()
}
}

View File

@@ -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)
}
}

View File

@@ -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) {
}
}
}

View File

@@ -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)
}
}

View File

@@ -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
}
}

Some files were not shown because too many files have changed in this diff Show More