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
919 changed files with 6231 additions and 37396 deletions

View File

@@ -21,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
@@ -48,21 +48,12 @@ 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}_${abi}_${date}.apk"
}
}
lintOptions {
@@ -148,20 +139,19 @@ android {
}
buildTypes {
def server_url_debug = '"http://beta.api.pekolive.com/"'
def server_url_release = '"https://api.pekolive.com/"'
debug {
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
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")) {
@@ -179,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"
@@ -297,7 +287,6 @@ dependencies {
//wheelView
implementation 'com.contrarywind:wheelview:4.1.0'
implementation 'tech.sud.mgp:SudMGP-static:1.3.3.1158'
}
channel {
@@ -305,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

@@ -233,7 +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.** {*;}
#百度统计

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"
@@ -982,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"
@@ -1015,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"
@@ -1036,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"
@@ -1046,7 +1018,6 @@
</intent-filter>
</receiver>
<receiver android:name=".reciever.NotificationClickReceiver" />
<service
android:name="com.netease.nimlib.service.NimService"
android:process=":core" />
@@ -1061,31 +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>
</application>
</manifest>

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

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

@@ -48,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;
@@ -161,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;
//生命周期监听
@@ -417,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);
@@ -507,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);

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,17 +2,10 @@ package com.yizhuan.erban.avroom.activity;
import static android.view.View.VISIBLE;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_BOX;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAIRY;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ROOM_PK;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_GIFT_L5;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_ROOM_PK_NOTIFY;
import android.annotation.SuppressLint;
@@ -97,20 +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.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;
@@ -140,7 +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.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;
@@ -164,7 +145,6 @@ import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import io.reactivex.Single;
@@ -323,8 +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);
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) {
@@ -431,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())
@@ -1196,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<>();
}
@@ -1221,72 +1204,8 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
}
}
break;
case CUSTOM_MSG_BOX://寻爱之旅
if (baseProtocol.getSecond() == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
RoomBoxPrizeAttachment roomBoxPrizeAttachment = new RoomBoxPrizeAttachment(CUSTOM_MSG_BOX, CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA);
RoomBoxPrizeInfo roomBoxPrizeBean = JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomBoxPrizeInfo.class);
roomBoxPrizeAttachment.setUid(roomBoxPrizeBean.getUid());
roomBoxPrizeAttachment.setPrizeName(roomBoxPrizeBean.getPrizeName());
roomBoxPrizeAttachment.setNick(roomBoxPrizeBean.getNick());
roomBoxPrizeAttachment.setBoxTypeStr(roomBoxPrizeBean.getBoxTypeStr());
roomBoxPrizeAttachment.setRoomUid(roomBoxPrizeBean.getRoomUid());
roomBoxPrizeAttachment.setPrizeNum(roomBoxPrizeBean.getPrizeNum());
roomBoxPrizeAttachment.setUserLevelLimit(roomBoxPrizeBean.getUserLevelLimit());
if (AvRoomDataManager.get().isOpenPureMode()) {
// 純凈模式打開後,僅能看跟自己相關的砸蛋消息
if (Objects.equals(roomBoxPrizeAttachment.getUid(), AuthModel.get().getCurrentUid())) {
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), roomBoxPrizeAttachment);
IMNetEaseManager.get().addMessages(message);
}
} else {
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), roomBoxPrizeAttachment);
IMNetEaseManager.get().addMessages(message);
IMNetEaseManager.get().getChatRoomEventObservable()
.onNext(new RoomEvent()
.setEvent(RoomEvent.BOX_NOTIFY_SVGA)
.setChatRoomMessage(message));
}
}
break;
case CustomAttachment.CUSTOM_MESS_TAROT:
if (baseProtocol.getSecond() == CustomAttachment.CUSTOM_MESS_TAROT_SENIOR_PRIZE_WINNING) {
TarotMsgBean tarotMsgBean = JSON.parseObject(String.valueOf(baseProtocol.getData()), TarotMsgBean.class);
TarotAttachment tarotAttachment = new TarotAttachment(CustomAttachment.CUSTOM_MESS_TAROT,
CustomAttachment.CUSTOM_MESS_TAROT_SENIOR_PRIZE_WINNING);
tarotAttachment.setTarotMsgBean(tarotMsgBean);
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(
String.valueOf(AvRoomDataManager.get().getRoomId()), tarotAttachment);
IMNetEaseManager.get().getChatRoomEventObservable()
.onNext(new RoomEvent()
.setEvent(RoomEvent.TAROT_NOTIFY_SVGA)
.setChatRoomMessage(message));
AvRoomDataManager.get().addChatRoomMessage(message);
}
break;
case CustomAttachment.CUSTOM_MSG_NOTIFY_H5:
if (baseProtocol.getSecond() == CustomAttachment.CUSTOM_MSG_NOTIFY_H5_SUB_WHOLE_SERVICE) {
NotifyH5Info bean = JSON.parseObject(String.valueOf(baseProtocol.getData()), NotifyH5Info.class);
NotifyH5Attachment notifyH5Attachment = new NotifyH5Attachment(baseProtocol.getSecond());
notifyH5Attachment.setBean(bean);
ChatRoomMessage notifyH5Msg = ChatRoomMessageBuilder.createChatRoomCustomMessage(
String.valueOf(AvRoomDataManager.get().getRoomId()), notifyH5Attachment);
IMNetEaseManager.get().getChatRoomEventObservable()
.onNext(new RoomEvent()
.setEvent(RoomEvent.NOTIFY_H5)
.setChatRoomMessage(notifyH5Msg));
}
break;
case CUSTOM_MSG_LUCKY_SEA://星级厨房
if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL) {
RoomLuckySeaAttachment attachment = new RoomLuckySeaAttachment(CUSTOM_MSG_LUCKY_SEA, CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL);
attachment.setRoomLuckySeaMsgBean(JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomLuckySeaMsgBean.class));
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), attachment);
IMNetEaseManager.get().addMessages(message);
IMNetEaseManager.get().noticeRoomEvent(message, RoomEvent.LUCKY_SEA_GIFT_SERVER_NOTIFY);
}
break;
case CUSTOM_MSG_LUCKY_GIFT://福袋
if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY || baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL) {
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);
@@ -1294,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);

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

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

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

@@ -30,7 +30,7 @@ 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;

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

@@ -11,12 +11,9 @@ import android.graphics.drawable.Drawable
import android.graphics.drawable.GradientDrawable
import android.os.Bundle
import android.text.TextUtils
import android.util.Log
import android.view.KeyEvent
import android.view.MotionEvent
import android.view.View
import android.view.ViewStub
import android.view.inputmethod.EditorInfo
import android.widget.EditText
import android.widget.ImageView
import android.widget.RelativeLayout
@@ -187,14 +184,6 @@ 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)
@@ -303,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之前!!!
@@ -328,7 +313,6 @@ 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()
@@ -336,7 +320,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
openOrCloseGiftValue(true)
GiftValueMrg.get().updateRoomGiftValue(false)
}
RoomEvent.ADD_BLACK_LIST -> onChatRoomMemberBlackAdd(roomEvent.account)
RoomEvent.MIC_QUEUE_STATE_CHANGE -> onQueueMicStateChange()
RoomEvent.KICK_DOWN_MIC_BY_S_ADMIN, RoomEvent.KICK_DOWN_MIC -> if (event == RoomEvent.KICK_DOWN_MIC) {
@@ -352,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) {
@@ -383,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()
}
@@ -566,10 +544,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
} else {
val roomQueueInfo = AvRoomDataManager.get()
.getRoomQueueMemberInfoByAccount(myUid.toString())
if (roomQueueInfo?.mChatRoomMember?.isNoProhibitMic == true && roomQueueInfo.mRoomMicInfo?.isMicMute == false) {
bottomView.setMicBtnEnable(true)
bottomView.setMicBtnOpen(true)
} else if (roomQueueInfo?.mChatRoomMember != null
if (roomQueueInfo?.mChatRoomMember != null
&& myUid.toString() == roomQueueInfo.mChatRoomMember.account
&& roomQueueInfo.mRoomMicInfo?.isMicMute == true
) {
@@ -657,16 +632,13 @@ 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)
}
}
@@ -735,7 +707,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
}
.subscribe { _, throwable ->
if (throwable != null) {
toast(throwable.message)
callback.onFail()
} else {
callback.onSuccess()
@@ -838,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)
@@ -1237,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)
}

View File

@@ -1,196 +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.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.view.IGameRoomView
import com.yizhuan.erban.databinding.FragmentGameRoomBinding
import com.yizhuan.erban.ui.widget.GiftDialog.OnGiftDialogBtnClickListener
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
import com.yizhuan.xchat_android_core.music.model.PlayerModel
import com.yizhuan.xchat_android_core.pay.event.FirstChargeEvent
import com.yizhuan.xchat_android_core.room.event.FinishAvRoomEvent
import com.yizhuan.xchat_android_library.base.factory.CreatePresenter
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
/**
* 轰趴房间
*
* @author chenran
* @date 2017/7/26
*/
@CreatePresenter(GameRoomPresenter::class)
class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
View.OnClickListener, OnGiftDialogBtnClickListener, IGameRoomView, OnMicroItemClickListener,
OnGameStatusChangeListener {
companion object {
@JvmStatic
fun newInstance(): GameRoomFragment {
val roomFragment = GameRoomFragment()
val bundle = Bundle()
roomFragment.arguments = bundle
return roomFragment
}
}
private lateinit var gameBinding: FragmentGameRoomBinding
private lateinit var gameDelegate: GameDelegate
private var isShowMiniMic = false
override fun getRootLayoutId(): Int {
return R.layout.fragment_game_room
}
override fun onFindViews() {
super.onFindViews()
gameBinding = DataBindingUtil.bind(mView)!!
gameBinding.lifecycleOwner = this
gameBinding.click = this
gameBinding.ktvModel = false
gameDelegate = GameDelegate(
requireActivity(),
gameBinding.flGameContainer,
AvRoomDataManager.get().mCurrentRoomInfo?.mgId
)
gameDelegate.setOnGameStatusChangeListener(this)
}
@SuppressLint("CheckResult")
override fun initiate() {
gameBinding.microView.bindAdapter(GameMicroViewAdapter(context))
super.initiate()
//游戏模式暂时不需要这个
PlayerModel.get().stop()
gameBinding.roomInfo = AvRoomDataManager.get().mCurrentRoomInfo
mvpPresenter?.getBannerList()
gameBinding.tvShowMiniMic.setOnClickListener { showMiniMic() }
gameBinding.ivShowMic.setOnClickListener { showMic() }
}
private fun showMiniMic() {
if (isShowMiniMic) return
isShowMiniMic = true
gameBinding.microView.bindAdapter(GameMiniMicroViewAdapter(context).apply {
setOnClick { showMic() }
})
gameBinding.tvShowMiniMic.isVisible = false
gameBinding.microView.postDelayed({
gameBinding.ivShowMic.isVisible = true
gameBinding.llMicView.setBackgroundResource(R.drawable.bg_mini_mic_entrance)
}, 100)
}
private fun showMic() {
if (!isShowMiniMic) return
isShowMiniMic = false
gameBinding.microView.bindAdapter(GameMicroViewAdapter(context))
gameBinding.tvShowMiniMic.isVisible = true
gameBinding.llMicView.background = null
gameBinding.ivShowMic.isVisible = false
}
override fun onSetListener() {
super.onSetListener()
bottomView.setBottomViewListener(BaseRoomBottomViewWrapper())
}
override fun updateView() {
super.updateView()
gameDelegate.updateGame(AvRoomDataManager.get().mCurrentRoomInfo?.mgId)
gameBinding.roomInfo = AvRoomDataManager.get().mCurrentRoomInfo
if (isSixMic()) {
gameBinding.tvShowMiniMic.isVisible = !isShowMiniMic
gameBinding.ivShowMic.isVisible = isShowMiniMic
} else {
showMic()
gameBinding.tvShowMiniMic.isInvisible = true
gameBinding.ivShowMic.isVisible = false
}
gameBinding.microView.adapter.notifyDataSetChanged()
}
override fun onGameStart() {
if (isSixMic()) {
showMiniMic()
}
}
override fun onGameEnd() {
if (isSixMic()) {
showMic()
}
}
private fun isSixMic(): Boolean {
return AvRoomDataManager.get().mgMicNum == AvRoomDataManager.GAME_DEF_MIC_COUNT
}
override fun onSendMsgSuccess(msg: String?) {
super.onSendMsgSuccess(msg)
msg?.let {
if (AvRoomDataManager.get().isSelfGamePlaying) {
gameDelegate.hitTheMark(msg)
}
}
}
override fun onShowBanner(dialogInfos: List<BannerInfo>) {
initRoomAct(gameBinding.activityImg, dialogInfos)
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun onFinishAvRoomEvent(event: FinishAvRoomEvent) {
gameDelegate.exitGame()
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun onFirstRechargeEvent(event: FirstChargeEvent) {
FirstChargePrizeDialog(
requireContext(),
event.chargeProdTitle,
event.firstChargeRewardList
).openDialog()
}
override fun onStart() {
super.onStart()
gameDelegate.onStart()
}
override fun onResume() {
super.onResume()
gameDelegate.onResume()
}
override fun onPause() {
super.onPause()
gameDelegate.onPause()
}
override fun onStop() {
super.onStop()
gameDelegate.onStop()
}
override fun onDestroy() {
gameDelegate.onDestroy()
super.onDestroy()
}
}

View File

@@ -32,7 +32,6 @@ 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;
@@ -79,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;
/**
* 轰趴房
@@ -100,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[]{""};
@@ -181,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);
}
/**
@@ -213,13 +209,6 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
ivRoomShare.setOnClickListener(this);
gameMainBinding.llRoomInfo.setOnClickListener(this);
gameMainBinding.ivBack.setOnClickListener(this);
mRoomEffectView.setOnPlayAnimCallback(new Function0<Boolean>() {
@Override
public Boolean invoke() {
return getIsAnim();
}
});
}
@SuppressLint("CheckResult")
@@ -355,24 +344,6 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
});
}
/**
* 获取礼物飘屏是否展示
*
* @return
*/
private boolean getIsAnim() {
if (giftView != null) {
return giftView.getIsPlayAnim();
}
return false;
}
/**
* 获取玩法飘屏是否展示
*/
private boolean getIsPlayAnim() {
return mRoomEffectView.getIsPlayAnim();
}
private void onReceiveLuckyGiftToMultiMsg(LuckyBagGifts giftMultiReceiverInfo) {
if (giftMultiReceiverInfo == null || !isResumed()) return;
@@ -434,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

@@ -60,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;
@@ -452,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));
}
@@ -964,6 +965,9 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
@Override
public void onShowBanner(List<BannerInfo> bannerInfos) {
initRoomAct(gameBinding.activityImg, bannerInfos, 11f);
AvRoomModel.get().getRoomActTimer(AvRoomDataManager.get().getRoomUid())
.compose(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
.subscribe();
}

View File

@@ -84,6 +84,11 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
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) {

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

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

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

@@ -32,21 +32,13 @@ public class GameRoomPresenter extends BaseRoomPresenter<IGameRoomView> {
bannerInfo.setFirstCharge(true);
bannerInfos.add(0, bannerInfo);
}
if(GoldBoxHelper.isShowFairy()){
BannerInfo bannerInfo = new BannerInfo();
bannerInfo.setFairy(true);
bannerInfos.add(firstCharge ? 1 : 0, bannerInfo);
}
List<BannerInfo> finalBannerInfos = bannerInfos;
GoldBoxHelper.isHideBox()
.subscribe(isHide -> {
if (!isHide) {
BannerInfo bannerInfo = new BannerInfo();
bannerInfo.setBox(true);
int index = 0;
if (firstCharge) index++;
if (GoldBoxHelper.isShowFairy()) index++;
finalBannerInfos.add(index, bannerInfo);
finalBannerInfos.add(firstCharge ? 1 : 0, bannerInfo);
}
getMvpView().onShowBanner(finalBannerInfos);
}, throwable -> getMvpView().onShowBanner(finalBannerInfos));

View File

@@ -55,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;
@@ -89,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;
@@ -150,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());
@@ -159,7 +159,7 @@ public class HomePartyPresenter extends BaseRoomPresenter<IHomePartyView> {
return ChatRoomMessageBuilder.createChatRoomCustomMessage(
// 聊天室id
roomInfo.getRoomId() + "",
// 自定消息
// 自定消息
faceAttachment
);
}
@@ -178,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));
}
@@ -215,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) {
@@ -245,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
@@ -273,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()));
}
@@ -328,11 +328,6 @@ public class HomePartyPresenter extends BaseRoomPresenter<IHomePartyView> {
getMvpView().onShowBanner(bannerInfos);
}, throwable -> getMvpView().onShowBanner(bannerInfos));
} else {
if(GoldBoxHelper.isShowFairy()){
BannerInfo bannerInfo = new BannerInfo();
bannerInfo.setFairy(true);
bannerInfos.add(0, bannerInfo);
}
if (firstCharge) {
BannerInfo bannerInfo = new BannerInfo();
bannerInfo.setFirstCharge(true);

View File

@@ -45,11 +45,6 @@ public class SingleRoomPresenter extends BaseRoomPresenter<ISingleRoomView> {
getMvpView().onShowBanner(bannerInfos);
}, throwable -> getMvpView().onShowBanner(bannerInfos));
} else {
if(GoldBoxHelper.isShowFairy()){
BannerInfo bannerInfo = new BannerInfo();
bannerInfo.setFairy(true);
bannerInfos.add(0, bannerInfo);
}
if (firstCharge) {
BannerInfo bannerInfo = new BannerInfo();
bannerInfo.setFirstCharge(true);

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

@@ -62,15 +62,15 @@ class RedPackageOpenDialog : BaseDialog<DialogRedPackageOpenBinding>() {
override fun init() {
dialog?.setCanceledOnTouchOutside(false)
binding?.ivClose?.setOnClickListener { dismissAllowingStateLoss() }
binding?.ivOpen?.setOnClickListener {
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
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))
}
@@ -85,7 +85,7 @@ class RedPackageOpenDialog : BaseDialog<DialogRedPackageOpenBinding>() {
}
}
, {
binding?.ivOpen?.isEnabled = true
binding.ivOpen.isEnabled = true
mObjectAnimator?.cancel()
SingleToastUtil.showToast(it.message)
})
@@ -97,11 +97,11 @@ class RedPackageOpenDialog : BaseDialog<DialogRedPackageOpenBinding>() {
it.addListener(object : AnimatorListenerAdapter() {
var isCanceled = false
override fun onAnimationCancel(animation: Animator) {
override fun onAnimationCancel(animation: Animator?) {
isCanceled = true
}
override fun onAnimationEnd(animation: Animator) {
override fun onAnimationEnd(animation: Animator?) {
if (!isCanceled) {
openRedPackage()
}
@@ -117,32 +117,32 @@ class RedPackageOpenDialog : BaseDialog<DialogRedPackageOpenBinding>() {
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)
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
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
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)
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(".")
binding.tvDiamondNum.text = it.amount.substringBefore(".")
}
if (!AvRoomDataManager.get().isRoomFans){
AvRoomDataManager.get().roomUid.let {
@@ -155,20 +155,20 @@ class RedPackageOpenDialog : BaseDialog<DialogRedPackageOpenBinding>() {
}
}
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.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}"
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)
binding.rvUsers.adapter = adapter
binding.rvUsers.layoutManager = LinearLayoutManager(context)
adapter.setNewData(packageInfo.redEnvelopeItemVOs)
PayModel.get().getWalletInfo(AuthModel.get().currentUid).subscribe()
}

View File

@@ -59,7 +59,7 @@ class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPass
EventBus.getDefault().register(this)
PayModel.get().currentWalletInfo?.let {
binding?.tvBalanceNum?.text = it.diamondNum.toInt().toString()
binding.tvBalanceNum.text = it.diamondNum.toInt().toString()
}
if (InitialModel.get().cacheInitInfo == null) {
InitialModel.get().init(true)
@@ -74,12 +74,12 @@ class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPass
*/
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}"
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}"
}
/**
@@ -87,39 +87,39 @@ class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPass
*/
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}"
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 {
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 = "改為禮物紅包"
binding.tvRedTypeHint.text = "當前為手氣紅包,"
binding.tvChangeType.text = "改為禮物紅包"
} else {
isGift = true
binding?.tvRedTypeHint?.text = "當前為禮物紅包,"
binding?.tvChangeType?.text = "改為手氣紅包"
binding.tvRedTypeHint.text = "當前為禮物紅包,"
binding.tvChangeType.text = "改為手氣紅包"
}
}
//默認就已經是手氣紅包,如果後臺配置為了禮物紅包就在這裏改下
if (initInfo.redEnvelopeType == 2 && !isGift) {
binding?.tvChangeType?.callOnClick()
binding.tvChangeType.callOnClick()
}
binding?.tvCharge?.setOnClickListener {
binding.tvCharge.setOnClickListener {
if (!CommonUtils.isFastDoubleClick(800)) {
if (AppMetaDataUtil.getChannelID() == Constants.GOOGLE) {
ChargeActivity.start(context)
@@ -133,9 +133,9 @@ class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPass
}
}
}
binding?.ivClose?.setOnClickListener { dismissAllowingStateLoss() }
binding?.ivHelp?.setOnClickListener { DialogWebViewActivity.start(context, UriProvider.getRedPacketRule()) }
binding?.ivSend?.setOnClickListener {
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)
@@ -148,12 +148,12 @@ class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPass
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()
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()
val goldNum = binding.editGoldNum.text.toString().toIntOrDef()
if (isAll) {
if (goldNum % 100 != 0) {
@@ -179,22 +179,22 @@ class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPass
SingleToastUtil.showToast("單個紅包金額過低")
return@setOnClickListener
}
GiveGoldPassWordFragment.newInstance(childFragmentManager, binding?.editGoldNum?.text.toString()).apply {
GiveGoldPassWordFragment.newInstance(childFragmentManager, binding.editGoldNum.text.toString()).apply {
setListener(this@RedPackageSendDialog)
passWordFragment = this
}
};
binding?.tvAllRed?.setOnClickListener {
binding.tvAllRed.setOnClickListener {
if (isAll) return@setOnClickListener
changeToAll()
}
binding?.tvRoomRed?.setOnClickListener {
binding.tvRoomRed.setOnClickListener {
if (!isAll) return@setOnClickListener
changeToNotAll()
}
binding?.editRedText?.addTextChangedListener(this)
binding.editRedText.addTextChangedListener(this)
binding?.editRedText?.setOnEditorActionListener { _, _, event ->
binding.editRedText.setOnEditorActionListener { _, _, event ->
event.keyCode == KeyEvent.KEYCODE_ENTER
}
@@ -210,7 +210,7 @@ class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPass
}
override fun onDestroyView() {
binding?.editRedText?.removeTextChangedListener(this)
binding.editRedText.removeTextChangedListener(this)
super.onDestroyView()
}
@@ -220,9 +220,9 @@ class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPass
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(),
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()
@@ -241,7 +241,7 @@ class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPass
@Subscribe(threadMode = ThreadMode.MAIN)
fun onWalletInfoUpdate(event: UpdateWalletInfoEvent?) {
binding?.tvBalanceNum?.text = PayModel.get().currentWalletInfo?.diamondNum?.toString()
binding.tvBalanceNum.text = PayModel.get().currentWalletInfo?.diamondNum?.toString()
?: "0"
}
@@ -256,7 +256,7 @@ class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPass
@SuppressLint("SetTextI18n")
override fun afterTextChanged(s: Editable) {
binding?.tvRedTextLimit?.text = "${s.length}/20"
binding.tvRedTextLimit.text = "${s.length}/20"
}
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {

View File

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

View File

@@ -33,37 +33,37 @@ class SingleRoomPkFinishDialog : BaseDialog<DialogSingleRoomPkFinishBinding>() {
@SuppressLint("CheckResult", "SetTextI18n")
override fun init() {
binding?.tvClose?.setOnClickListener { dismissAllowingStateLoss() }
binding?.tvTitleRed?.text = roomPkBean.cNick.subAndReplaceDot(7)
binding?.tvValueRed?.text = "${roomPkBean.cAmount}"
binding?.ivAvatarRed?.load(roomPkBean.cAvatar, defaultRes = R.drawable.default_avatar)
binding.tvClose.setOnClickListener { dismissAllowingStateLoss() }
binding.tvTitleRed.text = roomPkBean.cNick.subAndReplaceDot(7)
binding.tvValueRed.text = "${roomPkBean.cAmount}"
binding.ivAvatarRed.load(roomPkBean.cAvatar, defaultRes = R.drawable.default_avatar)
roomPkBean.csRank.getOrNull(0)?.let {
binding?.groupRank1?.isVisible = true
binding?.tvRankNick1?.text = it.nick.subAndReplaceDot(7)
binding?.tvRankValue1?.text = "PK值:${it.amount}"
binding?.ivAvatar1?.load(it.avatar, defaultRes = R.drawable.default_avatar)
binding.groupRank1.isVisible = true
binding.tvRankNick1.text = it.nick.subAndReplaceDot(7)
binding.tvRankValue1.text = "PK值:${it.amount}"
binding.ivAvatar1.load(it.avatar, defaultRes = R.drawable.default_avatar)
} ?: run {
binding?.groupRank1?.isVisible = false
binding?.tvEmptyTip?.isVisible = true
binding.groupRank1.isVisible = false
binding.tvEmptyTip.isVisible = true
}
roomPkBean.csRank.getOrNull(1)?.let {
binding?.groupRank2?.isVisible = true
binding?.tvRankNick2?.text = it.nick.subAndReplaceDot(7)
binding?.tvRankValue2?.text = "PK值:${it.amount}"
binding?.ivAvatar2?.load(it.avatar, defaultRes = R.drawable.default_avatar)
binding.groupRank2.isVisible = true
binding.tvRankNick2.text = it.nick.subAndReplaceDot(7)
binding.tvRankValue2.text = "PK值:${it.amount}"
binding.ivAvatar2.load(it.avatar, defaultRes = R.drawable.default_avatar)
} ?: run {
binding?.groupRank2?.isVisible = false
binding.groupRank2.isVisible = false
}
roomPkBean.csRank.getOrNull(2)?.let {
binding?.groupRank3?.isVisible = true
binding?.tvRankNick3?.text = it.nick.subAndReplaceDot(7)
binding?.tvRankValue3?.text = "PK值:${it.amount}"
binding?.ivAvatar3?.load(it.avatar, defaultRes = R.drawable.default_avatar)
binding.groupRank3.isVisible = true
binding.tvRankNick3.text = it.nick.subAndReplaceDot(7)
binding.tvRankValue3.text = "PK值:${it.amount}"
binding.ivAvatar3.load(it.avatar, defaultRes = R.drawable.default_avatar)
} ?: run {
binding?.groupRank3?.isVisible = false
binding.groupRank3.isVisible = false
}
Observable.intervalRange(0, 6, 0, 1, TimeUnit.SECONDS)
@@ -71,24 +71,24 @@ class SingleRoomPkFinishDialog : BaseDialog<DialogSingleRoomPkFinishBinding>() {
.observeOn(AndroidSchedulers.mainThread())
.doOnComplete { dismissAllowingStateLoss() }
.subscribe {
binding?.tvClose?.text = "關閉(${5 - it})"
binding.tvClose.text = "關閉(${5 - it})"
}
when (roomPkBean.winUid) {
0L -> {
binding?.viewBg?.setBackgroundResource(R.drawable.single_room_pk_bg_finish_deuce)
binding?.viewBgAvatar?.setBackgroundResource(R.drawable.single_room_pk_bg_finish_deuce_avatar)
binding?.tvContributeTitle?.setBackgroundResource(R.drawable.single_room_pk_bg_finish_deuce_contribute)
binding.viewBg.setBackgroundResource(R.drawable.single_room_pk_bg_finish_deuce)
binding.viewBgAvatar.setBackgroundResource(R.drawable.single_room_pk_bg_finish_deuce_avatar)
binding.tvContributeTitle.setBackgroundResource(R.drawable.single_room_pk_bg_finish_deuce_contribute)
}
roomPkBean.cUid -> {
binding?.viewBg?.setBackgroundResource(R.drawable.single_room_pk_bg_finish_win)
binding?.viewBgAvatar?.setBackgroundResource(R.drawable.single_room_pk_bg_finish_win_avatar)
binding?.tvContributeTitle?.setBackgroundResource(R.drawable.single_room_pk_bg_finish_win_contribute)
binding.viewBg.setBackgroundResource(R.drawable.single_room_pk_bg_finish_win)
binding.viewBgAvatar.setBackgroundResource(R.drawable.single_room_pk_bg_finish_win_avatar)
binding.tvContributeTitle.setBackgroundResource(R.drawable.single_room_pk_bg_finish_win_contribute)
}
else -> {
binding?.viewBg?.setBackgroundResource(R.drawable.single_room_pk_bg_finish_failed)
binding?.viewBgAvatar?.setBackgroundResource(R.drawable.single_room_pk_bg_finish_failed_avatar)
binding?.tvContributeTitle?.setBackgroundResource(R.drawable.single_room_pk_bg_finish_failed_contribute)
binding.viewBg.setBackgroundResource(R.drawable.single_room_pk_bg_finish_failed)
binding.viewBgAvatar.setBackgroundResource(R.drawable.single_room_pk_bg_finish_failed_avatar)
binding.tvContributeTitle.setBackgroundResource(R.drawable.single_room_pk_bg_finish_failed_contribute)
}
}

View File

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

View File

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

View File

@@ -17,12 +17,12 @@ class SingleRoomPkRuleDialog : BaseDialog<DialogSingleRoomPkRuleBinding>() {
}
override fun init() {
binding?.ivClose?.setOnClickListener { dismissAllowingStateLoss() }
binding?.tvContent?.movementMethod = ScrollingMovementMethod.getInstance()
binding.ivClose.setOnClickListener { dismissAllowingStateLoss() }
binding.tvContent.movementMethod = ScrollingMovementMethod.getInstance()
SingleRoomPKModel.getSingleRoomPkRule()
.compose(bindToLifecycle())
.doOnSuccess {
binding?.tvContent?.text = it.replace("\\n", "\n").replace("\\r", "\r")
binding.tvContent.text = it.replace("\\n", "\n").replace("\\r", "\r")
}
.doOnError { it?.message.toast() }
.subscribe()

View File

@@ -4,6 +4,7 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.Point;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
@@ -11,6 +12,9 @@ import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
@@ -25,14 +29,19 @@ import com.tencent.qgame.animplayer.AnimView;
import com.yizhuan.erban.R;
import com.yizhuan.erban.common.widget.CircleImageView;
import com.yizhuan.erban.ui.utils.ImageLoadKt;
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil;
import com.yizhuan.xchat_android_core.bean.RoomQueueInfo;
import com.yizhuan.xchat_android_core.gift.GiftModel;
import com.yizhuan.xchat_android_core.gift.bean.GiftEffectInfo;
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo;
import com.yizhuan.xchat_android_core.gift.bean.GiftReceiver;
import com.yizhuan.xchat_android_core.initial.InitialModel;
import com.yizhuan.xchat_android_core.initial.bean.InitInfo;
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager;
import com.yizhuan.xchat_android_core.manager.RoomEvent;
import com.yizhuan.xchat_android_library.utils.ResUtil;
import com.yizhuan.xchat_android_library.utils.ResolutionUtils;
import java.lang.ref.WeakReference;
@@ -63,9 +72,9 @@ public class GiftEffectView extends RelativeLayout implements SVGACallback {
private GiftEffectListener giftEffectListener;
private EffectHandler effectHandler;
private boolean isAnim;
private boolean isPlayAnim;
private boolean isHideCarEffect;
public GiftEffectView(Context context) {
super(context);
init();
@@ -85,10 +94,6 @@ public class GiftEffectView extends RelativeLayout implements SVGACallback {
return isAnim;
}
public boolean isPlayAnim() {
return isPlayAnim;
}
public void setGiftEffectListener(GiftEffectListener giftEffectListener) {
this.giftEffectListener = giftEffectListener;
}
@@ -121,9 +126,60 @@ public class GiftEffectView extends RelativeLayout implements SVGACallback {
giftInfo = giftEffectInfo.getGift();
}
if (giftInfo != null) {
isPlayAnim = false;
container.setVisibility(INVISIBLE);
effectHandler.sendEmptyMessageDelayed(0, 4000);
int totalCoin = giftInfo.getGoldPrice() * giftEffectInfo.getGiftNum() * giftEffectInfo.getTargetUsers().size();
if (totalCoin >= 520 &&
giftEffectInfo.getGiftReceiveType() != GiftEffectInfo.GIFT_RECEIVE_TYPE_LUCKY
&& !AvRoomDataManager.get().isSelfGamePlaying()) {//礼物栏
ImageLoadUtils.loadImage(benefactorAvatar.getContext(), giftEffectInfo.getAvatar(), benefactorAvatar);
ImageLoadUtils.loadImage(giftImg.getContext(), giftInfo.getGiftUrl(), giftImg);
benefactorNick.setText(giftEffectInfo.getNick());
giftNumber.setText("X" + giftEffectInfo.getGiftNum());
giftName.setText(giftInfo.getGiftName());
container.setVisibility(VISIBLE);
if (giftEffectInfo.getGiftReceiveType() == GiftEffectInfo.GIFT_RECEIVE_TYPE_SINGLE) {
GiftReceiver giftReceiver = giftEffectInfo.getTargetUsers().get(0);
ImageLoadUtils.loadAvatar(receiverAvatar.getContext(), giftReceiver.getAvatar(), receiverAvatar);
receiverNick.setText(giftReceiver.getNick());
} else if (giftEffectInfo.getGiftReceiveType() == GiftEffectInfo.GIFT_RECEIVE_TYPE_ALL) {
receiverAvatar.setImageResource(R.drawable.about_logo);
receiverNick.setText(ResUtil.getString(R.string.avroom_widget_gifteffectview_01));
} else if (giftEffectInfo.getGiftReceiveType() == GiftEffectInfo.GIFT_RECEIVE_TYPE_MULTI) {
receiverAvatar.setImageResource(R.drawable.about_logo);
StringBuilder sb = new StringBuilder();
for (GiftReceiver targetUser : giftEffectInfo.getTargetUsers()) {
RoomQueueInfo roomQueueInfo = AvRoomDataManager.get().getRoomQueueMemberInfoByAccount(targetUser.getUid() + "");
if (roomQueueInfo == null) continue;
sb.append(roomQueueInfo.mRoomMicInfo.getPosition() + 1).append(ResUtil.getString(R.string.avroom_widget_gifteffectview_02)).append(",");
}
if (sb.length() > 0) {
sb.replace(sb.lastIndexOf(","), sb.length(), "");
}
receiverNick.setText(sb.toString());
}
Animation operatingAnim = AnimationUtils.loadAnimation(getContext(), R.anim.light_bg_rotate_anim);
LinearInterpolator lin = new LinearInterpolator();
operatingAnim.setInterpolator(lin);
giftLightBg.setAnimation(operatingAnim);
final Point center = new Point();
center.x = ResolutionUtils.getScreenWidth(getContext()) / 2;
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(container, "translationX", -UIUtil.dip2px(getContext(), 400), center.x - container.getWidth() / 2).setDuration(500);
objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
objectAnimator.start();
ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(container, "alpha", 0.0F, 1.0F).setDuration(500);
objectAnimator1.setInterpolator(new AccelerateDecelerateInterpolator());
objectAnimator1.start();
if (totalCoin < 4999) {
imgBg.setImageResource(R.drawable.icon_gift_effect_bg_1);
} else if (totalCoin < 9999) {
imgBg.setImageResource(R.drawable.icon_gift_effect_bg_2);
} else {
imgBg.setImageResource(R.drawable.icon_gift_effect_bg_3);
}
}
effectHandler.sendEmptyMessageDelayed(0, 6000);
if (giftInfo.getOtherViewType() == 1 && !TextUtils.isEmpty(giftInfo.getViewUrl())) {
drawVAPEffect(giftInfo.getViewUrl());
} else if (giftInfo.isHasVggPic() && !StringUtil.isEmpty(giftInfo.getVggUrl())) {
@@ -153,7 +209,7 @@ public class GiftEffectView extends RelativeLayout implements SVGACallback {
svgaImageView.setImageDrawable(drawable);
svgaImageView.startAnimation();
svgaBg.setVisibility(VISIBLE);
ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(svgaBg, "alpha", 0.0F, 2.0F).setDuration(1250);
ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(svgaBg, "alpha", 0.0F, 2.0F).setDuration(800);
objectAnimator1.setInterpolator(new AccelerateDecelerateInterpolator());
objectAnimator1.start();
}
@@ -174,11 +230,11 @@ public class GiftEffectView extends RelativeLayout implements SVGACallback {
}
private void deleteAnim() {
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(container, "translationX", container.getX(), ResolutionUtils.getScreenWidth(getContext())).setDuration(1250);
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(container, "translationX", container.getX(), ResolutionUtils.getScreenWidth(getContext())).setDuration(500);
objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
objectAnimator.start();
ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(container, "alpha", 1.0F, 0.0F).setDuration(1250);
ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(container, "alpha", 1.0F, 0.0F).setDuration(500);
objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
objectAnimator.addListener(new AnimatorListenerAdapter() {
@Override
@@ -190,7 +246,6 @@ public class GiftEffectView extends RelativeLayout implements SVGACallback {
}
if (giftEffectListener != null) {
isAnim = false;
isPlayAnim = false;
giftEffectListener.onGiftEffectEnd();
}
}

View File

@@ -9,7 +9,9 @@ import android.animation.ValueAnimator;
import android.app.Activity;
import android.content.Context;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.graphics.Point;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
@@ -34,6 +36,7 @@ import com.yizhuan.erban.R;
import com.yizhuan.erban.common.svga.SimpleSvgaParseCompletion;
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil;
import com.yizhuan.xchat_android_core.auth.AuthModel;
import com.yizhuan.xchat_android_core.fansteam.FansTeamMsgInfo;
import com.yizhuan.xchat_android_core.gift.GiftModel;
import com.yizhuan.xchat_android_core.gift.bean.GiftEffectInfo;
@@ -50,6 +53,9 @@ import com.yizhuan.xchat_android_core.magic.bean.MagicInfo;
import com.yizhuan.xchat_android_core.magic.bean.MagicReceivedInfo;
import com.yizhuan.xchat_android_core.magic.bean.MultiMagicReceivedInfo;
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager;
import com.yizhuan.xchat_android_core.manager.RoomEvent;
import com.yizhuan.xchat_android_core.monsterhunting.bean.MonsterAttackInfo;
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
import com.yizhuan.xchat_android_library.utils.ResUtil;
import com.yizhuan.xchat_android_library.utils.ResolutionUtils;
@@ -59,7 +65,9 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Objects;
import java.util.Random;
import javax.annotation.Nullable;
@@ -90,6 +98,8 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
private Keyframe[] keyScale;
private Keyframe[] keyTrans;
private SvgaObjectPool mMagicViewPool;
private volatile Hashtable<Integer, MonsterAttackInfo> currentAnimationMap = new Hashtable<>();
public GiftV2View(Context context) {
this(context, null);
@@ -291,7 +301,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
}
}
private void drawLuckyGift(GiftReceiveInfo giftReceiveInfos, int giftReceiveType, boolean isShowAnimation, String svgaUrl, int pos) {
private void drawLuckyGift(GiftReceiveInfo giftReceiveInfos, int giftReceiveType, boolean isShowAnimation, String svgaUrl) {
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
if (roomInfo != null) {
List<GiftReceiver> targetUsers = new ArrayList<>();
@@ -306,11 +316,11 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
}, 1800);
}
handler.postDelayed(() -> drawLuckyGiftAnimation(roomInfo, giftReceiveInfos, totalCoin, targetUsers, giftReceiveType, isShowAnimation, pos), 1200);
handler.postDelayed(() -> drawLuckyGiftAnimation(roomInfo, giftReceiveInfos, totalCoin, targetUsers, giftReceiveType, isShowAnimation), 1200);
}
}
private void drawLuckyGiftAnimation(RoomInfo roomInfo, GiftReceiveInfo giftReceiveInfo, int totalCoin, List<GiftReceiver> targetUsers, int giftReceiveType, boolean isShowAnimation, int pos) {
private void drawLuckyGiftAnimation(RoomInfo roomInfo, GiftReceiveInfo giftReceiveInfo, int totalCoin, List<GiftReceiver> targetUsers, int giftReceiveType, boolean isShowAnimation) {
SparseArray<Point> micViewPoint = AvRoomDataManager.get().mMicPointMap;
GiftInfo giftInfo = GiftModel.get().findGiftInfoById(giftReceiveInfo.getGiftId());
if (giftInfo == null || TextUtils.isEmpty(giftInfo.getGiftUrl())) {
@@ -353,7 +363,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
giftReceiver.setNick(giftReceiveInfo.getTargetNick());
targetUsers.add(giftReceiver);
if (!isShowAnimation) return;
giftInfo = giftReceiveInfo.getDisplayGift().get(pos);
giftInfo = giftReceiveInfo.getDisplayGift().get(0);
if (totalCoin >= 520 || (giftInfo != null && giftInfo.isHasEffect())) {
Message msg = Message.obtain();
msg.what = 0;
@@ -361,13 +371,14 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
giftEffectInfo.setUid(giftReceiveInfo.getUid());
giftEffectInfo.setNick(giftReceiveInfo.getNick());
giftEffectInfo.setAvatar(giftReceiveInfo.getAvatar());
giftEffectInfo.setGiftId(giftReceiveInfo.getDisplayGift().get(pos).getGiftId());
giftEffectInfo.setGiftId(giftReceiveInfo.getDisplayGift().get(0).getGiftId());
giftEffectInfo.setGiftNum(giftReceiveInfo.getGiftNum());
giftEffectInfo.setGift(giftInfo);
giftEffectInfo.setTargetUsers(targetUsers);
giftEffectInfo.setGiftReceiveType(giftReceiveType);
msg.obj = giftEffectInfo;
handler.sendMessageDelayed(msg, 200);
}
}
@@ -424,24 +435,25 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
}
public void onReceiveLuckyGiftToMultiMsg(LuckyBagGifts giftMultiReceiverInfo) {
if (giftMultiReceiverInfo != null) {
setVisibility(VISIBLE);
int size = Math.min(giftMultiReceiverInfo.getDisplayGift().size(), 6);
for (int i = 0; i < size; i++) {
GiftReceiveInfo giftReceiveInfo = new GiftReceiveInfo();
giftReceiveInfo.setUid(giftMultiReceiverInfo.getUid());
giftReceiveInfo.setTargetNick(giftMultiReceiverInfo.getUser().getNick());
giftReceiveInfo.setTargetUid(giftMultiReceiverInfo.getUser().getUid());
giftReceiveInfo.setGiftNum(giftMultiReceiverInfo.getGiftNum());
giftReceiveInfo.setDisplayGift(giftMultiReceiverInfo.getDisplayGift());
giftReceiveInfo.setNick(giftMultiReceiverInfo.getNick());
giftReceiveInfo.setGiftId(giftMultiReceiverInfo.getGiftList().get(0).getGiftId());
giftReceiveInfo.setGift(giftMultiReceiverInfo.getDisplayGift().get(i));
//礼物值
giftReceiveInfo.setGiftValueVos(giftMultiReceiverInfo.getGiftValueVos());
giftReceiveInfo.setCurrentTime(giftMultiReceiverInfo.getCurrentTime());
drawLuckyGift(giftReceiveInfo, GiftEffectInfo.GIFT_RECEIVE_TYPE_LUCKY, giftMultiReceiverInfo.isShowAnimation(), giftMultiReceiverInfo.getLuckyGiftSvgaUrl(), i);
}
// List<GiftReceiveInfo> giftReceiveInfos = new ArrayList<>();
GiftReceiveInfo giftReceiveInfo = new GiftReceiveInfo();
giftReceiveInfo.setUid(giftMultiReceiverInfo.getUid());
giftReceiveInfo.setTargetNick(giftMultiReceiverInfo.getUser().getNick());
giftReceiveInfo.setTargetUid(giftMultiReceiverInfo.getUser().getUid());
giftReceiveInfo.setGiftNum(giftMultiReceiverInfo.getGiftNum());
giftReceiveInfo.setDisplayGift(giftMultiReceiverInfo.getDisplayGift());
giftReceiveInfo.setNick(giftMultiReceiverInfo.getNick());
giftReceiveInfo.setGiftId(giftMultiReceiverInfo.getGiftList().get(0).getGiftId());
giftReceiveInfo.setGift(giftMultiReceiverInfo.getDisplayGift().get(0));
//礼物值
giftReceiveInfo.setGiftValueVos(giftMultiReceiverInfo.getGiftValueVos());
giftReceiveInfo.setCurrentTime(giftMultiReceiverInfo.getCurrentTime());
// giftReceiveInfos.add(giftReceiveInfo);
drawLuckyGift(giftReceiveInfo, GiftEffectInfo.GIFT_RECEIVE_TYPE_LUCKY, giftMultiReceiverInfo.isShowAnimation(), giftMultiReceiverInfo.getLuckyGiftSvgaUrl());
}
}
@@ -459,6 +471,13 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
return magicInfo.getPathAnim();
}
// private boolean isCenter(MonsterAttackReceiveInfo monsterAttackReceiveInfo) {
// int magicId = Integer.parseInt(monsterAttackReceiveInfo.getMagicId());
// MagicInfo magicInfo = MagicModel.get().getMagicInfo(magicId);
// if (magicInfo == null) return monsterAttackReceiveInfo.getPosition() == MagicInfo.POS_CENTER;
// return magicInfo.getPosition() == MagicInfo.POS_CENTER;
// }
private String getValidExplodeAnimationUrl(int magicId, String url) {
if (!TextUtils.isEmpty(url)) return url;
MagicInfo magicInfo = MagicModel.get().getMagicInfo(magicId);
@@ -478,6 +497,13 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
drawMagicAnimation(magicReceivedInfos);
}
public void onReceiveMonsterAttackMsg(MonsterAttackInfo monsterAttackReceiveInfo, View monsterView) {
drawMonsterMagicView(monsterAttackReceiveInfo, monsterView);
// List<MonsterAttackInfo> monsterAttackReceiveInfos = new ArrayList<>();
// monsterAttackReceiveInfos.add(monsterAttackReceiveInfo);
// drawMonsterAttackAnimation(monsterAttackReceiveInfos, monsterView);
}
public void onReceiveMultiMagicMsg(MultiMagicReceivedInfo multiMagicReceivedInfo) {
if (multiMagicReceivedInfo != null) {
setVisibility(VISIBLE);
@@ -550,12 +576,70 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
}
/**
* 获取当前是否有飘屏正在显示
* 打怪兽时使用的动画效果
*
* @return
* @param monsterAttackReceiveInfo
* @param monsterView
*/
public boolean getIsPlayAnim() {
return giftEffectView.isPlayAnim();
private void drawMonsterMagicView(MonsterAttackInfo monsterAttackReceiveInfo, View monsterView) {
Point senderPoint = null;
if (Objects.equals(Long.valueOf(monsterAttackReceiveInfo.getUid()), AuthModel.get().getCurrentUid())) {
senderPoint = new Point(mScreenWidth - giftWidth, mScreenHeight - UIUtil.dip2px(context, 50));
} else {
senderPoint = new Point(new Random().nextInt(mScreenWidth), mScreenHeight);
}
SVGAImageView imageView = mMagicViewPool.borrowGiftObject(senderPoint);
imageView.setVisibility(GONE);
ImageLoadUtils.loadImage(context, monsterAttackReceiveInfo.getMagicIcon(), imageView);
int[] location = new int[2];
monsterView.getLocationInWindow(location);
int x = (location[0] + monsterView.getWidth() / 2) - giftWidth / 2;
int y = (location[1] + monsterView.getHeight() / 2) - giftHeight / 2;
Point receivePoint = new Point(x, y);
Path path = getBezierCurvePath(senderPoint, receivePoint, false);
ValueAnimator pathAnimator;
// 当前版本小于21需要
if (Build.VERSION_CODES.LOLLIPOP > Build.VERSION.SDK_INT) {
pathAnimator = ObjectAnimator.ofFloat(0.0f, 1.0f);
pathAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
float[] point = new float[2];
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float val = animation.getAnimatedFraction();
PathMeasure pathMeasure = new PathMeasure(path, false);
pathMeasure.getPosTan(pathMeasure.getLength() * val, point, null);
imageView.setTranslationX(point[0]);
imageView.setTranslationY(point[1]);
}
});
} else {
pathAnimator = ObjectAnimator.ofFloat(imageView, View.TRANSLATION_X, View.TRANSLATION_Y, path);
}
pathAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
imageView.setVisibility(VISIBLE);
}
@Override
public void onAnimationEnd(Animator animation) {
mMagicViewPool.returnObject(imageView);
currentAnimationMap.remove(monsterAttackReceiveInfo.getSequence());
IMNetEaseManager.get().getChatRoomEventObservable().onNext(new RoomEvent()
.setEvent(RoomEvent.MONSTER_HUNTING_ANIMATION_FINISHED)
.setMonsterAttackReceiveInfo(monsterAttackReceiveInfo));
}
});
pathAnimator.setDuration(1000);
currentAnimationMap.put(monsterAttackReceiveInfo.getSequence(), monsterAttackReceiveInfo);
if (currentAnimationMap.size() >= 10) {
postDelayed(pathAnimator::start, 500);
} else {
pathAnimator.start();
}
}
private void drawMagicView(Point senderPoint, Point receivePoint, MagicReceivedInfo magicReceivedInfo) {
@@ -591,8 +675,24 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
Path path = getBezierCurvePath(senderPoint, receivePoint, isCenter(magicReceivedInfo));
ValueAnimator pathAnimator;
// 当前版本小于21需要
pathAnimator = ObjectAnimator.ofFloat(imageView, View.TRANSLATION_X, View.TRANSLATION_Y, path);
pathAnimator.setDuration(1250);
if (Build.VERSION_CODES.LOLLIPOP > Build.VERSION.SDK_INT) {
pathAnimator = ObjectAnimator.ofFloat(0.0f, 1.0f);
pathAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
float[] point = new float[2];
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float val = animation.getAnimatedFraction();
PathMeasure pathMeasure = new PathMeasure(path, false);
pathMeasure.getPosTan(pathMeasure.getLength() * val, point, null);
imageView.setTranslationX(point[0]);
imageView.setTranslationY(point[1]);
}
});
} else {
pathAnimator = ObjectAnimator.ofFloat(imageView, View.TRANSLATION_X, View.TRANSLATION_Y, path);
}
pathAnimator.setDuration(1000);
pathAnimator.start();
}
@@ -654,7 +754,7 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
PropertyValuesHolder p2 = PropertyValuesHolder.ofKeyframe("scaleX", keyScale);
PropertyValuesHolder p3 = PropertyValuesHolder.ofKeyframe("scaleY", keyScale);
ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(imageView, p2, p3, p1, p0);
objectAnimator.setDuration(4000);
objectAnimator.setDuration(3200);
objectAnimator.start();
objectAnimator.addListener(new AnimatorListenerAdapter() {
@Override
@@ -798,6 +898,10 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
if (mImageView == null) return;
mImageView.stopAnimation(true);
giftV2View.mMagicViewPool.returnObject(mImageView);
// ViewParent parent = this.mImageView.getParent();
// if (parent != null && parent instanceof ViewGroup) {
// ((ViewGroup) parent).removeView(mImageView);
// }
}
@Override
@@ -807,6 +911,10 @@ public class GiftV2View extends FrameLayout implements GiftEffectView.GiftEffect
if (mImageView == null) return;
mImageView.stopAnimation(true);
giftV2View.mMagicViewPool.returnObject(mImageView);
// ViewParent parent = this.mImageView.getParent();
// if (parent != null && parent instanceof ViewGroup) {
// ((ViewGroup) parent).removeViewInLayout(mImageView);
// }
}
@Override

View File

@@ -1,20 +1,8 @@
package com.yizhuan.erban.avroom.widget;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAIRY;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GIFT_COMPOUND;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_RED_PACKAGE;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ME;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_CONVERT_L1;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_CONVERT_L2;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_CONVERT_L3;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_BALL_L1;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_BALL_L2;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_BALL_L3;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_GIFT_L1;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_GIFT_L2;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_GIFT_L3;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_GIFT_L4;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_GIFT_L5;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_FANS_TEAM_JOIN;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_GIFT_COMPOUND;
import static com.yizhuan.xchat_android_core.redpackage.RedPackageTypeKt.ALL_DIAMOND;
@@ -71,8 +59,6 @@ import com.yizhuan.erban.common.util.Utils;
import com.yizhuan.erban.common.widget.CustomAutoWidthImageSpan;
import com.yizhuan.erban.common.widget.CustomImageSpan;
import com.yizhuan.erban.common.widget.OriginalDrawStatusClickSpan;
import com.yizhuan.erban.treasure_box.widget.GoldBoxHelper;
import com.yizhuan.erban.treasurefairy.HomeFairyActivity;
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
import com.yizhuan.erban.ui.widget.DividerItemDecoration;
import com.yizhuan.erban.ui.widget.MyItemAnimator;
@@ -102,7 +88,6 @@ import com.yizhuan.xchat_android_core.im.custom.bean.CleanScreenAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.DatingAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.FaceAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.FairyMsgAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.FansTeamMsgAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.GiftAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.GiftBatchAttachment;
@@ -147,7 +132,6 @@ import com.yizhuan.xchat_android_core.noble.NobleInfo;
import com.yizhuan.xchat_android_core.noble.NobleUtil;
import com.yizhuan.xchat_android_core.praise.PraiseModel;
import com.yizhuan.xchat_android_core.redpackage.RedEnvelopeRoomMsg;
import com.yizhuan.xchat_android_core.room.anotherroompk.ShowUserInfoDialogEvent;
import com.yizhuan.xchat_android_core.room.bean.DatingNotifyInfo;
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
import com.yizhuan.xchat_android_core.room.bean.RoomMessageViewNoticeInfo;
@@ -162,15 +146,12 @@ import com.yizhuan.xchat_android_core.room.pk.bean.RoomPKInvitedUpMicMember;
import com.yizhuan.xchat_android_core.room.pk.bean.RoomPkData;
import com.yizhuan.xchat_android_core.room.queuing_mic.attachment.QueuingMicAttachment;
import com.yizhuan.xchat_android_core.room.queuing_mic.bean.QueuingMicInfo;
import com.yizhuan.xchat_android_core.treasurefairy.FairyMsgInfoBean;
import com.yizhuan.xchat_android_core.user.UserModel;
import com.yizhuan.xchat_android_core.user.bean.UserInfo;
import com.yizhuan.xchat_android_core.utils.ExtensionUtil;
import com.yizhuan.xchat_android_core.utils.StringExtensionKt;
import com.yizhuan.xchat_android_core.utils.net.DontWarnObserver;
import com.yizhuan.xchat_android_core.utils.net.RxHelper;
import com.yizhuan.xchat_android_core.vip.VipMessageInfo;
import com.yizhuan.xchat_android_library.rxbus.RxBus;
import com.yizhuan.xchat_android_library.utils.FormatUtils;
import com.yizhuan.xchat_android_library.utils.JavaUtil;
import com.yizhuan.xchat_android_library.utils.ListUtils;
@@ -296,9 +277,9 @@ public class MessageView extends FrameLayout {
sysIconHeight = Utils.dip2px(context, 14);
smallFace = Utils.dip2px(context, 22);
bigFace = Utils.dip2px(context, 30);
//經驗等級圖片後臺已經更換尺寸了,公屏同步下,尺寸是36:18
expLevelHeight = Utils.dip2px(context, 18);
expLevelWidth = expLevelHeight * 36 / 18;//expLevelHeight * 114 / 45
//經驗等級圖片後臺已經更換尺寸了,公屏同步下,尺寸是26:20
expLevelHeight = Utils.dip2px(context, 20);
expLevelWidth = expLevelHeight * 26 / 20;//expLevelHeight * 114 / 45
giftLength = Utils.dip2px(context, 35);
// 內容區域
layoutManger = new LinearLayoutManager(context, RecyclerView.VERTICAL, false);
@@ -993,8 +974,6 @@ public class MessageView extends FrameLayout {
setLuckyGiftServerNotifyMsg(chatRoomMessage, tvContent);
} else if (first == CUSTOM_MSG_GIFT_COMPOUND) {
setGiftCompoundMsg(chatRoomMessage, tvContent);
} else if (first == CUSTOM_MSG_FAIRY) {
setFairyMsg(chatRoomMessage, tvContent);
} else {
tvContent.setTextColor(Color.WHITE);
tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip));
@@ -1008,85 +987,6 @@ public class MessageView extends FrameLayout {
}
}
private void setFairyMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) {
if (chatRoomMessage.getAttachment() instanceof FairyMsgAttachment) {
FairyMsgAttachment attachment = (FairyMsgAttachment) chatRoomMessage.getAttachment();
FairyMsgInfoBean fairyMsgInfo = attachment.getFairyMsgInfo();
if (fairyMsgInfo == null) return;
SpannableBuilder builder = null;
switch (attachment.getSecond()) {
case CUSTOM_MSG_SUB_DRAW_GIFT_L1:
case CUSTOM_MSG_SUB_DRAW_GIFT_L2:
case CUSTOM_MSG_SUB_DRAW_BALL_L1:
builder = builderDrawMsg(tvContent, fairyMsgInfo, "厲害了!");
break;
case CUSTOM_MSG_SUB_DRAW_GIFT_L3:
case CUSTOM_MSG_SUB_DRAW_GIFT_L4:
case CUSTOM_MSG_SUB_DRAW_GIFT_L5:
case CUSTOM_MSG_SUB_DRAW_BALL_L2:
case CUSTOM_MSG_SUB_DRAW_BALL_L3:
builder = builderDrawMsg(tvContent, fairyMsgInfo, "好運爆棚!");
break;
case CUSTOM_MSG_SUB_CONVERT_L1:
builder = builderConvertMsg(tvContent, fairyMsgInfo, "初級召喚");
break;
case CUSTOM_MSG_SUB_CONVERT_L2:
builder = builderConvertMsg(tvContent, fairyMsgInfo, "史詩召喚");
break;
case CUSTOM_MSG_SUB_CONVERT_L3:
builder = builderConvertMsg(tvContent, fairyMsgInfo, "傳說召喚");
break;
}
if (builder != null) {
if (GoldBoxHelper.isShowFairy()) {
builder.append(" 去參加!", new OriginalDrawStatusClickSpan(Color.parseColor("#FFBC51")) {
@Override
public void onClick(@NonNull View widget) {
HomeFairyActivity.start(mContext);
}
});
}
tvContent.setOnClickListener(null);
tvContent.setMovementMethod(new LinkMovementMethod());
tvContent.setText(builder.build());
}
}
}
private SpannableBuilder builderConvertMsg(TextView textView, @NonNull FairyMsgInfoBean fairyMsgInfo, String type) {
return new SpannableBuilder(textView)
.append("厲害了!", new ForegroundColorSpan(whiteColor))
.append(StringExtensionKt.subAndReplaceDot(fairyMsgInfo.getNick(), 7), new OriginalDrawStatusClickSpan(roomTipNickColor, false) {
@Override
public void onClick(@NonNull View widget) {
RxBus.get().post(new ShowUserInfoDialogEvent(String.valueOf(fairyMsgInfo.getUid())));
}
})
.append("在奪寶精靈中 " + type, new ForegroundColorSpan(whiteColor))
.append(fairyMsgInfo.getRewardShowValue() + "" + fairyMsgInfo.getRewardName(), new ForegroundColorSpan(roomTipColor));
}
private SpannableBuilder builderDrawMsg(TextView textView, @NonNull FairyMsgInfoBean fairyMsgInfo, String desc) {
SpannableBuilder builder = new SpannableBuilder(textView)
.append(desc, new ForegroundColorSpan(whiteColor))
.append(StringExtensionKt.subAndReplaceDot(fairyMsgInfo.getNick(), 7), new OriginalDrawStatusClickSpan(roomTipNickColor, false) {
@Override
public void onClick(@NonNull View widget) {
RxBus.get().post(new ShowUserInfoDialogEvent(String.valueOf(fairyMsgInfo.getUid())));
}
})
.append(" 在奪寶精靈中獲得 ", new ForegroundColorSpan(whiteColor))
.append(fairyMsgInfo.getRewardName(), new ForegroundColorSpan(Color.WHITE));
if (fairyMsgInfo.getRewardNum() > 1) {
builder.append(" x" + fairyMsgInfo.getRewardNum(), new ForegroundColorSpan(roomTipNickColor));
}
return builder;
}
@SuppressLint("CheckResult")
private void setGiftCompoundMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) {
if (chatRoomMessage.getAttachment() instanceof GiftCompoundAttachment) {
@@ -1310,26 +1210,15 @@ public class MessageView extends FrameLayout {
private void setTarotMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) {
TarotAttachment attachment = (TarotAttachment) chatRoomMessage.getAttachment();
TarotMsgBean tarotMsgBean = attachment.getTarotMsgBean();
String nickName = RegexUtil.getPrintableString(tarotMsgBean.getNick());
SpannableBuilder text = new SpannableBuilder(tvContent);
switch (attachment.getSecond()) {
case CustomAttachment.CUSTOM_MESS_TAROT_SUCCESS:
text.append(ResUtil.getString(R.string.avroom_widget_messageview_026), new ForegroundColorSpan(textColor))
.append(nickName, new ForegroundColorSpan(roomTipNickColor))
.append(" " + tarotMsgBean.getDrawMsgText(), new ForegroundColorSpan(textColor))
.append(tarotMsgBean.getDrawGoldNum() + ResUtil.getString(R.string.avroom_widget_messageview_027), new ForegroundColorSpan(roomTipColor));
tvContent.setText(text.build());
break;
case CustomAttachment.CUSTOM_MESS_TAROT_JUNIOR_PRIZE_WINNING:
case CustomAttachment.CUSTOM_MESS_TAROT_INTERMEDIATE_PRIZE_WINNING:
case CustomAttachment.CUSTOM_MESS_TAROT_SENIOR_PRIZE_WINNING:
text.append(ResUtil.getString(R.string.avroom_widget_messageview_026), new ForegroundColorSpan(textColor))
.append(nickName, new ForegroundColorSpan(roomTipNickColor))
.append(ResUtil.getString(R.string.avroom_widget_messageview_0160), new ForegroundColorSpan(textColor))
.append(tarotMsgBean.getDrawGoldNum() + ResUtil.getString(R.string.avroom_widget_messageview_027), new ForegroundColorSpan(roomTipColor));
tvContent.setText(text.build());
break;
if (attachment.getSecond() == CustomAttachment.CUSTOM_MESS_TAROT_SUCCESS) {
TarotMsgBean tarotMsgBean = attachment.getTarotMsgBean();
String nickName = RegexUtil.getPrintableString(tarotMsgBean.getNick());
SpannableBuilder text = new SpannableBuilder(tvContent)
.append(ResUtil.getString(R.string.avroom_widget_messageview_026), new ForegroundColorSpan(textColor))
.append(nickName, new ForegroundColorSpan(roomTipNickColor))
.append(" " + tarotMsgBean.getDrawMsgText(), new ForegroundColorSpan(textColor))
.append(tarotMsgBean.getDrawGoldNum() + ResUtil.getString(R.string.avroom_widget_messageview_027), new ForegroundColorSpan(roomTipColor));
tvContent.setText(text.build());
}
}
@@ -1803,7 +1692,7 @@ public class MessageView extends FrameLayout {
SpannableBuilder text = new SpannableBuilder(tvContent)
.append(ResUtil.getString(R.string.avroom_widget_messageview_093), new ForegroundColorSpan(greyColor))
.append(attachment.getNick() + " ", new ForegroundColorSpan(roomTipColor))
.append(ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(R.string.avroom_widget_messageview_095), new ForegroundColorSpan(greyColor))
.append(ResUtil.getString(R.string.avroom_widget_messageview_094) + attachment.getBoxTypeStr() + ResUtil.getString(R.string.avroom_widget_messageview_095), new ForegroundColorSpan(greyColor))
.append(attachment.getPrizeName(), new ForegroundColorSpan(Color.WHITE));
if (attachment.getPrizeNum() > 1) {
text.append(" x" + attachment.getPrizeNum() + " ", new ForegroundColorSpan(roomTipColor));
@@ -2112,7 +2001,7 @@ public class MessageView extends FrameLayout {
builder.append(ivOfficialMask, SizeUtils.dp2px(tvContent.getContext(), 62), expLevelHeight);
}
//等級
builder.append(userLevel, expLevelHeight);
builder.append(userLevel, expLevelWidth, expLevelHeight);
//銘牌
String tvNamePlate = NobleUtil.getNamePlate(UserInfo.NAMEPLATE_WORD, chatRoomMessage).trim();
String ivNamePlate = NobleUtil.getNamePlate(UserInfo.NAMEPLATE_PIC, chatRoomMessage);

View File

@@ -65,7 +65,7 @@ public class MicroView extends LinearLayout implements View.OnLayoutChangeListen
private boolean isNeedResetMicCenterPoint = true;
private DatingItemDecoration datingItemDecoration;
private OnMicroItemClickListener onMicroItemClickListener = null;
private OnMicroItemClickListener onMicroItemClickListener;
public MicroView(Context context) {
this(context, null);
@@ -224,7 +224,7 @@ public class MicroView extends LinearLayout implements View.OnLayoutChangeListen
}
if (isNeedSetBackground) {
AnimFactory.getSpeakingAnimation(mContext, speakState.getWidth(), speakState.getHeight(),
NobleUtil.getColor(halo), speakState.getWidth() * 3 / 4)
NobleUtil.getColor(halo), speakState.getWidth() * 3 / 4)
.subscribe((animationDrawable, throwable) -> {
speakState.setBackground(animationDrawable);
animationDrawable.start();

View File

@@ -424,8 +424,6 @@ public class PKBoardView extends RelativeLayout implements View.OnClickListener
pkScoreBoardDialog.show();
}
break;
default:
break;
}
}

View File

@@ -41,12 +41,9 @@ import com.yizhuan.xchat_android_constants.XChatConstants
import com.yizhuan.xchat_android_core.auth.AuthModel
import com.yizhuan.xchat_android_core.decoration.car.bean.CarInfo
import com.yizhuan.xchat_android_core.im.custom.bean.*
import com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY
import com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager
import com.yizhuan.xchat_android_core.manager.RoomEvent
import com.yizhuan.xchat_android_core.monsterhunting.SimpleAnimationListener
import com.yizhuan.xchat_android_core.room.bean.DatingNotifyInfo
import com.yizhuan.xchat_android_core.super_admin.util.SuperAdminUtil
import com.yizhuan.xchat_android_core.user.UserModel
@@ -54,7 +51,6 @@ import com.yizhuan.xchat_android_core.user.bean.UserInfo
import com.yizhuan.xchat_android_core.utils.subAndReplaceDot
import com.yizhuan.xchat_android_library.utils.ListUtils
import com.yizhuan.xchat_android_library.utils.ResUtil
import com.yizhuan.xchat_android_library.utils.StringUtils
import io.reactivex.Observable
import io.reactivex.ObservableEmitter
import io.reactivex.ObservableOnSubscribe
@@ -76,8 +72,7 @@ class RoomEffectBoxView @JvmOverloads constructor(
private val mCarEffectList: MutableList<CarInfo?> by lazy { ArrayList() }
//頂部飄屏總展示時間
private val SHOW_TIME = 4500
private val CLOSE_TIME = 5000
private val SHOW_TIME = 3500
//頂部飄屏周期
private val PERIOD = 1000
@@ -90,6 +85,9 @@ class RoomEffectBoxView @JvmOverloads constructor(
private var boxDisposable: Disposable? = null
private val messagesBox: MutableList<ChatRoomMessage> by lazy { ArrayList() }
private var boxSVGADisposable: Disposable? = null
private val messagesBoxSVGA: MutableList<ChatRoomMessage> by lazy { ArrayList() }
private var animationLuckyGift: Animation? = null
private var disposableLuckyGift: Disposable? = null
private val messagesLuckyGift: MutableList<ChatRoomMessage> by lazy { ArrayList() }
@@ -152,21 +150,21 @@ class RoomEffectBoxView @JvmOverloads constructor(
if (roomEvent == null || AvRoomDataManager.get().isSelfGamePlaying) return@subscribe
when (roomEvent.event) {
RoomEvent.BOX_NOTIFY -> addBoxNotify(roomEvent.chatRoomMessage)
RoomEvent.BOX_NOTIFY_SVGA -> addBoxNotify(roomEvent.chatRoomMessage)
RoomEvent.DATING_ALL_NOTIFY -> addDatingAllNotify(roomEvent.chatRoomMessage)
RoomEvent.BOX_NOTIFY_SVGA -> addBoxNotifyBySVGA(roomEvent.chatRoomMessage)
RoomEvent.RADISH_NOTIFY,
RoomEvent.RADISH_NOTIFY_SVGA -> addRadishNotify(roomEvent.chatRoomMessage)
RoomEvent.ROOM_GIFT_COMPOUND -> addGiftCompoundNotify(roomEvent.chatRoomMessage)
RoomEvent.RECEIVE_ROOM_LUCKY_BAG_NOTICE, RoomEvent.RECEIVE_SERVICE_LUCKY_BAG_NOTICE -> //全服福袋
//廳內福袋
addLuckyBagNotify(roomEvent.chatRoomMessage)
RoomEvent.DATING_PUBLISH_RESULT -> showHandAnim((roomEvent.chatRoomMessage.attachment as DatingAttachment).datingNotifyInfo)
RoomEvent.RECEIVE_MEMBER_IN_NOTICE -> //進入房間
addMemberInNotify(roomEvent.chatRoomMessage)
RoomEvent.RECEIVE_EXPER_LEVEL_UP_NOTICE -> addLevelUpNotify(roomEvent.chatRoomMessage)
RoomEvent.ENTER_ROOM -> if (!SuperAdminUtil.isSuperAdmin()) {
playCarSvga(AuthModel.get().currentUid.toString(), null, true)
}
RoomEvent.CAR_MEMBER_IN -> if (roomEvent.mRoomCarMsgAttachment != null) {
playCarSvga(
null,
@@ -178,20 +176,17 @@ class RoomEffectBoxView @JvmOverloads constructor(
false
)
}
RoomEvent.ROOM_PK_NOTIFY -> addRoomPKNotify(roomEvent.chatRoomMessage)
RoomEvent.SINGLE_ROOM_PK_NOTIFY -> addSingleRoomPKNotify(roomEvent.chatRoomMessage)
RoomEvent.SINGLE_ROOM_RANK_TOP_NOTIFY -> showRoomRankNotify(roomEvent.chatRoomMessage)
RoomEvent.SINGLE_ROOM_RANK_TOP_NOTIFY -> showSingleRoomRankNotify(roomEvent.chatRoomMessage)
RoomEvent.ROOM_RANK_TOP_NOTIFY -> showRoomRankNotify(roomEvent.chatRoomMessage)
RoomEvent.ROOM_CAR_EFFECT_HIDE -> {
isHideCarEffect = true
loopCarAnim()
}
RoomEvent.ROOM_CAR_EFFECT_SHOW -> {
isHideCarEffect = false
}
RoomEvent.DRAW_GIFT_EFFECT -> {
val drawGiftAttachment =
(roomEvent.chatRoomMessage?.attachment as? DrawGiftAttachment)
@@ -202,7 +197,6 @@ class RoomEffectBoxView @JvmOverloads constructor(
false
)
}
else -> {}
}
}
@@ -231,13 +225,11 @@ class RoomEffectBoxView @JvmOverloads constructor(
if (disposableDatingAll == null || messagesDatingAll.size == 1) {
disposableDatingAll = Observable.interval(0, 3, TimeUnit.SECONDS)
.observeOn(AndroidSchedulers.mainThread())
.takeWhile { messagesDatingAll.size > 0 && !mContext.isDestroyed() }
.takeWhile { messagesDatingAll.size > 0 }
.subscribe {
if (binding.flDatingAllNotify.childCount == 0) {
showDatingAllNotify(
messagesDatingAll.removeAt(0)
)
}
showDatingAllNotify(
messagesDatingAll.removeAt(0)
)
}
}
}
@@ -300,6 +292,115 @@ class RoomEffectBoxView @JvmOverloads constructor(
) + ""
}
/**
* 開福袋飄屏
*
* @param chatRoomMessage
*/
private fun addLuckyBagNotify(chatRoomMessage: ChatRoomMessage) {
if (binding.clNotify.visibility == GONE) {
binding.clNotify.visibility = VISIBLE
}
messagesLuckyGift.add(chatRoomMessage)
if (disposableLuckyGift == null || messagesLuckyGift.size == 1) {
disposableLuckyGift = Observable.interval(0, PERIOD.toLong(), TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.takeWhile { messagesLuckyGift.size > 0 }
.subscribe {
showLuckyBagNotify(
messagesLuckyGift.removeAt(0)
)
}
}
}
private fun showLuckyBagNotify(message: ChatRoomMessage?) {
val attachment = message?.attachment as? RoomReceivedLuckyGiftAttachment ?: return
val noticeInfo = attachment.luckyBagNoticeInfo ?: return
val text = SpannableBuilder()
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_04),
ForegroundColorSpan(Color.WHITE)
)
.append(
noticeInfo.nick.subAndReplaceDot(6) + " ",
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
)
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_05),
ForegroundColorSpan(Color.WHITE)
)
.append(
noticeInfo.luckyBagName + " ",
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
)
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_06),
ForegroundColorSpan(Color.WHITE)
)
.append(
noticeInfo.goldPrice + " ",
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
)
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_07),
ForegroundColorSpan(Color.WHITE)
)
.append(
noticeInfo.giftName,
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
)
val svgaImageView = SVGAImageView(mContext)
svgaImageView.loops = 1
svgaImageView.clearsAfterStop = true
shareParser().decodeFromAssets(
"svga/lucky_gift_notify.svga",
object : SVGAParser.ParseCompletion {
override fun onComplete(videoItem: SVGAVideoEntity) {
binding.flLuckyGiftNotify.addView(svgaImageView)
val dynamicEntity = SVGADynamicEntity()
val textPaint = TextPaint()
textPaint.color = Color.WHITE //字體顏色
textPaint.textSize = 24f //字體大小
dynamicEntity.setDynamicText(
StaticLayout(
text.build(),
0,
text.build().length,
textPaint,
0,
Layout.Alignment.ALIGN_CENTER,
1.0f,
0.0f,
false
), "fdpp_copywriting"
)
if (AvRoomDataManager.get().roomUid == noticeInfo.roomUid) {
dynamicEntity.setHidden(true, "img_206")
} else {
svgaImageView.setOnClickListener {
//跳轉房間要移除監聽,不然可能NPE
svgaImageView.callback = null
AVRoomActivity.start(mContext, noticeInfo.roomUid)
}
}
val drawable = SVGADrawable(videoItem, dynamicEntity)
svgaImageView.setImageDrawable(drawable)
svgaImageView.stepToFrame(0, true)
}
override fun onError() {}
})
svgaImageView.callback = object : SimpleSvgaCallback() {
override fun onFinished() {
binding.flLuckyGiftNotify.post {
binding.flLuckyGiftNotify.removeView(svgaImageView)
}
}
}
}
/**
* 幸運池飄屏
*
@@ -313,20 +414,11 @@ class RoomEffectBoxView @JvmOverloads constructor(
if (boxDisposable == null || messagesBox.size == 1) {
boxDisposable = Observable.interval(0, PERIOD.toLong(), TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.takeWhile { messagesBox.size > 0 && !mContext.isDestroyed() }
.takeWhile { messagesBox.size > 0 }
.subscribe {
if (binding.flBoxNotify.childCount == 0) {
val msg = messagesBox.removeAt(0)
val attachment = msg.attachment
if (attachment is CustomAttachment) {
if (attachment.second == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY) {
showBoxNotify(msg)
} else if(attachment.second == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
showBoxNotifyBySVGA(msg)
}
}
}
showBoxNotify(
messagesBox.removeAt(0)
)
}
}
}
@@ -341,17 +433,17 @@ class RoomEffectBoxView @JvmOverloads constructor(
ForegroundColorSpan(Color.WHITE)
)
.append(
attachment.nick.subAndReplaceDot(8),
attachment.nick + " ",
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
)
.append(
ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(
ResUtil.getString(R.string.avroom_widget_roomeffectview_09) + attachment.boxTypeStr + ResUtil.getString(
R.string.avroom_widget_roomeffectview_010
), ForegroundColorSpan(Color.WHITE)
)
.append(
attachment.prizeName,
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
ForegroundColorSpan(resources.getColor(R.color.color_00EAFF))
)
if (attachment.prizeNum > 1) {
text.append("x" + attachment.prizeNum, ForegroundColorSpan(Color.WHITE))
@@ -361,15 +453,31 @@ class RoomEffectBoxView @JvmOverloads constructor(
binding.flBoxNotify.addView(textView)
textView.startAnimation(animationBox)
binding.flBoxNotify.postDelayed(
{
animationBox = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
textView.startAnimation(animationBox)
},
{ binding.flBoxNotify.removeView(textView) },
SHOW_TIME.toLong()
)
binding.flBoxNotify.postDelayed({
binding.flBoxNotify.removeView(textView)
}, CLOSE_TIME.toLong())
}
/**
* 幸運池飄屏 五級 SVGA背景的
*
* @param chatRoomMessage
*/
private fun addBoxNotifyBySVGA(chatRoomMessage: ChatRoomMessage) {
if (binding.clNotify.visibility == GONE) {
binding.clNotify.visibility = VISIBLE
}
messagesBoxSVGA.add(chatRoomMessage)
if (boxSVGADisposable == null || messagesBoxSVGA.size == 1) {
boxSVGADisposable = Observable.interval(0, PERIOD.toLong(), TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.takeWhile { messagesBoxSVGA.size > 0 }
.subscribe {
showBoxNotifyBySVGA(
messagesBoxSVGA.removeAt(0)
)
}
}
}
private fun showBoxNotifyBySVGA(chatRoomMessage: ChatRoomMessage) {
@@ -380,41 +488,32 @@ class RoomEffectBoxView @JvmOverloads constructor(
ForegroundColorSpan(Color.WHITE)
)
.append(
StringUtils.abbreviate(attachment.nick, 8) + " ",
attachment.nick + " ",
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
)
.append(
ResUtil.getString(R.string.treasure_in_find_love) + ResUtil.getString(
ResUtil.getString(R.string.avroom_widget_roomeffectview_012) + attachment.boxTypeStr + ResUtil.getString(
R.string.avroom_widget_roomeffectview_013
), ForegroundColorSpan(Color.WHITE)
)
.append(
attachment.prizeName,
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
ForegroundColorSpan(resources.getColor(R.color.color_00EAFF))
)
if (attachment.prizeNum > 1) {
text.append("x" + attachment.prizeNum, ForegroundColorSpan(Color.WHITE))
}
val svgaImageView = SVGAImageView(mContext)
svgaImageView.loops = 1
svgaImageView.clearsAfterDetached = true
svgaImageView.clearsAfterStop = true
val params = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
svgaImageView.layoutParams = params
svgaImageView.callback = object : SimpleSvgaCallback() {
override fun onFinished() {
animationBox = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
animationBox!!.setAnimationListener(object : SimpleAnimationListener() {
override fun onAnimationEnd(animation: Animation?) {
binding.flBoxNotify.removeView(svgaImageView)
}
})
binding.flBoxNotify.startAnimation(animationBox)
binding.flSvgaBoxNotify.post { binding.flSvgaBoxNotify.removeView(svgaImageView) }
}
}
animationBox = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
binding.flBoxNotify.addView(svgaImageView)
binding.flBoxNotify.startAnimation(animationBox)
binding.flSvgaBoxNotify.addView(svgaImageView)
shareParser().decodeFromAssets("svga/box_notify.svga", object : SVGAParser.ParseCompletion {
override fun onComplete(videoItem: SVGAVideoEntity) {
val dynamicEntity = SVGADynamicEntity()
@@ -432,7 +531,7 @@ class RoomEffectBoxView @JvmOverloads constructor(
1.0f,
0.0f,
false
), "bg"
), "noble_text_tx"
)
val drawable = SVGADrawable(videoItem, dynamicEntity)
svgaImageView.setImageDrawable(drawable)
@@ -456,11 +555,9 @@ class RoomEffectBoxView @JvmOverloads constructor(
if (radishDisposable == null || messagesRadish.size == 1) {
radishDisposable = Observable.interval(0, PERIOD.toLong(), TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.takeWhile { messagesRadish.size > 0 && !mContext.isDestroyed() }
.takeWhile { messagesRadish.size > 0 }
.subscribe {
if (binding.flRadishNotify.childCount == 0) {
showRadishNotify(messagesRadish.removeAt(0))
}
showRadishNotify(messagesRadish.removeAt(0))
}
}
}
@@ -536,11 +633,9 @@ class RoomEffectBoxView @JvmOverloads constructor(
if (radishSVGADisposable == null || messagesRadishSVGA.size == 1) {
radishSVGADisposable = Observable.interval(0, PERIOD.toLong(), TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.takeWhile { messagesRadishSVGA.size > 0 && !mContext.isDestroyed() }
.takeWhile { messagesRadishSVGA.size > 0 }
.subscribe {
if (binding.flSvgaRadishNotify.childCount == 0) {
showRadishNotifyBySVGA(messagesRadishSVGA.removeAt(0))
}
showRadishNotifyBySVGA(messagesRadishSVGA.removeAt(0))
}
}
}
@@ -624,11 +719,11 @@ class RoomEffectBoxView @JvmOverloads constructor(
if (disposableGiftCompound == null || messagesGiftCompound.size == 1) {
disposableGiftCompound = Observable.interval(0, PERIOD.toLong(), TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.takeWhile { messagesGiftCompound.size > 0 && !mContext.isDestroyed() }
.takeWhile { messagesGiftCompound.size > 0 }
.subscribe {
if (binding.flGiftCompoundNotify.childCount == 0) {
showGiftCompoundNotify(messagesGiftCompound.removeAt(0))
}
showGiftCompoundNotify(
messagesGiftCompound.removeAt(0)
)
}
}
}
@@ -700,9 +795,11 @@ class RoomEffectBoxView @JvmOverloads constructor(
if (disposableMemberIn == null || messagesMemberIn.size == 1) {
disposableMemberIn = Observable.interval(0, 6, TimeUnit.SECONDS)
.observeOn(AndroidSchedulers.mainThread())
.takeWhile { messagesMemberIn.size > 0 && !mContext.isDestroyed() }
.takeWhile { messagesMemberIn.size > 0 }
.subscribe {
showMemberInNotify(messagesMemberIn.removeAt(0))
showMemberInNotify(
messagesMemberIn.removeAt(0)
)
}
}
}
@@ -832,9 +929,11 @@ class RoomEffectBoxView @JvmOverloads constructor(
if (disposableLevelUp == null || messagesLevelUp.size == 1) {
disposableLevelUp = Observable.interval(0, 6, TimeUnit.SECONDS)
.observeOn(AndroidSchedulers.mainThread())
.takeWhile { messagesLevelUp.size > 0 && !mContext.isDestroyed() }
.takeWhile { messagesLevelUp.size > 0 }
.subscribe {
showLevelUpNotify(messagesLevelUp.removeAt(0))
showLevelUpNotify(
messagesLevelUp.removeAt(0)
)
}
}
}
@@ -1131,11 +1230,11 @@ class RoomEffectBoxView @JvmOverloads constructor(
if (disposableRoomPK == null || messagesRoomPK.size == 1) {
disposableRoomPK = Observable.interval(0, 4, TimeUnit.SECONDS)
.observeOn(AndroidSchedulers.mainThread())
.takeWhile { messagesRoomPK.size > 0 && !mContext.isDestroyed() }
.takeWhile { messagesRoomPK.size > 0 }
.subscribe {
if (binding.flRoomPkNotify.childCount == 0) {
showRoomPKNotify(messagesRoomPK.removeAt(0))
}
showRoomPKNotify(
messagesRoomPK.removeAt(0)
)
}
}
}
@@ -1177,11 +1276,11 @@ class RoomEffectBoxView @JvmOverloads constructor(
if (disposableSingleRoomPK == null || messagesSingleRoomPK.size == 1) {
disposableSingleRoomPK = Observable.interval(0, 4, TimeUnit.SECONDS)
.observeOn(AndroidSchedulers.mainThread())
.takeWhile { messagesSingleRoomPK.size > 0 && !mContext.isDestroyed() }
.takeWhile { messagesSingleRoomPK.size > 0 }
.subscribe {
if (binding.flSingleRoomPkNotify.childCount == 0) {
showSingleRoomPKNotify(messagesSingleRoomPK.removeAt(0))
}
showSingleRoomPKNotify(
messagesSingleRoomPK.removeAt(0)
)
}
}
}
@@ -1211,6 +1310,27 @@ class RoomEffectBoxView @JvmOverloads constructor(
)
}
private fun showSingleRoomRankNotify(chatRoomMessage: ChatRoomMessage) {
if (binding.clNotify.visibility == GONE) {
binding.clNotify.visibility = VISIBLE
}
val roomPkBean = (chatRoomMessage.attachment as SingleRoomRankAttachment).msgBean
val rootView =
LayoutInflater.from(mContext).inflate(R.layout.layout_single_room_rank_notify, null)
(rootView.findViewById<View>(R.id.tv_nick) as TextView).text =
roomPkBean.nick.subAndReplaceDot(6)
(rootView.findViewById<View>(R.id.tv_desc) as TextView).text = roomPkBean.desc
rootView.findViewById<ImageView>(R.id.iv_avatar).load(roomPkBean.avatar)
rootView.setOnClickListener { AVRoomActivity.start(context, roomPkBean.uid) }
binding.flSingleRoomRankNotify.addView(rootView)
animationLuckyGift = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
rootView.startAnimation(animationLuckyGift)
binding.flSingleRoomRankNotify.postDelayed({
binding.flSingleRoomRankNotify.removeView(
rootView
)
}, SHOW_TIME.toLong())
}
private fun showRoomRankNotify(chatRoomMessage: ChatRoomMessage) {
if (binding.clNotify.visibility == GONE) {

View File

@@ -4,18 +4,7 @@ import static com.yizhuan.xchat_android_core.Constants.DEBUG_MAX_UID;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MESS_HEAD_NOBLE;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MESS_SUB_OPENNOBLE;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MESS_SUB_RENEWNOBLE;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_BOX;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAIRY;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_NOTIFY_H5_SUB_WHOLE_SERVICE;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_RED_PACKAGE;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_GIFT_L5;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_DIAMOND;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_VIP;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_VIP_USER_ALL_UPGRADE;
@@ -23,7 +12,6 @@ import static com.yizhuan.xchat_android_library.utils.UIUtils.getActivityByConte
import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.Dialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -35,7 +23,6 @@ import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.StyleSpan;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
@@ -78,8 +65,6 @@ import com.yizhuan.erban.common.permission.PermissionActivity;
import com.yizhuan.erban.common.widget.StatusLayout;
import com.yizhuan.erban.common.widget.dialog.DialogManager;
import com.yizhuan.erban.common.widget.dialog.DialogUiHelper;
import com.yizhuan.erban.treasure_box.activity.TreasureBoxActivity;
import com.yizhuan.erban.treasurefairy.HomeFairyActivity;
import com.yizhuan.erban.ui.im.avtivity.NimP2PMessageActivity;
import com.yizhuan.erban.ui.login.AddUserInfoActivity;
import com.yizhuan.erban.ui.login.LoginCodeActivity;
@@ -88,11 +73,6 @@ import com.yizhuan.erban.ui.pay.ChargeActivity;
import com.yizhuan.erban.ui.setting.ResetPasswordActivity;
import com.yizhuan.erban.ui.webview.CommonWebViewActivity;
import com.yizhuan.erban.ui.widget.DefaultToolBar;
import com.yizhuan.erban.ui.widget.dialog.AllPlayEffectDialog;
import com.yizhuan.erban.ui.widget.dialog.AllServiceGiftDialog;
import com.yizhuan.erban.ui.widget.dialog.AllServiceGiftLevelOneDialog;
import com.yizhuan.erban.ui.widget.dialog.AllServiceGiftLevelThreeDialog;
import com.yizhuan.erban.ui.widget.dialog.AllServiceGiftLevelTwoDialog;
import com.yizhuan.erban.ui.widget.dialog.AllServiceVipLevelUPDialog;
import com.yizhuan.erban.ui.widget.dialog.OpenNobleGlobalNoticeDialog;
import com.yizhuan.erban.utils.UserUtils;
@@ -101,21 +81,12 @@ import com.yizhuan.xchat_android_constants.XChatConstants;
import com.yizhuan.xchat_android_core.Constants;
import com.yizhuan.xchat_android_core.UriProvider;
import com.yizhuan.xchat_android_core.bean.BaseProtocol;
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagNoticeInfo;
import com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.NotifyH5Attachment;
import com.yizhuan.xchat_android_core.im.custom.bean.NotifyH5Info;
import com.yizhuan.xchat_android_core.im.custom.bean.PlayEffectInfo;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeInfo;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomLuckySeaMsgBean;
import com.yizhuan.xchat_android_core.im.custom.bean.TarotMsgBean;
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager;
import com.yizhuan.xchat_android_core.manager.RoomEvent;
import com.yizhuan.xchat_android_core.mentoring_relationship.event.GrabApprenticesEvent;
import com.yizhuan.xchat_android_core.newbie.NewbieHelloInfo;
import com.yizhuan.xchat_android_core.newbie.event.NewbieHelloDialogEvent;
import com.yizhuan.xchat_android_core.noble.AllServiceGiftProtocol;
import com.yizhuan.xchat_android_core.noble.NobleInfo;
import com.yizhuan.xchat_android_core.noble.NobleProtocol;
import com.yizhuan.xchat_android_core.pay.PayModel;
@@ -123,14 +94,12 @@ import com.yizhuan.xchat_android_core.pay.bean.WalletInfo;
import com.yizhuan.xchat_android_core.redpackage.RedPackageNotifyInfo;
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
import com.yizhuan.xchat_android_core.room.model.AvRoomModel;
import com.yizhuan.xchat_android_core.treasurefairy.FairyMsgInfoBean;
import com.yizhuan.xchat_android_core.user.UserModel;
import com.yizhuan.xchat_android_core.utils.net.RxHelper;
import com.yizhuan.xchat_android_core.vip.VipMessageInfo;
import com.yizhuan.xchat_android_library.common.util.DeviceUtil;
import com.yizhuan.xchat_android_library.rxbus.RxBus;
import com.yizhuan.xchat_android_library.utils.AppMetaDataUtil;
import com.yizhuan.xchat_android_library.utils.JavaUtil;
import com.yizhuan.xchat_android_library.utils.NetworkUtils;
import com.yizhuan.xchat_android_library.utils.ResUtil;
import com.yizhuan.xchat_android_library.utils.SingleToastUtil;
@@ -147,7 +116,6 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import io.reactivex.Observable;
@@ -179,12 +147,6 @@ public abstract class BaseActivity extends RxAppCompatActivity
private OpenNobleGlobalNoticeDialog mNoticeDialog;
private boolean isShowingChargeDialog;
private Dialog giftDialog;
private LinkedList<AllServiceGiftProtocol.DataBean> giftList;
private Dialog playEffectDialog;
private LinkedList<PlayEffectInfo> playEffectList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -198,6 +160,7 @@ public abstract class BaseActivity extends RxAppCompatActivity
if (roomEvent == null) return;
onReceiveChatRoomEvent(roomEvent);
}));
registerNimBroadcastMessage(true);
}
protected void onReceiveChatRoomEvent(RoomEvent roomEvent) {
@@ -367,45 +330,24 @@ public abstract class BaseActivity extends RxAppCompatActivity
@Override
protected void onStart() {
super.onStart();
registerNimBroadcastMessage(true);
}
@Override
protected void onStop() {
super.onStop();
registerNimBroadcastMessage(false);
}
@Override
protected void onDestroy() {
registerNimBroadcastMessage(false);
if (mCompositeDisposable != null) {
mCompositeDisposable.dispose();
mCompositeDisposable = null;
}
try {
if (mNoticeDialog != null && mNoticeDialog.isShowing()) {
mNoticeDialog.dismiss();
mNoticeDialog = null;
}
if (giftDialog != null && giftDialog.isShowing()) {
giftDialog.setOnDismissListener(null);
giftDialog.dismiss();
giftDialog = null;
}
if (playEffectDialog != null && playEffectDialog.isShowing()) {
playEffectDialog.setOnDismissListener(null);
playEffectDialog.dismiss();
playEffectDialog = null;
}
if (giftList != null) {
giftList.clear();
}
if(playEffectList != null){
playEffectList.clear();
}
} catch (Exception e){
Logger.i("关闭弹窗失败" + e.getMessage());
if (mNoticeDialog != null && mNoticeDialog.isShowing()) {
mNoticeDialog.dismiss();
mNoticeDialog = null;
}
super.onDestroy();
@@ -564,12 +506,6 @@ public abstract class BaseActivity extends RxAppCompatActivity
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::onRoomEventReceived);
if (giftList != null) {
giftList.clear();
}
if(playEffectList != null){
playEffectList.clear();
}
}
@Override
@@ -972,271 +908,11 @@ public abstract class BaseActivity extends RxAppCompatActivity
}
}
break;
case CUSTOM_MSG_HEADER_TYPE_GIFT:
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|| this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|| UserUtils.getUserInfo() == null)
return;
if (giftList == null) {
giftList = new LinkedList<>();
}
int second2 = baseProtocol.getSecond();
AllServiceGiftProtocol.DataBean data = JSON.parseObject(String.valueOf(baseProtocol.getData()), AllServiceGiftProtocol.DataBean.class);
if (data == null || data.getGiftUrl() == null) return;
giftList.add(data);
if (second2 == CUSTOM_MSG_ALL_SERVICE_GIFT) {
if (giftDialog != null && giftDialog.isShowing()) {
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst();
if (dataBean != null) {
return;
} else {
giftDialog.dismiss();
}
} else {
showGiftDialog();
}
}
break;
case CUSTOM_MSG_BOX://寻爱之旅
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|| this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|| UserUtils.getUserInfo() == null)
return;
if (playEffectList == null) {
playEffectList = new LinkedList<>();
}
RoomBoxPrizeInfo roomBoxPrizeInfo = JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomBoxPrizeInfo.class);
if (roomBoxPrizeInfo == null) return;
if (baseProtocol.getSecond() == CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
playEffectInfo.setSecond(CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA);
playEffectInfo.setRoomBoxPrizeInfo(roomBoxPrizeInfo);
playEffectList.add(playEffectInfo);
if (playEffectDialog != null && playEffectDialog.isShowing()) {
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
PlayEffectInfo dataBean = playEffectList.peekFirst();
if (dataBean != null) {
return;
} else {
playEffectDialog.dismiss();
}
} else {
showPlayEffectDialog();
}
}
break;
case CustomAttachment.CUSTOM_MESS_TAROT:
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|| this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|| UserUtils.getUserInfo() == null)
return;
if (playEffectList == null) {
playEffectList = new LinkedList<>();
}
if (baseProtocol.getSecond() == CustomAttachment.CUSTOM_MESS_TAROT_SENIOR_PRIZE_WINNING) {
TarotMsgBean tarotMsgBean = JSON.parseObject(String.valueOf(baseProtocol.getData()), TarotMsgBean.class);
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
playEffectInfo.setSecond(CustomAttachment.CUSTOM_MESS_TAROT_SENIOR_PRIZE_WINNING);
playEffectInfo.setTarotMsgBean(tarotMsgBean);
if (playEffectList == null) {
playEffectList = new LinkedList<>();
}
playEffectList.add(playEffectInfo);
if (playEffectDialog != null && playEffectDialog.isShowing()) {
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
PlayEffectInfo dataBean = playEffectList.peekFirst();
if (dataBean != null) {
return;
} else {
playEffectDialog.dismiss();
}
} else {
showPlayEffectDialog();
}
}
break;
case CustomAttachment.CUSTOM_MSG_NOTIFY_H5:
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|| this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|| UserUtils.getUserInfo() == null)
return;
if (baseProtocol.getSecond() == CustomAttachment.CUSTOM_MSG_NOTIFY_H5_SUB_WHOLE_SERVICE) {
NotifyH5Info bean = JSON.parseObject(String.valueOf(baseProtocol.getData()), NotifyH5Info.class);
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
playEffectInfo.setSecond(CUSTOM_MSG_NOTIFY_H5_SUB_WHOLE_SERVICE);
playEffectInfo.setNotifyH5(bean);
if (playEffectList == null) {
playEffectList = new LinkedList<>();
}
playEffectList.add(playEffectInfo);
if (playEffectDialog != null && playEffectDialog.isShowing()) {
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
PlayEffectInfo dataBean = playEffectList.peekFirst();
if (dataBean != null) {
return;
} else {
playEffectDialog.dismiss();
}
} else {
showPlayEffectDialog();
}
}
break;
case CUSTOM_MSG_LUCKY_SEA://星级厨房
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|| this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|| UserUtils.getUserInfo() == null)
return;
if (playEffectList == null) {
playEffectList = new LinkedList<>();
}
RoomLuckySeaMsgBean roomLuckySeaMsgBean = JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomLuckySeaMsgBean.class);
if (roomLuckySeaMsgBean == null) return;
if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL) {
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
playEffectInfo.setSecond(CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL);
playEffectInfo.setRoomLuckySeaMsgBean(roomLuckySeaMsgBean);
playEffectList.add(playEffectInfo);
if (playEffectDialog != null && playEffectDialog.isShowing()) {
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
PlayEffectInfo dataBean = playEffectList.peekFirst();
if (dataBean != null) {
return;
} else {
playEffectDialog.dismiss();
}
} else {
showPlayEffectDialog();
}
}
break;
case CUSTOM_MSG_LUCKY_GIFT://福袋
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|| this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|| UserUtils.getUserInfo() == null)
return;
if (playEffectList == null) {
playEffectList = new LinkedList<>();
}
LuckyBagNoticeInfo luckyBagNoticeInfo = JSON.parseObject(String.valueOf(baseProtocol.getData()), LuckyBagNoticeInfo.class);
if (luckyBagNoticeInfo == null) return;
if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL) {
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
playEffectInfo.setSecond(CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL);
playEffectInfo.setLuckyBagNoticeInfo(luckyBagNoticeInfo);
playEffectList.add(playEffectInfo);
if (playEffectDialog != null && playEffectDialog.isShowing()) {
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
PlayEffectInfo dataBean = playEffectList.peekFirst();
if (dataBean != null) {
return;
} else {
playEffectDialog.dismiss();
}
} else {
showPlayEffectDialog();
}
}
break;
case CUSTOM_MSG_FAIRY://夺宝精灵
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|| this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|| UserUtils.getUserInfo() == null)
return;
if (playEffectList == null) {
playEffectList = new LinkedList<>();
}
FairyMsgInfoBean fairyMsgInfo = JSON.parseObject(String.valueOf(baseProtocol.getData()), FairyMsgInfoBean.class);
if (fairyMsgInfo == null) return;
if (baseProtocol.getSecond() == CUSTOM_MSG_SUB_DRAW_GIFT_L5) {
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
playEffectInfo.setSecond(CUSTOM_MSG_SUB_DRAW_GIFT_L5);
playEffectInfo.setFairyMsgInfo(fairyMsgInfo);
playEffectList.add(playEffectInfo);
if (playEffectDialog != null && playEffectDialog.isShowing()) {
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
PlayEffectInfo dataBean = playEffectList.peekFirst();
if (dataBean != null) {
return;
} else {
playEffectDialog.dismiss();
}
} else {
showPlayEffectDialog();
}
}
break;
default:
break;
}
}
private void showPlayEffectDialog() {
if (playEffectList.size() == 0) return;
playEffectDialog = new AllPlayEffectDialog(this, playEffectList.peekFirst());
playEffectDialog.setOnDismissListener(dialog -> {
playEffectList.pollFirst();
PlayEffectInfo dataBean = playEffectList.peekFirst();
if (dataBean != null) {
if (isValid()) {
showPlayEffectDialog();
} else {
playEffectList.clear();
}
}
});
try {
playEffectDialog.show();
} catch (Exception e) {
e.printStackTrace();
}
}
private void showGiftDialog() {
if (giftList.size() == 0) return;
if (giftList.peekFirst() != null && !giftList.peekFirst().isHomeShow()) return;
giftDialog = generateAllServiceGiftDialog(this, giftList.peekFirst());
giftDialog.setOnDismissListener(dialog -> {
giftList.pollFirst();
AllServiceGiftProtocol.DataBean dataBean = giftList.peekFirst();
if (dataBean != null) {
if (isValid()) {
showGiftDialog();
} else {
giftList.clear();
}
}
});
try {
giftDialog.show();
} catch (Exception e) {
e.printStackTrace();
}
}
private 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);
}
}
public void onGrabApprenticesEvent(GrabApprenticesEvent event) {
if (!isTopActivity()) return;
if (dialog != null && dialog.isAdded()) {

View File

@@ -16,7 +16,7 @@ abstract class BaseDialog<T : ViewBinding> : RxDialogFragment() {
private var _binding: T? = null
private var onDismissListener: (() -> Unit)? = null
val binding get() = _binding
val binding get() = _binding!!
open var width = ScreenUtil.getDialogWidth()
open var height = WindowManager.LayoutParams.WRAP_CONTENT
open var gravity = Gravity.CENTER
@@ -42,7 +42,7 @@ abstract class BaseDialog<T : ViewBinding> : RxDialogFragment() {
val aClass = type.actualTypeArguments[0] as Class<*>
val method = aClass.getDeclaredMethod("inflate", LayoutInflater::class.java)
_binding = method.invoke(null, layoutInflater) as T
return binding?.root
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {

View File

@@ -2,18 +2,15 @@ package com.yizhuan.erban.base
import android.os.Bundle
import android.view.LayoutInflater
import androidx.annotation.Nullable
import androidx.viewbinding.ViewBinding
import java.lang.reflect.ParameterizedType
abstract class BaseViewBindingActivity<T : ViewBinding> : BaseActivity(){
lateinit var binding : T
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
this.initBefore(savedInstanceState)
//反射没有想象中的那么耗时
val type = javaClass.genericSuperclass as ParameterizedType
val aClass = type.actualTypeArguments[0] as Class<*>
@@ -23,10 +20,5 @@ abstract class BaseViewBindingActivity<T : ViewBinding> : BaseActivity(){
init()
}
/**
* 该方法是在onCreate()方法里执行在setContentView()方法被调用之前触发可用于处理解析Activity#getIntent()中的数据时的场景
*/
protected open fun initBefore(@Nullable savedInstanceState: Bundle?) {}
abstract fun init()
}

View File

@@ -1,27 +0,0 @@
package com.yizhuan.erban.base
/**
* Used as a wrapper for data that is exposed via a LiveData that represents an event.
*/
open class Event<out T>(private val content: T) {
var hasBeenHandled = false
private set // Allow external read but not write
/**
* Returns the content and prevents its use again.
*/
fun getContentIfNotHandled(): T? {
return if (hasBeenHandled) {
null
} else {
hasBeenHandled = true
content
}
}
/**
* Returns the content, even if it's already been handled.
*/
fun peekContent(): T = content
}

View File

@@ -20,7 +20,6 @@ import com.netease.nim.uikit.support.glide.GlideApp;
import com.yizhuan.erban.R;
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil;
import com.yizhuan.erban.view.GenderAgeTextView;
import com.yizhuan.xchat_android_core.utils.StarUtils;
import com.yizhuan.xchat_android_library.utils.TimeUtils;
import com.yizhuan.xchat_android_library.utils.config.BasicConfig;
@@ -84,6 +83,17 @@ public class ViewAdapter {
ImageLoadUtils.loadImage(imageView.getContext(), url, imageView);
}
@BindingAdapter(value = {"date"}, requireAll = false)
public static void setConstellation(TextView textView, long date) {
String star = StarUtils.getConstellation(new Date(date));
if (null == star) {
textView.setVisibility(View.GONE);
} else {
textView.setText(star);
textView.setVisibility(View.VISIBLE);
}
}
@BindingAdapter(value = {"isOn"}, requireAll = false)
public static void setIsOn(IOSSwitchView iosSwitchView, boolean isOn) {
iosSwitchView.setOn(isOn);
@@ -167,14 +177,4 @@ public class ViewAdapter {
params.height = (int) height;
v.setLayoutParams(params);
}
@BindingAdapter(value = {"birthday"}, requireAll = false)
public static void setBirthday(GenderAgeTextView v, long birthday) {
v.setBirthDay(birthday);
}
@BindingAdapter(value = {"gender"}, requireAll = false)
public static void setGender(GenderAgeTextView v, int gender) {
v.setGender(gender);
}
}

View File

@@ -14,7 +14,7 @@ import com.yizhuan.xchat_android_library.utils.ResUtil;
public class EmptyViewHelper {
public static View createEmptyTextView(Context context, String text) {
public static View createEmptyView(Context context, String text) {
if (!NetworkUtils.isNetworkAvailable(context)) text = ResUtil.getString(R.string.erban_common_emptyviewhelper_01);
View view = LayoutInflater.from(context).inflate(R.layout.layout_ktv_empty, null);
view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
@@ -22,22 +22,6 @@ public class EmptyViewHelper {
return view;
}
public static View createEmptyTextViewHeight(Context context, String text) {
if (!NetworkUtils.isNetworkAvailable(context)) text = ResUtil.getString(R.string.erban_common_emptyviewhelper_01);
View view = LayoutInflater.from(context).inflate(R.layout.layout_wrap_empty, null);
view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
((TextView) view.findViewById(R.id.tv_hint)).setText(text);
return view;
}
public static View createEmptyTextViewNoImage(Context context, String text) {
if (!NetworkUtils.isNetworkAvailable(context)) text = ResUtil.getString(R.string.erban_common_emptyviewhelper_01);
View view = LayoutInflater.from(context).inflate(R.layout.layout_text_empty, null);
view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
((TextView) view.findViewById(R.id.tv_hint)).setText(text);
return view;
}
public static View createDarkEmptyView(Context context, String text) {
if (!NetworkUtils.isNetworkAvailable(context)) text = ResUtil.getString(R.string.erban_common_emptyviewhelper_02);
View view = LayoutInflater.from(context).inflate(R.layout.layout_ktv_empty, null);

View File

@@ -108,10 +108,8 @@ public class ActivityStack {
if (mAvRoomActivity == null) {
mAvRoomActivity = new WeakReference<>(activity);
} else if (mAvRoomActivity.get() != activity) {
if(mAvRoomActivity != null) {
mAvRoomActivity.clear();
mAvRoomActivity = new WeakReference<>(activity);
}
mAvRoomActivity.clear();
mAvRoomActivity = new WeakReference<>(activity);
}
}
}
@@ -132,10 +130,8 @@ public class ActivityStack {
if (mAvRoomActivity == null) {
mAvRoomActivity = new WeakReference<>(activity);
} else if (mAvRoomActivity.get() != activity) {
if(mAvRoomActivity != null) {
mAvRoomActivity.clear();
mAvRoomActivity = new WeakReference<>(activity);
}
mAvRoomActivity.clear();
mAvRoomActivity = new WeakReference<>(activity);
}
}
}
@@ -153,10 +149,8 @@ public class ActivityStack {
break;
}
if (activity instanceof AVRoomActivity) {
if(mAvRoomActivity != null) {
mAvRoomActivity.clear();
mAvRoomActivity = null;
}
mAvRoomActivity.clear();
mAvRoomActivity = null;
}
}

View File

@@ -3,7 +3,6 @@ package com.yizhuan.erban.common.dialog
import android.Manifest
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.Settings
import android.text.TextUtils
@@ -74,14 +73,16 @@ class PhotoDialog : BaseDialogFragment<PhotoDialogBinding>(), EasyPermissions.Pe
private fun checkStoragePermission1() {
if (!EasyPermissions.hasPermissions(
XChatApplication.gContext, if (Build.VERSION.SDK_INT >= 33) Manifest.permission.READ_MEDIA_IMAGES else Manifest.permission.READ_EXTERNAL_STORAGE
XChatApplication.gContext, Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE
)
) {
EasyPermissions.requestPermissions(
this,
getString(R.string.permission_storage_rationale),
PERMISSION_CODE_STORAGE_1,
if (Build.VERSION.SDK_INT >= 33) Manifest.permission.READ_MEDIA_IMAGES else Manifest.permission.READ_EXTERNAL_STORAGE
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE
)
} else {
PhotoProviderNew.photoProvider(this, resultCode = REQUEST_CODE_OPEN_PHOTO_PROVIDER)
@@ -89,11 +90,7 @@ class PhotoDialog : BaseDialogFragment<PhotoDialogBinding>(), EasyPermissions.Pe
}
private fun checkCameraPermission() {
if (!EasyPermissions.hasPermissions(
XChatApplication.gContext,
Manifest.permission.CAMERA
)
) {
if (!EasyPermissions.hasPermissions(XChatApplication.gContext, Manifest.permission.CAMERA)) {
EasyPermissions.requestPermissions(
this,
getString(R.string.permission_camera_rationale),
@@ -107,15 +104,16 @@ class PhotoDialog : BaseDialogFragment<PhotoDialogBinding>(), EasyPermissions.Pe
private fun checkStoragePermission2() {
if (!EasyPermissions.hasPermissions(
XChatApplication.gContext, if (Build.VERSION.SDK_INT >= 33)
Manifest.permission.READ_MEDIA_IMAGES else Manifest.permission.READ_EXTERNAL_STORAGE
XChatApplication.gContext, Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE
)
) {
EasyPermissions.requestPermissions(
this,
getString(R.string.permission_storage_rationale),
PERMISSION_CODE_STORAGE_2,
if (Build.VERSION.SDK_INT >= 33) Manifest.permission.READ_MEDIA_IMAGES else Manifest.permission.READ_EXTERNAL_STORAGE
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE
)
} else {
PhotoProviderNew.photoCamera(this, REQUEST_CODE_OPEN_CAMERA_PROVIDER)

View File

@@ -8,6 +8,7 @@ import androidx.annotation.Nullable;
import com.adjust.sdk.Adjust;
import com.yizhuan.erban.application.XChatApplication;
import com.yizhuan.erban.location.LocationManager;
import com.yizhuan.xchat_android_core.auth.AuthModel;
import com.yizhuan.xchat_android_library.common.util.CoreUtils;
@@ -32,8 +33,12 @@ public class AppLifeCycleHelper implements Application.ActivityLifecycleCallback
AppLifeCycleHelper.onForeground();
//应用回到前台了
//这里进行暗号的判断
//PwdCodeMgr.get().handlePopPwdCodeWindow(activity);
if (AuthModel.get().isImLogin()) {
//签到弹窗
// SignDialogTimeManager.checkSignDialog(activity, true);
LocationManager.uploadLocation(activity);
}
}
}

View File

@@ -9,7 +9,6 @@ import androidx.annotation.NonNull;
public abstract class OriginalDrawStatusClickSpan extends ClickableSpan {
private final Integer mColor;
private final boolean underlineText;
public OriginalDrawStatusClickSpan() {
this(null);
@@ -17,19 +16,13 @@ public abstract class OriginalDrawStatusClickSpan extends ClickableSpan {
public OriginalDrawStatusClickSpan(@ColorInt Integer color) {
this.mColor = color;
this.underlineText = true;
}
public OriginalDrawStatusClickSpan(@ColorInt Integer color, boolean underlineText) {
this.mColor = color;
this.underlineText = underlineText;
}
@Override
public void updateDrawState(@NonNull TextPaint ds) {
if (mColor != null) {
ds.setColor(mColor);
ds.setUnderlineText(underlineText);
ds.setUnderlineText(true);
}
}

View File

@@ -54,7 +54,7 @@ class DecorationCommonFragment : BaseViewBindingFragment<FragmentDecorationCommo
.setAdapter(decorationAdapter)
.setRecyclerView(binding.recyclerView)
.setRefreshLayout(binding.swipeRefresh)
.setEmptyView(EmptyViewHelper.createEmptyTextView(mContext, ResUtil.getString(R.string.decoration_view_decorationcommonfragment_01)))
.setEmptyView(EmptyViewHelper.createEmptyView(mContext, ResUtil.getString(R.string.decoration_view_decorationcommonfragment_01)))
.setLayoutManager(
if (dressType == DecorationStoreActivity.TAB_USER_CARD) {
LinearLayoutManager(mContext)

View File

@@ -40,6 +40,10 @@ class DecorationViewModel : BaseViewModel() {
block = {
_decorationInfoListLiveData.value =
ListResult.success(DecorationModel.getDecorationInfoList(dressType), 1)
},
onError = {
it.message.toast()
_decorationInfoListLiveData.value = ListResult.failed(1)
}
)
}
@@ -50,7 +54,7 @@ class DecorationViewModel : BaseViewModel() {
block = {
DecorationModel.buyDecoration(dressType, dressId)
ResUtil.getString(R.string.decoration_viewmodel_decorationviewmodel_01).toast()
}
},
)
}

View File

@@ -9,10 +9,6 @@ import java.util.*
class EarnRecordViewModel : BaseViewModel() {
//是否个播
private val _queryRoomTypeLiveData = MutableLiveData<RoomTypeInfo?>()
val queryRoomTypeLiveData: MutableLiveData<RoomTypeInfo?> = _queryRoomTypeLiveData
//收益记录
private val _earnRecordLiveData = MutableLiveData<EarnRecordInfo?>()
val earnRecordLiveData: MutableLiveData<EarnRecordInfo?> = _earnRecordLiveData
@@ -96,18 +92,6 @@ class EarnRecordViewModel : BaseViewModel() {
mWeekChooseDay = weekChooseDay
}
/**
* 是否个播
*/
fun queryWithRoomType() {
safeLaunch(
false,
block = {
_queryRoomTypeLiveData.value = EarnModel.queryWithRoomType()
}
)
}
/**
* 收益记录
*/

View File

@@ -14,7 +14,6 @@ import com.yizhuan.erban.ui.pay.ChargeActivity
import com.yizhuan.erban.ui.webview.CommonWebViewActivity
import com.yizhuan.xchat_android_core.Constants
import com.yizhuan.xchat_android_core.UriProvider
import com.yizhuan.xchat_android_core.earn.bean.RoomTypeInfo
import com.yizhuan.xchat_android_library.common.util.DeviceUtil
import com.yizhuan.xchat_android_library.utils.AppMetaDataUtil
@@ -27,7 +26,6 @@ class EarnRecordActivity : BaseViewBindingActivity<ActivityEarnRecordBinding>(),
View.OnClickListener {
private val earnRecordModel: EarnRecordViewModel by viewModels()
private var roomTypeInfo: RoomTypeInfo ?= null
companion object {
@JvmStatic
@@ -46,6 +44,28 @@ class EarnRecordActivity : BaseViewBindingActivity<ActivityEarnRecordBinding>(),
else dialogManager.dismissDialog()
}
earnRecordModel.earnRecordLiveData.observe(this) {
it?.let {
binding.tvDiamondNum.text = String.format(it.diamonds.toString())
binding.tvGoldNum.text = String.format(it.golds.toString())
if (it.isClanElder) {
binding.tvGoldDetail.visibility = View.VISIBLE
binding.tvConvertDiamond.visibility = View.GONE
binding.csGoldBg.background =
ContextCompat.getDrawable(this, R.drawable.bg_gold_detail)
} else {
binding.tvGoldDetail.visibility = View.GONE
if (it.hasGoldExchangeAuth) {
binding.tvConvertDiamond.visibility = View.VISIBLE
} else {
binding.tvConvertDiamond.visibility = View.GONE
}
binding.csGoldBg.background =
ContextCompat.getDrawable(this, R.drawable.bg_earn_gold)
}
}
}
earnRecordModel.goldToDiamondLiveData.observe(this) {
it?.let {
ConvertDiamondActivity.start(this, it)
@@ -58,26 +78,11 @@ class EarnRecordActivity : BaseViewBindingActivity<ActivityEarnRecordBinding>(),
}
}
earnRecordModel.queryRoomTypeLiveData.observe(this) {
it?.let {
roomTypeInfo = it
binding.tvDiamondNum.text = String.format(it.diamonds.toString())
binding.tvGoldNum.text = String.format(it.golds.toString())
if (it.isClanElder) {
binding.csGoldBg.background =
ContextCompat.getDrawable(this, R.drawable.bg_gold_detail)
} else {
binding.csGoldBg.background =
ContextCompat.getDrawable(this, R.drawable.bg_earn_gold)
}
}
}
}
override fun onResume() {
super.onResume()
earnRecordModel.queryWithRoomType()
earnRecordModel.getEarnRecordInfo()
}
fun initListener() {
@@ -105,7 +110,7 @@ class EarnRecordActivity : BaseViewBindingActivity<ActivityEarnRecordBinding>(),
CommonWebViewActivity.start(context, UriProvider.getDiamondDetail())
}
R.id.tvGoldDetail -> {//金币明细
CommonWebViewActivity.start(context, UriProvider.getGoldDetail())
GoldDetailActivity.start(this)
}
R.id.tvConvertDiamond -> {//兑换钻石
earnRecordModel.getGoldToDiamondInfo()

View File

@@ -64,7 +64,7 @@ class GoldDetailActivity : BaseViewBindingActivity<ActivityGoldDetailBinding>(),
.setLayoutManager(LinearLayoutManager(context))
.setRecyclerView(binding.mRecyclerView)
.setEmptyView(
EmptyViewHelper.createEmptyTextView(
EmptyViewHelper.createEmptyView(
context,
getString(R.string.empty_data)
)

View File

@@ -53,7 +53,7 @@ class FansTeamJoinedActivity : BaseViewBindingActivity<ActivityFansTeamJoinedBin
.setLayoutManager(LinearLayoutManager(this))
.setRecyclerView(binding.rvTask)
.setAdapter(FansTeamTaskAdapter())
.setEmptyView(EmptyViewHelper.createEmptyTextView(this, ResUtil.getString(R.string.erban_fansteam_fansteamjoinedactivity_01)))
.setEmptyView(EmptyViewHelper.createEmptyView(this, ResUtil.getString(R.string.erban_fansteam_fansteamjoinedactivity_01)))
.build()
binding.llRank.setOnClickListener {

View File

@@ -41,7 +41,7 @@ class FansTeamListActivity : BaseViewBindingActivity<ActivityFansTeamListBinding
.setRecyclerView(binding.recyclerView)
.setAdapter(FansTeamListAdapter())
.setPageSize(pageSize)
.setEmptyView(EmptyViewHelper.createEmptyTextView(this, ResUtil.getString(R.string.erban_fansteam_fansteamlistactivity_02)))
.setEmptyView(EmptyViewHelper.createEmptyView(this, ResUtil.getString(R.string.erban_fansteam_fansteamlistactivity_02)))
.build()
binding.swipeRefresh.setOnRefreshListener {

View File

@@ -4,10 +4,12 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.yizhuan.erban.base.BaseViewModel
import com.yizhuan.xchat_android_core.bean.response.ListResult
import com.yizhuan.xchat_android_core.home.bean.*
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
import com.yizhuan.xchat_android_core.home.bean.HomeRoomInfo
import com.yizhuan.xchat_android_core.home.bean.HomeTabMapInfo
import com.yizhuan.xchat_android_core.home.bean.HomeTagInfo
import com.yizhuan.xchat_android_core.home.model.HomeModel
import com.yizhuan.xchat_android_core.room.bean.AnchorInfo
import com.yizhuan.xchat_android_core.user.bean.UserInfo
import com.yizhuan.xchat_android_core.utils.toast
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
@@ -20,15 +22,6 @@ class HomeViewModel : BaseViewModel() {
private val _bannerLiveData = MutableLiveData<List<BannerInfo>?>()
val bannerLiveData: MutableLiveData<List<BannerInfo>?> = _bannerLiveData
private val _currentResourceLiveData = MutableLiveData<List<CurrentResourceInfo>?>()
val currentResourceLiveData: MutableLiveData<List<CurrentResourceInfo>?> = _currentResourceLiveData
private val _resourceJumpLiveData = MutableLiveData<HomeRoomInfo?>()
val resourceJumpLiveData: LiveData<HomeRoomInfo?> = _resourceJumpLiveData
private val _homeChatPickLiveData = MutableLiveData<String?>()
val homeChatPickLiveData: LiveData<String?> = _homeChatPickLiveData
private val _gameRoomLiveData = MutableLiveData<ListResult<HomeRoomInfo>>()
val gameRoomLiveData: LiveData<ListResult<HomeRoomInfo>> = _gameRoomLiveData
@@ -56,11 +49,8 @@ class HomeViewModel : BaseViewModel() {
private val _homePlayInfoLiveData = MutableLiveData<List<HomeRoomInfo>?>()
val homePlayInfoData: MutableLiveData<List<HomeRoomInfo>?> = _homePlayInfoLiveData
private val _homeHotRoomLiveData = MutableLiveData<ListResult<HomeRoomInfo>>()
val homeHotRoomLiveData: LiveData<ListResult<HomeRoomInfo>> = _homeHotRoomLiveData
private val _newFriendLiveData = MutableLiveData<ListResult<UserInfo>>()
val newFriendLiveData: LiveData<ListResult<UserInfo>> = _newFriendLiveData
private val _homeHotRoomLiveData = MutableLiveData<List<HomeRoomInfo>?>()
val homeHotRoomLiveData: LiveData<List<HomeRoomInfo>?> = _homeHotRoomLiveData
fun getHomeTabName() {
safeLaunch(
@@ -73,44 +63,6 @@ class HomeViewModel : BaseViewModel() {
)
}
/**
* 首页改版资源位
*/
fun getCurrentResourceInfo() {
safeLaunch(
onError = {
_currentResourceLiveData.value = null
},
block = {
_currentResourceLiveData.value = HomeModel.getCurrentResource()
}
)
}
fun getResourceJumpInfo(id: Int) {
safeLaunch(
onError = {
_resourceJumpLiveData.value = null
it.message.toast()
},
block = {
_resourceJumpLiveData.value = HomeModel.getResourceJumpInfo(id)
}
)
}
fun getHomeChatPick() {
safeLaunch(
onError = {
_homeChatPickLiveData.value = null
it.message.toast()
},
block = {
_homeChatPickLiveData.value = HomeModel.getHomeChatPick()
}
)
}
fun getBannerInfo() {
safeLaunch(
onError = {
@@ -225,23 +177,10 @@ class HomeViewModel : BaseViewModel() {
fun getHotRoom() {
safeLaunch(
onError = {
_homeHotRoomLiveData.value = ListResult.failed(1)
_homeHotRoomLiveData.value = null
},
block = {
val result = HomeModel.getHotRoom()
_homeHotRoomLiveData.value = ListResult.success(result, 1)
}
)
}
fun getNewFriendList(gender: Int? = null) {
safeLaunch(
onError = {
_newFriendLiveData.value = ListResult.failed(1)
},
block = {
val result = HomeModel.getNewFriendList(gender)
_newFriendLiveData.value = ListResult.success(result, 1)
_homeHotRoomLiveData.value = HomeModel.getHotRoom()
}
)
}

View File

@@ -50,7 +50,7 @@ class RoomHistoryListActivity : BaseViewBindingActivity<ActivityRoomHistoryListB
.setLayoutManager(LinearLayoutManager(this))
.setRecyclerView(binding.recyclerView)
.setAdapter(RoomHistoryListAdapter())
.setEmptyView(EmptyViewHelper.createEmptyTextView(this, ResUtil.getString(R.string.home_activity_roomhistorylistactivity_06)))
.setEmptyView(EmptyViewHelper.createEmptyView(this, ResUtil.getString(R.string.home_activity_roomhistorylistactivity_06)))
.build()
binding.swipeRefresh.setOnRefreshListener {

View File

@@ -44,7 +44,7 @@ class VisitorListActivity : BaseViewBindingActivity<ActivityVisitorListBinding>(
.setRecyclerView(binding.recyclerView)
.setAdapter(VisitorListAdapter())
.setPageSize(pageSize)
.setEmptyView(EmptyViewHelper.createEmptyTextView(this, ResUtil.getString(R.string.home_activity_visitorlistactivity_02)))
.setEmptyView(EmptyViewHelper.createEmptyView(this, ResUtil.getString(R.string.home_activity_visitorlistactivity_02)))
.build()
rvDelegate.adapter.setOnLoadMoreListener({ loadData(false) }, binding.recyclerView)

View File

@@ -1,22 +0,0 @@
package com.yizhuan.erban.home.adapter
import com.yizhuan.erban.R
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
import com.zhpan.bannerview.BaseBannerAdapter
import com.zhpan.bannerview.BaseViewHolder
class HomeBannerAdapter : BaseBannerAdapter<BannerInfo?>() {
override fun getLayoutId(viewType: Int): Int {
return R.layout.activity_home_banner
}
override fun bindData(
helper: BaseViewHolder<BannerInfo?>,
item: BannerInfo?,
position: Int,
pageSize: Int
) {
ImageLoadUtilsV2.loadImage(helper.findViewById(R.id.iv_cover), item?.bannerPic)
}
}

View File

@@ -1,15 +1,12 @@
package com.yizhuan.erban.home.adapter
import android.view.View
import androidx.constraintlayout.widget.Group
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.opensource.svgaplayer.SVGAImageView
import com.yizhuan.erban.R
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2
import com.yizhuan.erban.ui.utils.loadFromAssets
import com.yizhuan.xchat_android_core.home.bean.HomeRoomInfo
import com.yizhuan.xchat_android_core.utils.subAndReplaceDot
/**
* create by lvzebiao @2019/11/13
@@ -18,21 +15,17 @@ class HomeChatAdapter :
BaseQuickAdapter<HomeRoomInfo, BaseViewHolder>(R.layout.item_home_chat) {
override fun convert(helper: BaseViewHolder, item: HomeRoomInfo) {
val svgaLiving = helper.getView<SVGAImageView>(R.id.svga_living)
ImageLoadUtilsV2.loadAvatar(helper.getView(R.id.iv_avatar), item.avatar)
helper.setText(R.id.tv_name, item.title.subAndReplaceDot(6))
if (item.mgId == 0L) {
helper.getView<Group>(R.id.group_game).visibility = View.INVISIBLE
} else {
helper.getView<Group>(R.id.group_game).visibility = View.VISIBLE
when(item.gender){
0 ->{
helper.getView<View>(R.id.mViewBg).background = ContextCompat.getDrawable(mContext,R.drawable.bg_home_chat_man)
}
1 ->{
helper.getView<View>(R.id.mViewBg).background = ContextCompat.getDrawable(mContext,R.drawable.bg_home_chat_man)
}
2 ->{
helper.getView<View>(R.id.mViewBg).background = ContextCompat.getDrawable(mContext,R.drawable.bg_home_chat_women)
}
}
svgaLiving.loadFromAssets("svga/home_living.svga")
ImageLoadUtilsV2.loadAvatar(helper.getView(R.id.mCirImage), item.avatar)
}
override fun onViewAttachedToWindow(holder: BaseViewHolder) {
super.onViewAttachedToWindow(holder)
val svgaLiving = holder.getView<SVGAImageView>(R.id.svga_living)
svgaLiving?.loadFromAssets("svga/home_living.svga")
}
}

View File

@@ -1,16 +1,12 @@
package com.yizhuan.erban.home.adapter
import android.view.View
import android.widget.ImageView
import androidx.appcompat.widget.AppCompatImageView
import androidx.core.view.isGone
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.opensource.svgaplayer.SVGAImageView
import com.yizhuan.erban.R
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2
import com.yizhuan.erban.ui.utils.load
import com.yizhuan.erban.ui.utils.loadFromAssets
import com.yizhuan.xchat_android_core.home.bean.HomeRoomInfo
import com.yizhuan.xchat_android_core.utils.TextUtils
@@ -18,57 +14,18 @@ import com.yizhuan.xchat_android_core.utils.TextUtils
* create by lvzebiao @2019/11/13
*/
class HomeHotAdapter :
BaseQuickAdapter<HomeRoomInfo, BaseViewHolder>(R.layout.item_room_recommend) {
BaseQuickAdapter<HomeRoomInfo, BaseViewHolder>(R.layout.item_room_common) {
override fun convert(helper: BaseViewHolder, item: HomeRoomInfo) {
helper.apply {
getView<ImageView>(R.id.iv_room_image).load(item.avatar)
setText(R.id.tv_online_number, "${item.onlineNum}")
setText(R.id.tv_room_title, item.title)
setText(R.id.tv_id, "ID:${item.erbanNo}")
}
helper.setVisible(R.id.tv_in_pk, item.isCrossPking)
helper.setGone(R.id.iv_room_tag, !TextUtils.isEmptyText(item.tagPict))
ImageLoadUtilsV2.loadImage(helper.getView(R.id.iv_room_tag), item.tagPict)
val icTopList = helper.getView<AppCompatImageView>(R.id.iv_top_list)
if(item.isHourTop1 == 1){
icTopList.visibility = View.VISIBLE
icTopList.setImageResource(R.drawable.bg_recommend_hour_list)
} else if(item.isWeekTop1 == 1){
icTopList.visibility = View.VISIBLE
icTopList.setImageResource(R.drawable.bg_recommend_weekly_list)
} else {
icTopList.visibility = View.INVISIBLE
}
val avatars: Array<ImageView> = arrayOf(
helper.getView(R.id.iv_avatar_0),
helper.getView(R.id.iv_avatar_1),
helper.getView(R.id.iv_avatar_2),
helper.getView(R.id.iv_avatar_3),
helper.getView(R.id.iv_avatar_4)
)
for (i in avatars.indices) {
val avatarUrl = item.micUsers?.getOrNull(i)?.avatar
avatars[i].isGone = avatarUrl.isNullOrBlank()
avatars[i].load(avatarUrl)
}
val svgaPk = helper.getView<SVGAImageView>(R.id.svga_pk)
if (item.isCrossPking) {
svgaPk.visibility = View.VISIBLE
svgaPk.loadFromAssets("svga/svga_home_pk.svga")
} else {
svgaPk.visibility = View.GONE
}
val svgaLiving = helper.getView<SVGAImageView>(R.id.svga_living)
svgaLiving.loadFromAssets("svga/home_white_living.svga")
}
override fun onViewAttachedToWindow(holder: BaseViewHolder) {
super.onViewAttachedToWindow(holder)
val svgaLiving = holder.getView<SVGAImageView>(R.id.svga_living)
svgaLiving?.loadFromAssets("svga/home_white_living.svga")
}
}

View File

@@ -11,7 +11,6 @@ import com.yizhuan.erban.R;
import com.yizhuan.erban.avroom.firstcharge.FirstChargeDialog;
import com.yizhuan.erban.shipantics.PullRadishActivity;
import com.yizhuan.erban.treasure_box.widget.GoldBoxHelper;
import com.yizhuan.erban.treasurefairy.HomeFairyActivity;
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
import com.yizhuan.erban.ui.widget.rollviewpager.adapter.StaticPagerAdapter;
import com.yizhuan.erban.utils.CommonJumpHelper;
@@ -39,9 +38,7 @@ public class RoomActAdapter extends StaticPagerAdapter {
BannerInfo bannerInfo = data.get(position);
String actId = String.valueOf(bannerInfo.getBannerId());
ivCover.setScaleType(ImageView.ScaleType.CENTER_CROP);
if (bannerInfo.isFairy()) {
ivCover.setImageResource(R.drawable.ic_fairy_entrance);
} else if (bannerInfo.isFirstCharge()) {
if (bannerInfo.isFirstCharge()) {
ivCover.setImageResource(R.drawable.ic_first_charge_enter);
} else if (bannerInfo.isBox()) {
GlideApp.with(BasicConfig.INSTANCE.getAppContext())
@@ -54,9 +51,7 @@ public class RoomActAdapter extends StaticPagerAdapter {
ImageLoadUtils.loadImage(mContext, bannerInfo.getBannerPic(), ivCover, R.drawable.default_cover);
}
ivCover.setOnClickListener(v -> {
if (bannerInfo.isFairy()) {
HomeFairyActivity.start(mContext);
} else if (bannerInfo.isFirstCharge()) {
if (bannerInfo.isFirstCharge()) {
FirstChargeDialog.start(mContext);
} else if (bannerInfo.isBox()) {
GoldBoxHelper.handleBoxClick(mContext);

View File

@@ -1,234 +0,0 @@
package com.yizhuan.erban.home.adapter
import android.text.TextUtils
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.appcompat.widget.AppCompatImageView
import androidx.appcompat.widget.AppCompatTextView
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.google.android.flexbox.AlignItems
import com.google.android.flexbox.FlexDirection
import com.opensource.svgaplayer.SVGAImageView
import com.yizhuan.erban.R
import com.yizhuan.erban.audio.helper.AudioPlayerHelper
import com.yizhuan.erban.audio.helper.OnPlayListener
import com.yizhuan.erban.avroom.activity.AVRoomActivity
import com.yizhuan.erban.ui.im.avtivity.NimP2PMessageActivity
import com.yizhuan.erban.ui.user.activity.UserInfoActivity
import com.yizhuan.erban.ui.user.adapter.UserInfoLabelAdapter
import com.yizhuan.erban.ui.utils.ImageLoadUtils
import com.yizhuan.erban.ui.utils.loadAvatar
import com.yizhuan.erban.ui.utils.loadFromAssets
import com.yizhuan.erban.view.GenderAgeTextView
import com.yizhuan.xchat_android_core.Constants
import com.yizhuan.xchat_android_core.manager.AudioEngineManager
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
import com.yizhuan.xchat_android_core.user.bean.UserInfo
import com.yizhuan.xchat_android_core.utils.StarUtils
import com.yizhuan.xchat_android_core.utils.ifNullOrEmpty
import com.yizhuan.xchat_android_library.common.widget.LinesFlexBoxLayoutManager
import com.yizhuan.xchat_android_library.utils.ListUtils
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import java.util.Date
import java.util.concurrent.TimeUnit
class RoomNewFriendsAdapter :
BaseQuickAdapter<UserInfo, BaseViewHolder>(R.layout.item_room_new_friends) {
private var disposable: Disposable? = null
private var isMute = false
private var isRemoteMute = false
override fun convert(helper: BaseViewHolder, item: UserInfo) {
helper.getView<ImageView>(R.id.iv_avatar).loadAvatar(item.avatar)
helper.setText(R.id.tv_desc, item.userDesc.ifNullOrEmpty { "我是个默认签名" })
val tvGenderAge = helper.getView<GenderAgeTextView>(R.id.tv_gender_age)
tvGenderAge.setBirthDay(item.birth)
tvGenderAge.setGender(item.gender)
//设置星座
val star = StarUtils.getConstellation(Date(item.birth))
helper.setImageResource(R.id.iv_constellation, star)
val tvTalk = helper.getView<TextView>(R.id.tv_talk)
helper.setVisible(
R.id.view_online, if (item.inMic) {
false
} else item.inOnline
)
helper.setVisible(R.id.group_party, item.inMic)
if (item.inRoomUid != 0L) {
tvTalk.text = "去找TA"
tvTalk.setOnClickListener {
AVRoomActivity.startForFromType(
mContext,
item.inRoomUid,
AVRoomActivity.FROM_TYPE_USER,
item.nick,
item.uid.toString()
)
}
} else {
tvTalk.text = "和TA聊"
tvTalk.setOnClickListener {
NimP2PMessageActivity.start(mContext, item.uid.toString())
}
}
helper.getView<View>(R.id.iv_avatar).setOnClickListener {
UserInfoActivity.Companion.start(mContext, item.uid)
}
val tvNickname = helper.getView<TextView>(R.id.tv_nickname)
tvNickname.text = item.nick
val ivUserLevel: AppCompatImageView = helper.getView(R.id.iv_user_level)
ivUserLevel.visibility = View.GONE
if (item.userLevelVo != null && !TextUtils.isEmpty(item.userLevelVo.getExperUrl())) {
ivUserLevel.visibility = View.VISIBLE
ImageLoadUtils.loadImage(mContext, item.userLevelVo.getExperUrl(), ivUserLevel)
}
val ivCharmLevel: AppCompatImageView = helper.getView(R.id.iv_charm_level)
ivCharmLevel.visibility = View.GONE
if (item.userLevelVo != null && !TextUtils.isEmpty(item.userLevelVo.getCharmUrl())) {
ivCharmLevel.visibility = View.VISIBLE
ImageLoadUtils.loadImage(
mContext,
item.userLevelVo.getCharmUrl(),
ivCharmLevel
)
}
if (item.userVoice.isNullOrBlank()) {
helper.getView<AppCompatTextView>(R.id.tv_desc).visibility = View.VISIBLE
helper.getView<LinearLayout>(R.id.llAudio).visibility = View.GONE
} else {
helper.getView<AppCompatTextView>(R.id.tv_desc).visibility = View.GONE
helper.getView<LinearLayout>(R.id.llAudio).visibility = View.VISIBLE
helper.getView<AppCompatTextView>(R.id.tvAudio).text = item.voiceDura.toString()
helper.getView<LinearLayout>(R.id.llAudio)
.setOnClickListener { toggleAudio(helper, item) }
helper.setImageResource(R.id.liv_user, R.drawable.ic_sound_wave)
}
val mLabelRecyclerView = helper.getView<RecyclerView>(R.id.mLabelRecyclerView)
if (!ListUtils.isListEmpty(item.labels)) {
mLabelRecyclerView.visibility = View.VISIBLE
val userInfoLabelAdapter = UserInfoLabelAdapter()
val labelLayoutManager = LinesFlexBoxLayoutManager(mContext)
labelLayoutManager.flexDirection = FlexDirection.ROW
labelLayoutManager.alignItems = AlignItems.FLEX_START
labelLayoutManager.setMaxLines(1)
mLabelRecyclerView.layoutManager = labelLayoutManager
mLabelRecyclerView.adapter = userInfoLabelAdapter
userInfoLabelAdapter.setNewData(item.labels)
} else {
mLabelRecyclerView.visibility = View.GONE
}
}
private fun toggleAudio(holder: BaseViewHolder, item: UserInfo) {
if (item.isVoicePlaying) {
stopAudio()
} else {
playAudio(holder, item)
}
}
private fun stopAudio() {
AudioPlayerHelper.get().endPlay()
}
private fun resetAudioUI(holder: BaseViewHolder, item: UserInfo) {
item.isVoicePlaying = false
disposable?.dispose()
holder.setImageResource(R.id.iv_audio_control, R.drawable.ic_sound_pause)
holder.setText(R.id.tvAudio, item.voiceDura.toString())
val svgaImageView = holder.getView<SVGAImageView>(R.id.liv_user)
svgaImageView.stopAnimation()
svgaImageView.setImageResource(R.drawable.ic_sound_wave)
AvRoomDataManager.get().mCurrentRoomInfo?.run {
AudioEngineManager.get().isRemoteMute = isRemoteMute //非靜音
AudioEngineManager.get().isMute = isMute //能説話
AudioEngineManager.get().setRole(
if (isRemoteMute) Constants.CLIENT_ROLE_AUDIENCE else Constants.CLIENT_ROLE_BROADCASTER
)
}
}
private fun playAudio(holder: BaseViewHolder, item: UserInfo) {
AudioPlayerHelper.get().endPlay()
item.isVoicePlaying = true
holder.setImageResource(R.id.iv_audio_control, R.drawable.ic_sound_start)
val svgaImageView = holder.getView<SVGAImageView>(R.id.liv_user)
svgaImageView.loadFromAssets("svga/home_voice_playing.svga")
disposable = Observable.interval(1L, TimeUnit.SECONDS)
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread())
.map { it + 1 }
.takeUntil { it == item.voiceDura.toLong() }
.subscribe {
holder.setText(R.id.tvAudio, (item.voiceDura - it).toString())
}
AvRoomDataManager.get().mCurrentRoomInfo?.run {
isRemoteMute = AudioEngineManager.get().isRemoteMute
isMute = AudioEngineManager.get().isMute
AudioEngineManager.get().isRemoteMute = true //設置靜音
AudioEngineManager.get().isMute = true //不能説話
AudioEngineManager.get().setRole(Constants.CLIENT_ROLE_AUDIENCE)
}
AudioPlayerHelper.get().playInThread(item.userVoice, object : OnPlayListener {
override fun onError(error: String) {
SingleToastUtil.showToast(mContext.getString(R.string.me_error_playing))
resetAudioUI(holder, item)
}
override fun onPrepared() {}
override fun onPlaying(currDuration: Long) {}
override fun onCompletion() {
resetAudioUI(holder, item)
}
})
}
override fun onViewDetachedFromWindow(holder: BaseViewHolder) {
super.onViewDetachedFromWindow(holder)
val position = holder.absoluteAdapterPosition
if (position < 0 || position >= data.size) {
return
}
val item = data[position]
if (item.isVoicePlaying) {
stopAudio()
}
}
}

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