Compare commits

...

126 Commits

Author SHA1 Message Date
Max
c8d16ad331 feat:修改接口加密KEY 2024-04-28 09:45:36 +08:00
Max
dc4b5fec82 feat:调整TRTC相关参数 2024-04-19 10:17:11 +08:00
Max
67d5d12cb8 fix:文件上传改为默认主线程回调 2024-04-12 14:39:09 +08:00
Max
8299cc29fe feat:调整易盾KEY 2024-04-08 10:26:14 +08:00
Max
f4f7361184 fix:GitModel初始化加载礼物接口 补加登录状态判断 2024-04-03 17:19:20 +08:00
Max
7bd8b4c653 fix:修复动态上传失败后非主线程更新UI问题 2024-04-03 10:29:06 +08:00
Max
beb083c896 feat:支持自定义域名替换 2024-04-02 20:05:09 +08:00
Max
56942bf545 fix:修复动态发布失败时按钮状态未恢复问题 2024-04-02 20:04:39 +08:00
Max
a1891718f5 feat:移除七牛云改用腾讯COS 2024-04-02 20:04:09 +08:00
Max
68723cd47f fix:修复贵族中心空指针隐患 2024-04-02 16:47:31 +08:00
Max
6f49eca7b9 fix:修复贵族google渠道开通接口传参问题
fix:移除开通按钮错误的状态更新
2024-04-01 18:58:10 +08:00
Max
1478973d42 feat:送礼接口调整 2024-04-01 16:20:57 +08:00
Max
688dc3bc3d feat:去掉贵族返利列表的波纹动效 2024-04-01 10:40:17 +08:00
Max
8096ce0ff5 feat:初步完成送礼可刷金币功能(待测试) 2024-04-01 10:19:19 +08:00
Max
f2b083d7a7 feat:完成贵族购买需求 2024-03-29 19:41:50 +08:00
Max
e326dabc13 feat:PK更新值忽略超级幸运礼物 2024-03-25 23:05:11 +08:00
Max
794a24f332 fix:修复通用模版消息解析json问题 2024-03-25 19:00:12 +08:00
Max
3a6ccd0e97 fix:修复房间在线列表-点击神秘人弹出资料卡问题 2024-03-25 15:28:06 +08:00
Max
87da2a9f18 feat:通用飘屏协议号变更(105老版本有崩溃问题) 2024-03-25 14:53:30 +08:00
Max
9d8118e331 fix:修复通用公屏异常(FastJson解析DataClass问题)
feat:增加trycatch避免直接崩溃
2024-03-25 14:52:02 +08:00
Max
ed6e247de7 fix:修复超级幸运礼物-全麦送礼时未屏蔽公屏问题 2024-03-25 09:57:43 +08:00
Max
3864efcc4c feat:完成超级幸运礼物功能 2024-03-21 20:03:26 +08:00
Max
cae5ccce7a fix:修复正式包json解析问题(com.alibaba.fastjson.JSONException: default constructor not found) 2024-03-20 20:52:17 +08:00
Max
6bd857b97d feat:完成通用飘屏对接 2024-03-20 14:20:22 +08:00
Max
502a2f20b9 feat:初步完成房间内的通用模版飘屏(待测试) 2024-03-20 14:20:22 +08:00
Max
74a7ccecfc feat:分享邀请支持动态配置:标题、图片 2024-03-20 14:19:57 +08:00
Max
d4f65da89e feat:分享邀请生成图片UI新调整
feat:新增JS方法->直接保存图片
2024-03-20 14:19:55 +08:00
Max
bbb6a21cb9 feat:初步分享邀请弹窗部分(假数据) 2024-03-20 14:19:54 +08:00
Max
098bf777d7 fix:个播跨房PK-bug处理记录(服务端临时处理) 2024-03-12 21:11:25 +08:00
Max
6f1165dc37 feat:拆分出疯狂动物城相关协议号(为了iOS兼容性) 2024-03-12 11:09:39 +08:00
Max
5c4c4cc284 完成疯狂动物园飘窗功能 2024-03-11 18:48:54 +08:00
Max
6b7adc5950 fix:修复相亲房送礼导致闭麦、结束导致闭麦问题(只是临时补救,具体看注释)
fix:移除BaseRoomFragment中更新麦克风状态的某些判断(isNoProhibitMic),不知道之前为何加这段判断,但这段判断风险较大,某些情况导致麦克风状态一直显示未关闭(去掉后经测试验收,未发现问题)
2024-03-06 20:58:31 +08:00
Max
87b81b7761 fix:修复声网切换音乐导致无限切歌bug 2024-03-05 18:48:40 +08:00
Max
842bf98958 feat:修改版本号 2024-02-26 20:46:15 +08:00
Max
f110a47c0e fix:修复房间banner详情页图标展示错误问题 2024-02-26 17:14:12 +08:00
Max
160e5025b8 fix:修复首页没有更多Tab时默认第一个Tab不能正常初始化问题 2024-02-23 19:51:01 +08:00
Max
9ec8385544 fix:调整滚动条配置方式(发现部分手机无效,这样改后貌似可以) 2024-02-23 18:47:27 +08:00
Max
13106a62e4 fix:修复房间玩法资源位样式问题(滚动条| 背景色) 2024-02-23 16:35:43 +08:00
Max
7a677c96cd fix:修复首页Tab页无数据的提示文案 2024-02-23 15:51:02 +08:00
Max
7093cfa7f3 fix:修复首页Tab页列表分页传参导致bug 2024-02-23 14:38:47 +08:00
Max
3747c10dc1 feat:完成预留活动(模版消息)公屏 2024-02-23 14:36:51 +08:00
Max
d9e3c32f1b feat:完成首页动态Tab功能 2024-02-22 14:17:41 +08:00
Max
9891c6f9d0 fix:优化房间玩法资源位展开效果 2024-02-21 16:43:22 +08:00
Max
f721e34139 feat:去掉守护星球公屏昵称前后空格:和其他公屏样式风格保持一致 2024-02-21 15:53:41 +08:00
Max
069eb3e89c feat:公会主播收入页面增加直播时长信息展示 2024-02-21 15:52:30 +08:00
Max
8ae154cf09 feat:守护星球公屏样式微调(昵称前后加空格) 2024-02-21 14:26:44 +08:00
Max
6b90fedb8b Merge branch 'feature/room_icon' into test/2.6.0 2024-02-21 14:06:46 +08:00
Max
cee6060d62 feat:新增守护星球公屏 2024-02-21 14:06:37 +08:00
Max
0acd6f9c88 feat:增加首充成功后房间banner刷新 2024-02-21 09:58:23 +08:00
Max
9a075db5d5 feat:完成房间资源位改版 2024-02-20 19:35:40 +08:00
Max
592dbc78f3 feat:输出包文件名称增加versionCode信息 2024-02-02 18:35:16 +08:00
Max
c3bf0b9451 fix:修复寻爱飘窗高等级重复展示问题(还是忍不住吐槽下:乱七八糟的事件漫天飞) 2024-02-01 18:57:02 +08:00
Max
82ad02f2a7 feat:补充支付结果未登录判断 2024-02-01 15:07:27 +08:00
Max
fb6d784c1d Merge branch 'peko_feature/my_car' into develop 2024-02-01 15:05:00 +08:00
Max
3e4d9654c9 feat:完成mycard支付结果回调处理 2024-02-01 14:54:32 +08:00
Max
923e598344 feat:设置SplashScreen默认背景色(部分手机默认黑色) 2024-01-31 16:49:12 +08:00
Max
5de48352c5 feat:去掉年度盛典icon 2024-01-31 16:48:27 +08:00
Max
5140a70569 Merge branch 'fix/xunai' into develop 2024-01-31 16:09:50 +08:00
Max
0e405f5bda fix:修复夺宝5级礼物未在公屏展示问题 2024-01-31 16:09:45 +08:00
Max
d5be4ace02 fix:修复寻爱飘窗重复展示问题 2024-01-31 14:58:16 +08:00
Max
4475d622fd feat:完成mycard跳转对接 2024-01-31 11:42:09 +08:00
Max
03faea9138 feat:调整新的首页tab图标 2024-01-06 16:03:33 +08:00
Max
37afa710fe feat:调整首页Tab图标资源 2024-01-06 15:51:49 +08:00
Max
6a71670b84 fix:调整普通房/牌照房 主麦位置UI 2024-01-06 15:43:39 +08:00
Max
615089d1e1 feat:删掉测试代码 2024-01-06 11:48:14 +08:00
Max
47b38458df feat:去掉调试日志 2024-01-06 11:42:31 +08:00
Max
91be03ea07 fix:修复个播PK进房未加入对方房间问题 2024-01-05 19:23:38 +08:00
Max
f7a500770a feat:补充加入频道失败的异常提示 2024-01-05 18:50:36 +08:00
Max
d82bb55c4e feat:调整部分图标(年度盛典) 2024-01-05 18:20:06 +08:00
Max
dc1383be70 fix:修复福袋飘窗礼物数量展示问题 2024-01-05 18:04:47 +08:00
Max
368ed2bf70 fix:修复个播PK声音状态异常(多线程不同步导致)
fix:PK数据接口字段适配
fix:修复PK麦克风状态更新不及时问题(接收到PK数据后就更新麦位状态)
2024-01-05 17:54:43 +08:00
Max
d595ed469e Merge branch 'peko_feature/notify' into peko_test/2.5.0 2024-01-05 11:33:49 +08:00
Max
792ad5141c fix:调整福袋飘窗点击跳转区域 2024-01-05 11:20:19 +08:00
Max
de6a4fe524 fix:修复房间内福袋飘窗文本展示问题;增加跳转提示 2024-01-05 11:07:32 +08:00
Max
d0cb9e43b1 Merge branch 'peko_feature/notify' into peko_test/2.5.0 2024-01-04 20:41:01 +08:00
Max
ef8d9b0b6f feat:完成飘窗优先级控制 2024-01-04 20:40:49 +08:00
Max
e781369be1 Merge branch 'peko_feature/notify' into peko_test/2.5.0 2024-01-03 19:41:38 +08:00
Max
3bd13e732a Merge branch 'peko_feature/pk' into peko_test/2.5.0 2024-01-03 19:41:28 +08:00
Max
67babbaebd feat:初步完成声网个播PK功能 2024-01-03 18:27:09 +08:00
Max
c392b20f21 feat:完成全局福袋飘窗点击跳转提示;调整飘窗文案 2024-01-03 11:07:05 +08:00
Max
0a1ae82d42 feat:完成全服福袋通知样式调整 2024-01-02 20:15:35 +08:00
Max
6dc63e1d26 Merge branch 'peko_feature/online' into peko_test/2.5.0 2024-01-02 18:23:19 +08:00
Max
2dcbcf7179 feat:完成铭牌渲染优化 2024-01-02 17:38:17 +08:00
Max
bcd6faf213 feat:调整房间在线列表-房主判断字段,适配隐身进房展示 2024-01-02 16:15:46 +08:00
Max
072c837c99 feat:完成房间内福袋飘窗UI调整 2024-01-02 15:29:26 +08:00
Max
067f97d6be feat:完成房间在线列表优化需求 2024-01-02 11:32:05 +08:00
Max
15b317d5d0 feat:写了接口请求部分,未实现UI等部分;(接口500,下周继续) 2023-12-29 19:46:46 +08:00
Max
16712197e3 feat:完成私聊限制需求(每发消息都请求接口) 2023-12-29 17:02:22 +08:00
Max
24ccadc593 fix:修复个播小时榜点击无效问题 2023-12-19 16:33:40 +08:00
Max
88767208bd 同步hiyoo:调整房间小时榜、音乐、房间榜入口位置 2023-12-19 15:30:56 +08:00
Max
91bb8f7871 fix:修复相亲房布局导致的异常 2023-12-18 10:58:59 +08:00
Max
dedb075c56 fix:补充公会搜索的空判断 2023-12-15 20:18:02 +08:00
Max
1b1f477494 fix:修复公会搜索不出结果问题 2023-12-15 20:17:58 +08:00
Max
9a015aff0b feat:新增个播-人气礼物 2023-12-15 20:17:39 +08:00
Max
9500554550 feat:调整个播默认背景和默认麦位头饰 2023-12-15 20:17:32 +08:00
Max
23e05ccab1 fix:修复选择幸运礼物后被自动重置为选中第一个的问题 2023-12-15 20:17:03 +08:00
Max
0417e53b85 feat:调整客态视角下粉丝团提醒文案 2023-12-15 20:16:52 +08:00
Max
df96cfe5d4 fix:调整加入粉丝团入口UI 2023-12-11 17:00:54 +08:00
Max
213efcba31 fix:修复添加管理员后管理员列表中无法正常展示昵称头像问题 2023-12-11 16:14:04 +08:00
Max
9e36225b77 fix:修复个播小时榜飘窗无法展示问题 2023-12-11 15:22:39 +08:00
Max
da3d72ebff fix:修复升级弹窗偶发异常 2023-12-11 11:47:10 +08:00
Max
fd3dc7cb3c fix:个播在麦时禁止滑动 2023-12-11 11:07:25 +08:00
Max
eebe231a45 Merge branch 'peko_feature/search' into peko_test/2.4.0 2023-12-08 16:01:34 +08:00
Max
276f2002f9 Merge branch 'peko_feature/region' into peko_test/2.4.0 2023-12-08 16:01:30 +08:00
Max
2942e2f0bb feat;完成地区选择器优化(调整地区数据、支持字母索引、有效展示当前地区) 2023-12-08 15:59:59 +08:00
Max
406077b43b fix:修复房间用户详情弹窗边框展示问题 2023-12-07 18:07:45 +08:00
Max
55a8d037e0 feat:完成搜索结果条目信息展示调整(去掉性别,新增等级信息) 2023-12-07 17:10:58 +08:00
Max
ba58b0bd40 feat:刚刚少提交依赖 2023-12-07 16:02:43 +08:00
Max
151b1c37d0 feat:修复RectRoundImageView导致的图片加载问题 2023-12-07 16:01:55 +08:00
Max
4a7af141aa feat:声网RTC配置debug环境KEY 2023-12-07 15:11:28 +08:00
Max
cec6e00e09 feat:同步音萌完成个播PK屏蔽麦功能 2023-12-07 14:50:01 +08:00
Max
bf6ef26eca fix:修复个播粉丝团入口展示问题(进入有密码房间时因请求时机导致未正确加载状态) 2023-12-06 17:45:39 +08:00
Max
07845b5e60 fix:修复断网时被踢,重连后未退房问题 2023-12-06 17:03:55 +08:00
Max
097ead1327 fix:修复公会高管设置入口展示问题 2023-12-06 14:25:52 +08:00
Max
2b45d35d40 feat:升级vasdolly版本 2023-12-06 11:58:31 +08:00
Max
e6f4b40e66 fix:修复粉丝团入口逻辑 2023-12-06 11:10:33 +08:00
Max
c46f19f03f fix:修复pk-某liveData空类型导致异常 2023-12-05 18:59:35 +08:00
Max
37196025cc fix:修复个播房闪退:pk的一个liveData空类型问题 2023-12-05 18:01:44 +08:00
Max
9096a9b57f fix:修复输入密码进入游戏房的房间状态不一致问题 2023-12-04 18:54:11 +08:00
Max
c46c49715c feat:补充日志信息 2023-12-04 17:42:29 +08:00
Max
31b785c511 fix:调整礼物飘窗样式问题 2023-12-04 17:42:14 +08:00
Max
6f01c5ddad fix:修复进入有密码的房间,游戏未加载问题 2023-12-04 17:34:47 +08:00
Max
306f15f7f9 feat:通过时间,简单过滤多次重复401异常处理 2023-12-04 16:58:11 +08:00
Max
0babbedeb9 feat:同步habu完成房间banner资源位展示优化 2023-12-01 16:54:21 +08:00
Max
d09e60d206 feat:同步hubu完成【升级飘窗、加入公会】功能优化 2023-12-01 16:31:06 +08:00
Max
e37796286b feat:同步Habu完成地区隔离功能 2023-12-01 16:10:22 +08:00
292 changed files with 9299 additions and 2914 deletions

View File

@@ -60,7 +60,7 @@ android {
if (abi == null) {
abi = "universal"
}
outputFileName = "piko_${buildType.name}_v${defaultConfig.versionName}_${abi}_${date}.apk"
outputFileName = "piko_${buildType.name}_v${defaultConfig.versionName}_${defaultConfig.versionCode}_${abi}_${date}.apk"
}
}
@@ -275,7 +275,7 @@ dependencies {
implementation 'com.github.fodroid:XRadioGroup:v1.5'
api 'com.tencent.vasdolly:helper:3.0.3'
api 'com.tencent.vasdolly:helper:3.0.6'
implementation "io.github.tencent:vap:2.0.24"
implementation 'com.github.mmin18:realtimeblurview:1.2.1'
@@ -303,6 +303,7 @@ dependencies {
implementation 'com.contrarywind:wheelview:4.1.0'
implementation 'tech.sud.mgp:SudMGP-static:1.3.3.1158'
implementation 'com.google.android.material:material:1.9.0'
}
channel {

View File

@@ -355,6 +355,24 @@
android:name=".ui.webview.CommonWebViewActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".ui.wallet.PaymentResultActivity"
android:exported="true"
android:launchMode="singleTask"
android:theme="@style/transparent_activity"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="payment"
android:path="/result"
android:scheme="pekoapp" />
</intent-filter>
</activity>
<activity
android:name=".ui.webview.SimpleWebViewActivity"
android:screenOrientation="portrait" />
@@ -521,7 +539,7 @@
android:windowSoftInputMode="stateHidden|adjustResize" />
<activity
android:name=".treasure_box.activity.TreasureBoxActivity"
android:theme="@style/dialog_web_view_activity" />
android:theme="@style/transparent_activity" />
<activity
android:name=".treasure_box.activity.BoxRankingActivity"
android:theme="@style/room_message_activity" />
@@ -825,10 +843,18 @@
<activity
android:name=".ui.webview.DialogWebViewActivity"
android:theme="@style/dialog_web_view_activity"
android:windowSoftInputMode="adjustPan" /> <!-- 隐私政策 -->
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".ui.webview.room_banner.RoomWebDialogActivity"
android:theme="@style/room_dialog_web_view_activity"
android:windowSoftInputMode="adjustPan" /><!-- 隐私政策 -->
<activity
android:name=".ui.webview.DatingRuleWebViewActivity"
android:theme="@style/dialog_web_view_activity" />
<activity
android:name=".ui.webview.room_banner.RoomBannerWebDialogActivity"
android:theme="@style/dialog_web_view_activity"
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".ui.webview.TarotPayWebViewActivity"
android:theme="@style/dialog_web_view_activity" />

View File

@@ -0,0 +1 @@
[{"name":"Taiwan","abbr":"TW","mcc":"466","code":"886"},{"name":"Hong Kong","abbr":"HK","mcc":"454","code":"852"},{"name":"Singapore","abbr":"SG","mcc":"525","code":"65"},{"name":"Malaysia","abbr":"MY","mcc":"502","code":"60"},{"name":"China","abbr":"CN","mcc":"460","code":"86"}]

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

View File

@@ -410,6 +410,7 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
}
onParseIntent();
handleNimIntent();
InitialModel.get().regionCheck();
}
private void onParseIntent() {
@@ -519,6 +520,7 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
@Subscribe(threadMode = ThreadMode.MAIN)
public void onLoadLoginUserInfoEvent(LoadLoginUserInfoEvent event) {
firstLoadedUserInfo();
InitialModel.get().regionCheck();
}
public void onLogout() {

View File

@@ -16,6 +16,8 @@ import android.util.Log;
import androidx.multidex.MultiDex;
import com.bumptech.glide.request.target.ViewTarget;
import com.chuhai.utils.LanguageUtils;
import com.chuhai.utils.ServiceTime;
import com.coorchice.library.utils.LogUtils;
import com.facebook.stetho.Stetho;
import com.hjq.toast.ToastUtils;
@@ -114,6 +116,9 @@ import io.realm.RealmConfiguration;
public class XChatApplication extends BaseApp {
public static final String TAG = "XChatApplication";
public static Application gContext;
// 接收到退出登录事件(跳转到登录页了)
private static long logoutEventTime = 0;
private static final MessageNotifierCustomization messageNotifierCustomization = new MessageNotifierCustomization() {
@Override
public String makeNotifyContent(String nick, IMMessage message) {
@@ -202,10 +207,11 @@ public class XChatApplication extends BaseApp {
String channel = "";
channel = ChannelReaderUtil.getChannel(instance);
Log.d(TAG, "localChannel:" + channel);
if (TextUtils.isEmpty(channel)) {
channel = Constants.GOOGLE;
}
Log.d(TAG, "finalChannel:" + channel);
BasicConfig.INSTANCE.setOriginalChannel(channel);
BasicConfig.INSTANCE.setChannel(channel);
@@ -244,6 +250,13 @@ public class XChatApplication extends BaseApp {
SingleToastUtil.showToast(serviceResult.getMessage());
EventBus.getDefault().post(new NeedCompleteInfoEvent());
throw new ServerException(serviceResult.getMessage(), serviceResult.getCode());
} else if (serviceResult.getCode() == 401) {
if ((ServiceTime.INSTANCE.getTime() - logoutEventTime) > 800) {
logoutEventTime = ServiceTime.INSTANCE.getTime();
SingleToastUtil.showToast(serviceResult.getMessage());
AuthModel.get().cleanLogInfo();
}
throw new ServerException(serviceResult.getMessage(), serviceResult.getCode());
}
}
return null;
@@ -403,6 +416,7 @@ public class XChatApplication extends BaseApp {
httpParams.put("deviceId", DeviceUuidFactory.getDeviceId(context));
httpParams.put("androidId", MD5Utils.getMD5String(Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID)));
httpParams.put("channel", AppMetaDataUtil.getChannelID());
httpParams.put("lang", LanguageUtils.INSTANCE.getSystemLanguage().toLanguageTag());
RxNet.init(context)
.debug(BuildConfig.DEBUG)
.setBaseUrl(url)
@@ -464,6 +478,7 @@ public class XChatApplication extends BaseApp {
ChannelModel.get();
MarketVerifyModel.get();
GiftModel.get();
GiftModel.get().tryLoadGiftList();
PublicChatHallModel.get();
// 模厅
HallDataManager.get().application();

View File

@@ -3,6 +3,8 @@ package com.yizhuan.erban.avroom.activity;
import static android.view.View.VISIBLE;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_BOX;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_CRAZY_ZOO;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_CRAZY_ZOO_SUB_ALL_ROOM;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAIRY;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT;
@@ -14,6 +16,8 @@ import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUS
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_GIFT_L5;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_ROOM_PK_NOTIFY;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY_ALL;
import android.annotation.SuppressLint;
import android.app.Activity;
@@ -44,6 +48,7 @@ import androidx.viewpager2.widget.ViewPager2;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.netease.nim.uikit.StatusBarUtil;
import com.netease.nimlib.sdk.NIMSDK;
import com.netease.nimlib.sdk.Observer;
@@ -107,6 +112,8 @@ import com.yizhuan.xchat_android_core.im.custom.bean.RoomLuckySeaMsgBean;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomPKAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomPkBean;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomReceivedLuckyGiftAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomTemplateNotifyAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomTemplateNotifyMsgBean;
import com.yizhuan.xchat_android_core.im.custom.bean.TarotAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.TarotMsgBean;
import com.yizhuan.xchat_android_core.initial.InitialModel;
@@ -140,6 +147,7 @@ import com.yizhuan.xchat_android_core.super_admin.util.SAdminOptUtil;
import com.yizhuan.xchat_android_core.super_admin.util.SuperAdminUtil;
import com.yizhuan.xchat_android_core.support.room.RoomContext;
import com.yizhuan.xchat_android_core.support.room.RoomView;
import com.yizhuan.xchat_android_core.support.room.RoomWidget;
import com.yizhuan.xchat_android_core.treasurefairy.FairyMsgInfoBean;
import com.yizhuan.xchat_android_core.user.UserModel;
import com.yizhuan.xchat_android_core.user.bean.FirstChargeInfo;
@@ -225,6 +233,10 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
private SingleRoomTipDialog singleRoomTipDialog;
// 通过红包进来时,有该参数
private RedPackageNotifyInfo redPackageNotifyInfo;
// 是否禁用VP滑动true不允许滑动false某些条件下可以滑动
private boolean viewPagerInputDisable;
public static void start(Context context, long roomUid) {
startForFromType(context, roomUid, FROM_TYPE_NORMAL, null, null);
}
@@ -319,7 +331,8 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
}
} else if (roomInfo.getType() == RoomInfo.ROOM_TYPE_SINGLE) {
bgPicture[0] = "";
svgaRoomBg.setImageResource(R.drawable.bg_room_single_pic);
// svgaRoomBg.setImageResource(R.drawable.bg_room_single_pic);
playSvgaBg(svgaRoomBg, "svga/room_bg_single.svga");
} else {
bgPicture[0] = "";
if (roomInfo.getRoomModeType() == RoomModeType.OPEN_PK_MODE) {
@@ -396,7 +409,7 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
public void setCurrentItem(int item) {
dismissLoadingDialog();
if (viewpager != null) {
viewpager.setUserInputEnabled(true);
tryEnabledViewPagerInput();
viewpager.setCurrentItem(item, false);
}
}
@@ -411,7 +424,7 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
Object notifyInfo = intent.getSerializableExtra("notifyInfo");
if (notifyInfo instanceof RedPackageNotifyInfo) {
redPackageNotifyInfo = (RedPackageNotifyInfo) notifyInfo;
}else{
} else {
redPackageNotifyInfo = null;
}
if (mRoomInfo != null) {
@@ -445,7 +458,7 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
viewpager.setOffscreenPageLimit(2);
viewpager.setOrientation(ViewPager2.ORIENTATION_VERTICAL);
viewpager.getChildAt(0).setOverScrollMode(View.OVER_SCROLL_NEVER);
viewpager.setUserInputEnabled(false);
disableViewPagerInput();
viewpager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
@@ -472,11 +485,11 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
if (state == 0 && viewpager.getCurrentItem() == 2) {
showLoadingDialog();
((FakeSingleRoomFragment) mAdapter.getItem(2)).tryJumpRoom();
viewpager.setUserInputEnabled(false);
disableViewPagerInput();
} else if (state == 0 && viewpager.getCurrentItem() == 0) {
showLoadingDialog();
((FakeSingleRoomBackFragment) mAdapter.getItem(0)).tryJumpRoom();
viewpager.setUserInputEnabled(false);
disableViewPagerInput();
}
}
});
@@ -615,6 +628,12 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
case RoomEvent.MY_SELF_KICK_OUT_ROOM_BY_S_ADMIN:
toBack(true);
break;
case RoomEvent.FAIRY_DRAW_GIFT_L5:
ChatRoomMessage message = roomEvent.getChatRoomMessage();
if (message != null) {
IMNetEaseManager.get().addMessages(message);
}
break;
default:
}
}
@@ -663,7 +682,14 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
*/
private void showRoomFragment(boolean isRoomMin) {
mCurrentFragment = (HomePartyFragment) mAdapter.getItem(1);
viewpager.setUserInputEnabled(AvRoomDataManager.get().isSingleRoom());
mCurrentFragment.getPlayNotifyState().observe(getLifecycleOwner(), aBoolean -> {
if (!aBoolean) {
if (isValid()) {
showGiftDialog();
}
}
});
tryEnabledViewPagerInput();
viewpager.setCurrentItem(1, false);
if (isRoomMin) {
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
@@ -1196,17 +1222,10 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
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();
if (mCurrentFragment != null && mCurrentFragment.isShowingPlayNotify()) {
return;
}
showGiftDialog();
}
break;
case CUSTOM_MSG_BOX://寻爱之旅
@@ -1273,6 +1292,22 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
IMNetEaseManager.get().noticeRoomEvent(message, RoomEvent.LUCKY_SEA_GIFT_SERVER_NOTIFY);
}
break;
case CUSTOM_MSG_CRAZY_ZOO://疯狂动物园
if (baseProtocol.getSecond() == CUSTOM_MSG_CRAZY_ZOO_SUB_ALL_ROOM) {
RoomLuckySeaAttachment attachment = new RoomLuckySeaAttachment(CUSTOM_MSG_CRAZY_ZOO, CUSTOM_MSG_CRAZY_ZOO_SUB_ALL_ROOM);
attachment.setRoomLuckySeaMsgBean(JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomLuckySeaMsgBean.class));
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), attachment);
IMNetEaseManager.get().noticeRoomEvent(message, RoomEvent.CRAZY_ZOO_ALL_ROOM_NOTIFY);
}
break;
case CUSTOM_MSG_TEMPLATE_NOTIFY://通用飘屏
if (baseProtocol.getSecond() == CUSTOM_MSG_TEMPLATE_NOTIFY_ALL) {
RoomTemplateNotifyAttachment attachment = new RoomTemplateNotifyAttachment(CUSTOM_MSG_TEMPLATE_NOTIFY, CUSTOM_MSG_TEMPLATE_NOTIFY_ALL);
attachment.setMsgBean(new Gson().fromJson(String.valueOf(baseProtocol.getData()), RoomTemplateNotifyMsgBean.class));
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(String.valueOf(AvRoomDataManager.get().getRoomId()), attachment);
IMNetEaseManager.get().noticeRoomEvent(message, RoomEvent.TEMPLATE_NOTIFY);
}
break;
case CUSTOM_MSG_LUCKY_GIFT://福袋
if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY || baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL) {
RoomReceivedLuckyGiftAttachment attachment = new RoomReceivedLuckyGiftAttachment(CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY);
@@ -1303,10 +1338,23 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
}
}
public boolean isShowingGiftNotify() {
if (giftDialog != null && giftDialog.isShowing()) {
return true;
} else {
return false;
}
}
private void showGiftDialog() {
if (!isValid()) return;
if (giftList == null) return;
if (giftList.size() == 0) return;
AllServiceGiftProtocol.DataBean data = giftList.peekFirst();
if (data == null) return;
if (giftDialog != null && giftDialog.isShowing()) {
return;
}
giftDialog = generateAllServiceGiftDialog(this, data);
giftDialog.setOnDismissListener(dialog -> {
giftList.pollFirst();
@@ -1395,6 +1443,12 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
return this;
}
@Nullable
@Override
public RoomWidget findWidget(@NonNull String name) {
return null;
}
private static class GiftBroadcastObserver implements Observer<BroadcastMessage> {
private WeakReference<AVRoomActivity> mReference;
@@ -1408,23 +1462,64 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
String contentStr = broadcastMessage.getContent();
Logger.i(ResUtil.getString(R.string.avroom_activity_avroomactivity_014) + contentStr);
if (TextUtils.isEmpty(contentStr)) return;
AVRoomActivity activity = mReference.get();
if (activity == null) return;
if (activity.isValid()) {
JSONObject jsonObject;
try {
jsonObject = JSON.parseObject(contentStr);
} catch (Exception e) {
jsonObject = null;
}
if (jsonObject == null) return;
if (jsonObject.containsKey("body")) {
String body = jsonObject.getString("body");
if (TextUtils.isEmpty(body)) return;
activity.onReceivedGiftBroadcastMessage(body);
try {
AVRoomActivity activity = mReference.get();
if (activity == null) return;
if (activity.isValid()) {
JSONObject jsonObject;
try {
jsonObject = JSON.parseObject(contentStr);
} catch (Exception e) {
jsonObject = null;
}
if (jsonObject == null) return;
if (jsonObject.containsKey("body")) {
String body = jsonObject.getString("body");
if (TextUtils.isEmpty(body)) return;
activity.onReceivedGiftBroadcastMessage(body);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
@Override
protected void onReceiveChatRoomEvent(RoomEvent roomEvent) {
super.onReceiveChatRoomEvent(roomEvent);
switch (roomEvent.getEvent()) {
case RoomEvent.UP_MIC:
case RoomEvent.DOWN_MIC:
resetViewPagerInputEnabled();
break;
}
}
/**
* 禁用VP滑动
*/
private void disableViewPagerInput() {
this.viewPagerInputDisable = true;
resetViewPagerInputEnabled();
}
private void tryEnabledViewPagerInput() {
this.viewPagerInputDisable = false;
resetViewPagerInputEnabled();
}
private void resetViewPagerInputEnabled() {
if (viewPagerInputDisable) {
viewpager.setUserInputEnabled(false);
} else {
if (AvRoomDataManager.get().isSingleRoom() && !AvRoomDataManager.get().isOwnerOnMic()) {
// 个播+没在麦位=可以滑动
viewpager.setUserInputEnabled(true);
} else {
viewpager.setUserInputEnabled(false);
}
}
}
}

View File

@@ -21,6 +21,7 @@ import com.yizhuan.erban.base.BaseMvpActivity;
import com.yizhuan.xchat_android_core.Constants;
import com.yizhuan.xchat_android_core.noble.NobleResourceType;
import com.yizhuan.xchat_android_core.room.bean.OnlineChatMember;
import com.yizhuan.xchat_android_core.room.bean.RoomOnlineUserBean;
import com.yizhuan.xchat_android_core.user.bean.UserInfo;
import com.yizhuan.xchat_android_library.base.factory.CreatePresenter;
import com.yizhuan.xchat_android_library.utils.ListUtils;
@@ -107,10 +108,11 @@ public class RoomInviteActivity extends BaseMvpActivity<IRoomInviteView, RoomInv
}
@Override
public void onRequestChatMemberByPageSuccess(List<OnlineChatMember> memberList, int page) {
public void onRequestRoomOnlineListSuccess(List<RoomOnlineUserBean> list) {
}
@Override
public void onRequestChatMemberByPageFail(String errorStr, int page) {
mPage = page;

View File

@@ -527,7 +527,7 @@ public abstract class BaseMicroViewAdapter extends RecyclerView.Adapter<Recycler
/**
* 主席位特有
*/
FrameLayout frTitle;
View frTitle;
TextView tvRoomDesc;
ImageView ivTag;
TextView tvLabelLeaveMode;

View File

@@ -12,27 +12,20 @@ import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.netease.nim.uikit.impl.cache.NimUserInfoCache;
import com.netease.nimlib.sdk.RequestCallbackWrapper;
import com.netease.nimlib.sdk.uinfo.constant.GenderEnum;
import com.netease.nimlib.sdk.uinfo.model.NimUserInfo;
import com.yizhuan.erban.R;
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
import com.yizhuan.erban.ui.widget.NobleAvatarView;
import com.yizhuan.erban.utils.NamePlateHelper;
import com.yizhuan.erban.utils.RegexUtil;
import com.yizhuan.xchat_android_core.auth.AuthModel;
import com.yizhuan.xchat_android_core.level.UserLevelResourceType;
import com.yizhuan.xchat_android_core.level.UserLevelVo;
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager;
import com.yizhuan.xchat_android_core.manager.RoomEvent;
import com.yizhuan.xchat_android_core.noble.NobleResourceType;
import com.yizhuan.xchat_android_core.noble.NobleUtil;
import com.yizhuan.xchat_android_core.room.bean.OnlineChatMember;
import com.yizhuan.xchat_android_core.user.bean.UserInfo;
import com.yizhuan.xchat_android_core.room.bean.RoomOnlineUserBean;
import com.yizhuan.xchat_android_library.utils.ListUtils;
import java.util.List;
import io.reactivex.disposables.Disposable;
/**
@@ -41,19 +34,17 @@ import io.reactivex.disposables.Disposable;
* @author Administrator
* @date 2017/12/4
*/
public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<OnlineChatMember, BaseViewHolder> {
public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<RoomOnlineUserBean, BaseViewHolder> {
private boolean mIsHomeParty;
private Disposable mDisposable;
private Context context;
private OnRoomOnlineNumberChangeListener mListener;
public OnlineUserAdapter(Context context, boolean isHomeParty) {
super(null);
addItemType(OnlineChatMember.NORMAL, R.layout.list_item_online_user);
addItemType(OnlineChatMember.NOBLE, R.layout.list_item_online_user_mystery);
addItemType(RoomOnlineUserBean.NORMAL, R.layout.list_item_online_user);
addItemType(RoomOnlineUserBean.NOBLE, R.layout.list_item_online_user_mystery);
mIsHomeParty = isHomeParty;
this.context = context;
}
@Override
@@ -63,147 +54,76 @@ public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<OnlineChatMembe
}
@Override
protected void convert(@NonNull BaseViewHolder baseViewHolder, OnlineChatMember onlineChatMember) {
if (onlineChatMember != null && onlineChatMember.chatRoomMember != null) {
if (onlineChatMember.getItemType() == OnlineChatMember.NORMAL) {
setNormalData(baseViewHolder, onlineChatMember);
} else {
setMysteryData();
}
protected void convert(@NonNull BaseViewHolder helper, RoomOnlineUserBean item) {
if (item.getItemType() == OnlineChatMember.NOBLE) {
return;
}
// 性别
final ImageView sexImage = helper.getView(R.id.sex);
if (item.getGender() == 1) {
sexImage.setVisibility(View.VISIBLE);
sexImage.setImageResource(R.drawable.ic_gender_male);
} else if (item.getGender() == 2) {
sexImage.setVisibility(View.VISIBLE);
sexImage.setImageResource(R.drawable.ic_gender_female);
} else {
sexImage.setVisibility(View.GONE);
}
}
private void setMysteryData() {
//do nothing
}
// 昵称
helper.setText(R.id.nick, RegexUtil.getPrintableString(item.getNick()));
private void setNormalData(BaseViewHolder baseViewHolder, OnlineChatMember onlineChatMember) {
setSexData(baseViewHolder, onlineChatMember);
ImageView roomOnlineTag = baseViewHolder.getView(R.id.room_online_tag);
ImageView managerLogo = baseViewHolder.getView(R.id.manager_logo);
roomOnlineTag.setVisibility(onlineChatMember.isOnMic ? View.VISIBLE : View.GONE);
managerLogo.setVisibility((onlineChatMember.isAdmin || onlineChatMember.isRoomOwer)
? View.VISIBLE : View.GONE);
managerLogo.setImageResource(onlineChatMember.isAdmin ? R.drawable.icon_admin_logo
: R.drawable.icon_user_list_room_ownner);
baseViewHolder.setText(R.id.nick, RegexUtil.getPrintableString(onlineChatMember.chatRoomMember.getNick()));
NobleAvatarView nobleAvatarView = baseViewHolder.getView(R.id.noble_avatar_view);
// 头像
NobleAvatarView nobleAvatarView = helper.getView(R.id.noble_avatar_view);
nobleAvatarView.setSize(37, 54, 0);
nobleAvatarView.setData(onlineChatMember.chatRoomMember);
nobleAvatarView.setData(item);
// 官字
baseViewHolder.getView(R.id.iv_user_official).setVisibility(onlineChatMember.isOfficial() ? View.VISIBLE : View.GONE);
helper.getView(R.id.iv_user_official).setVisibility(item.isOfficial() ? View.VISIBLE : View.GONE);
// 管理
ImageView ivManager = helper.getView(R.id.manager_logo);
if (item.getMemberType() != null && item.getMemberType().equals("MANAGER")) {
ivManager.setVisibility(View.VISIBLE);
ivManager.setImageResource(R.drawable.icon_admin_logo);
} else if (item.getMemberType() != null && item.getMemberType().equals("CREATOR")) {
ivManager.setVisibility(View.VISIBLE);
ivManager.setImageResource(R.drawable.icon_user_list_room_ownner);
} else {
ivManager.setVisibility(View.GONE);
}
// 在麦
ImageView ivMic = helper.getView(R.id.room_online_tag);
ivMic.setVisibility(item.isInMic() ? View.VISIBLE : View.GONE);
//等级
UserLevelVo levelVo = item.getUserLevelVo();
String experLevelUrl = null;
String charmLevelUrl = null;
if (levelVo != null) {
experLevelUrl = levelVo.getExperUrl();
charmLevelUrl = levelVo.getCharmUrl();
}
//经验等级
AppCompatImageView ivUserExper = baseViewHolder.getView(R.id.iv_user_exper);
String experLevelUrl = NobleUtil.getLevel(UserLevelResourceType.EXPER_URL, onlineChatMember.chatRoomMember);
AppCompatImageView ivUserExper = helper.getView(R.id.iv_user_exper);
boolean isExperLevelUrlEmpty = TextUtils.isEmpty(experLevelUrl);
ivUserExper.setVisibility(!isExperLevelUrlEmpty ? View.VISIBLE : View.GONE);
if (!isExperLevelUrlEmpty) {
ImageLoadUtils.loadImage(mContext, experLevelUrl, ivUserExper);
}
//魅力等级
AppCompatImageView ivUserCharm = baseViewHolder.getView(R.id.iv_user_charm);
String charmLevelUrl = NobleUtil.getLevel(UserLevelResourceType.CHARM_URL, onlineChatMember.chatRoomMember);
AppCompatImageView ivUserCharm = helper.getView(R.id.iv_user_charm);
boolean isCharmLevelUrlEmpty = TextUtils.isEmpty(charmLevelUrl);
ivUserCharm.setVisibility(!isCharmLevelUrlEmpty ? View.VISIBLE : View.GONE);
if (!isCharmLevelUrlEmpty) {
ImageLoadUtils.loadImage(mContext, charmLevelUrl, ivUserCharm);
}
// 官方主播铭牌标识
String fixWord = NobleUtil.getLevel(UserInfo.OAC_NAME, onlineChatMember.chatRoomMember);
String iconPic = NobleUtil.getLevel(UserInfo.OAC_ICON, onlineChatMember.chatRoomMember);
View inOfficialMask = baseViewHolder.getView(R.id.in_official_mask);
if (!TextUtils.isEmpty(fixWord) && !TextUtils.isEmpty(iconPic)) {
inOfficialMask.setVisibility(View.VISIBLE);
TextView tvOfficialMask = inOfficialMask.findViewById(R.id.tv_official_mask);
if (tvOfficialMask != null) {
tvOfficialMask.setText(fixWord);
}
ImageView ivOfficialMask = inOfficialMask.findViewById(R.id.iv_official_mask);
if (ivOfficialMask != null) {
ImageLoadUtils.loadImage(mContext, iconPic, ivOfficialMask);
}
} else {
inOfficialMask.setVisibility(View.GONE);
}
// 铭牌
String namePlateWord = NobleUtil.getLevel(UserInfo.NAMEPLATE_WORD, onlineChatMember.chatRoomMember);
String namePlatePic = NobleUtil.getLevel(UserInfo.NAMEPLATE_PIC, onlineChatMember.chatRoomMember);
View inNamePlate = baseViewHolder.getView(R.id.in_nameplate);
if (!TextUtils.isEmpty(namePlateWord) && !TextUtils.isEmpty(namePlatePic)) {
inNamePlate.setVisibility(View.VISIBLE);
TextView tvNamePlate = inNamePlate.findViewById(R.id.tv_official_mask);
if (tvNamePlate != null) {
tvNamePlate.setText(namePlateWord);
}
ImageView ivNamePlate = inNamePlate.findViewById(R.id.iv_official_mask);
if (ivNamePlate != null) {
ImageLoadUtils.loadImage(mContext, namePlatePic, ivNamePlate);
}
} else {
inNamePlate.setVisibility(View.GONE);
}
AppCompatImageView ivUserLevel = baseViewHolder.getView(R.id.iv_noble_level);
String resource = (String) NobleUtil.getResource(NobleResourceType.KEY_BADGE, onlineChatMember.chatRoomMember);
if (TextUtils.isEmpty(resource)) {
ivUserLevel.setVisibility(View.GONE);
return;
}
ivUserLevel.setVisibility(View.VISIBLE);
NobleUtil.loadResource(resource, ivUserLevel);
}
private void setSexData(BaseViewHolder baseViewHolder, OnlineChatMember onlineChatMember) {
final ImageView sexImage = baseViewHolder.getView(R.id.sex);
String gender = NobleUtil.getLevel(UserInfo.GENDER, onlineChatMember.chatRoomMember);
if ("1".equals(gender)) {
sexImage.setVisibility(View.VISIBLE);
sexImage.setImageResource(R.drawable.ic_gender_male);
} else if ("2".equals(gender)) {
sexImage.setVisibility(View.VISIBLE);
sexImage.setImageResource(R.drawable.ic_gender_female);
} else {
NimUserInfo nimUserInfo = NimUserInfoCache.getInstance().getUserInfo(onlineChatMember.chatRoomMember.getAccount());
if (nimUserInfo == null) {
NimUserInfoCache.getInstance().getUserInfoFromRemote(onlineChatMember.chatRoomMember.getAccount(),
new RequestCallbackWrapper<NimUserInfo>() {
@Override
public void onResult(int i, NimUserInfo nimUserInfo, Throwable throwable) {
if (nimUserInfo != null) {
if (nimUserInfo.getGenderEnum() == GenderEnum.MALE) {
sexImage.setVisibility(View.VISIBLE);
sexImage.setImageResource(R.drawable.ic_gender_male);
} else if (nimUserInfo.getGenderEnum() == GenderEnum.FEMALE) {
sexImage.setVisibility(View.VISIBLE);
sexImage.setImageResource(R.drawable.ic_gender_female);
} else {
sexImage.setVisibility(View.GONE);
}
}
}
});
} else {
if (nimUserInfo.getGenderEnum() == GenderEnum.MALE) {
sexImage.setVisibility(View.VISIBLE);
sexImage.setImageResource(R.drawable.ic_gender_male);
} else if (nimUserInfo.getGenderEnum() == GenderEnum.FEMALE) {
sexImage.setVisibility(View.VISIBLE);
sexImage.setImageResource(R.drawable.ic_gender_female);
} else {
sexImage.setVisibility(View.GONE);
}
}
}
View inNamePlate = helper.getView(R.id.in_nameplate);
NamePlateHelper.INSTANCE.load(inNamePlate, inNamePlate.findViewById(R.id.tv_official_mask), inNamePlate.findViewById(R.id.iv_official_mask), item);
}
private void registerRoomEvent() {
@@ -240,7 +160,7 @@ public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<OnlineChatMembe
updateMemberIn(roomEvent);
} else if (event == RoomEvent.ROOM_MEMBER_EXIT) {
if (mListener != null) {
mListener.onMemberExit(roomEvent.getAccount(), mData);
mListener.onMemberExit(roomEvent.getAccount());
}
}
});
@@ -248,19 +168,19 @@ public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<OnlineChatMembe
private void updateMemberIn(RoomEvent roomEvent) {
if (mListener != null) {
mListener.onMemberIn(roomEvent.getAccount(), mData);
mListener.onMemberIn(roomEvent.getAccount());
}
}
private void updateManager(RoomEvent roomEvent) {
if (mListener != null)
mListener.onUpdateMemberManager(roomEvent.getAccount(),
roomEvent.getEvent() == RoomEvent.ROOM_MANAGER_REMOVE, mData);
roomEvent.getEvent() == RoomEvent.ROOM_MANAGER_REMOVE);
}
private void updateDownUpMic(String account, boolean isUpMic) {
if (mListener != null) {
mListener.onMemberDownUpMic(account, isUpMic, mData);
mListener.onMemberDownUpMic(account, isUpMic);
}
}
@@ -281,34 +201,29 @@ public class OnlineUserAdapter extends BaseMultiItemQuickAdapter<OnlineChatMembe
*
* @param account
*/
void onMemberIn(String account, List<OnlineChatMember> dataList);
void onMemberIn(String account);
/**
* 成员出去回调
*
* @param account
* @param dataList
*/
void onMemberExit(String account, List<OnlineChatMember> dataList);
void onMemberExit(String account);
/**
* 成员上下麦更新
*
* @param account
* @param isUpMic
* @param dataList
*/
void onMemberDownUpMic(String account, boolean isUpMic,
List<OnlineChatMember> dataList);
void onMemberDownUpMic(String account, boolean isUpMic);
/**
* 设置管理员回调
*
* @param account
* @param dataList
*/
void onUpdateMemberManager(String account, boolean isRemoveManager,
List<OnlineChatMember> dataList);
void onUpdateMemberManager(String account, boolean isRemoveManager);
void addMemberBlack();
}

View File

@@ -0,0 +1,40 @@
package com.yizhuan.erban.avroom.banner
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.core.util.Consumer
import com.yizhuan.erban.R
import com.yizhuan.erban.ui.utils.ImageLoadUtils
import com.yizhuan.erban.ui.widget.rollviewpager.adapter.StaticPagerAdapter
import com.yizhuan.xchat_android_core.room.bean.RoomIcon
class RoomBannerAdapter(private val mContext: Context, private val data: List<RoomIcon>) :
StaticPagerAdapter() {
var onItemClickListener: Consumer<RoomIcon>? = null
override fun getView(container: ViewGroup, position: Int): View {
val view = LayoutInflater.from(mContext).inflate(R.layout.item_room_act, container, false)
val ivCover = view.findViewById<ImageView>(R.id.iv_cover)
val bannerInfo = data[position]
val actId = bannerInfo.id?.toString()
ivCover.scaleType = ImageView.ScaleType.CENTER_CROP
ImageLoadUtils.loadImage(
mContext,
bannerInfo.icon,
ivCover,
R.drawable.default_cover
)
ivCover.setOnClickListener { v: View? ->
onItemClickListener?.accept(bannerInfo)
}
return view
}
override fun getCount(): Int {
return data.size
}
}

View File

@@ -0,0 +1,194 @@
package com.yizhuan.erban.avroom.banner
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.Drawable
import android.graphics.drawable.GradientDrawable
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.RelativeLayout
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import androidx.databinding.DataBindingUtil
import com.yizhuan.erban.R
import com.yizhuan.erban.avroom.firstcharge.FirstChargeDialog
import com.yizhuan.erban.databinding.RoomBannerWidgetBinding
import com.yizhuan.erban.shipantics.PullRadishActivity
import com.yizhuan.erban.treasure_box.widget.GoldBoxHelper
import com.yizhuan.erban.treasurefairy.HomeFairyActivity
import com.yizhuan.erban.ui.webview.CommonWebViewActivity
import com.yizhuan.erban.ui.webview.room_banner.RoomBannerWebDialogActivity
import com.yizhuan.erban.ui.webview.room_banner.RoomWebDialogActivity
import com.yizhuan.erban.ui.widget.rollviewpager.Util
import com.yizhuan.erban.ui.widget.rollviewpager.hintview.ColorPointHintView
import com.yizhuan.erban.utils.CommonJumpHelper
import com.yizhuan.xchat_android_core.room.bean.RoomIcon
import com.yizhuan.xchat_android_core.room.bean.RoomInfo
import com.yizhuan.xchat_android_core.room.model.AvRoomModel
import com.yizhuan.xchat_android_core.support.room.FrameLayoutRoomWidget
import com.yizhuan.xchat_android_core.support.room.RoomContext
import com.yizhuan.xchat_android_core.support.room.RoomView
import okhttp3.internal.filterList
/**
* Created by Max on 2024/2/20 10:42
* Desc:玩法活动
**/
class RoomBannerWidget : FrameLayoutRoomWidget {
private val binding: RoomBannerWidgetBinding =
DataBindingUtil.inflate(
LayoutInflater.from(
context
), R.layout.room_banner_widget, this, true
)
private var indicatorVisible = false
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
)
constructor(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int,
defStyleRes: Int
) : super(context, attrs, defStyleAttr, defStyleRes)
init {
setIndicatorEnabled(true)
}
override fun onInitialize(roomView: RoomView, roomContext: RoomContext) {
super.onInitialize(roomView, roomContext)
refreshData()
}
fun disabledIndicator() {
setIndicatorEnabled(false)
}
fun refreshData() {
if (RoomContext.get()?.getRoomInfo()?.type == RoomInfo.ROOMTYPE_GAME) {
refreshData(true)
} else {
refreshData(false)
}
}
private fun refreshData(isGameRoom: Boolean) {
val disposable = if (isGameRoom) {
AvRoomModel.get().gameRoomBannerList
} else {
AvRoomModel.get().roomBannerList
}.subscribe { list: List<RoomIcon> ->
loadData(list)
}
getCompositeDisposable().add(disposable)
}
private fun loadData(list: List<RoomIcon>?) {
if (list.isNullOrEmpty()) {
this.isVisible = false
return
}
this.isVisible = true
// 只有一個圖標,隱藏底部指示器
indicatorVisible = list.size > 1
val bannerAdapter = RoomBannerAdapter(context, list)
bannerAdapter.onItemClickListener = androidx.core.util.Consumer<RoomIcon> {
if (it.isSeizeTreasure()) {
HomeFairyActivity.start(context)
} else if (it.isFirstCharge()) {
FirstChargeDialog.start(context)
} else if (it.isFindLove()) {
GoldBoxHelper.handleBoxClick(context)
} else if (it.isNauticalAdventure()) {
PullRadishActivity.start(context)
} else {
AvRoomModel.get().activityClickLog("2", it.id?.toString()).subscribe()
if (it.skipType == 3) {
if (it.tag == RoomIcon.TAG_GAMEPLAY) {
if (it.showType == 2) {
RoomWebDialogActivity.start(context, it.skipContent ?: "", false)
} else {
CommonWebViewActivity.start(context, it.skipContent ?: "")
}
} else {
val newList = list.filterList {
skipType == 3 && tag != RoomIcon.TAG_GAMEPLAY
}
val newPosition = newList.indexOfFirst { item ->
item == it
}
RoomBannerWebDialogActivity.start(context, newPosition, newList)
}
} else {
CommonJumpHelper.bannerJump(context, it)
}
}
}
binding.pagerView.adapter = bannerAdapter
binding.pagerView.setPlayDelay(3000)
//設置透明度
binding.pagerView.setAnimationDurtion(500)
bannerAdapter.notifyDataSetChanged()
val viewPager = binding.pagerView.viewPager
viewPager.offscreenPageLimit = list.size
}
private fun setIndicatorEnabled(isEnabled: Boolean) {
// 模擬指示器在viewpager底部效果
val viewPager = binding.pagerView.viewPager
val layoutParams = viewPager.layoutParams as RelativeLayout.LayoutParams
if (isEnabled) {
layoutParams.setMargins(0, 0, 0, Util.dip2px(context, 7f))
binding.pagerView.setHintView(object : ColorPointHintView(
context, Color.WHITE, ContextCompat.getColor(
context,
R.color.color_66FFFFFF
)
) {
override fun makeFocusDrawable(): Drawable? {
val dotFocus = GradientDrawable()
dotFocus.setColor(Color.WHITE)
dotFocus.cornerRadius = Util.dip2px(
context, 2f
).toFloat()
dotFocus.setSize(
Util.dip2px(context, 9f), Util.dip2px(
context, 4f
)
)
return if (indicatorVisible) dotFocus else null
}
override fun makeNormalDrawable(): Drawable? {
val dotNormal = GradientDrawable()
dotNormal.setColor(ContextCompat.getColor(context, R.color.color_66FFFFFF))
dotNormal.cornerRadius = Util.dip2px(
context, 2f
).toFloat()
dotNormal.setSize(
Util.dip2px(context, 4f), Util.dip2px(
context, 4f
)
)
return if (indicatorVisible) dotNormal else null
}
})
} else {
layoutParams.setMargins(0, 0, 0, 0)
binding.pagerView.setHintView(null)
}
viewPager.layoutParams = layoutParams
}
}

View File

@@ -6,9 +6,6 @@ import android.app.Activity
import android.content.DialogInterface
import android.content.Intent
import android.content.pm.PackageManager
import android.graphics.Color
import android.graphics.drawable.Drawable
import android.graphics.drawable.GradientDrawable
import android.os.Bundle
import android.text.TextUtils
import android.view.KeyEvent
@@ -47,7 +44,6 @@ import com.yizhuan.erban.avroom.dialog.AttentionHintDialog
import com.yizhuan.erban.avroom.dialog.DatingVipRuleDialog
import com.yizhuan.erban.avroom.dialog.RoomFreeGiftDialog
import com.yizhuan.erban.avroom.dialog.RoomOperationDialog
import com.yizhuan.erban.avroom.firstcharge.FirstChargeDialog
import com.yizhuan.erban.avroom.presenter.BaseRoomPresenter
import com.yizhuan.erban.avroom.redpackage.send.RedPackageSendDialog
import com.yizhuan.erban.avroom.room_album.RoomAlbumModel
@@ -59,34 +55,24 @@ import com.yizhuan.erban.base.BaseMvpActivity
import com.yizhuan.erban.base.BaseMvpFragment
import com.yizhuan.erban.event.OpenRoomIntroEvent
import com.yizhuan.erban.friend.view.SelectFriendActivity
import com.yizhuan.erban.home.adapter.RoomActAdapter
import com.yizhuan.erban.shipantics.PullRadishActivity
import com.yizhuan.erban.treasure_box.widget.GoldBoxHelper
import com.yizhuan.erban.ui.webview.DialogWebViewActivity
import com.yizhuan.erban.ui.widget.ButtonItem
import com.yizhuan.erban.ui.widget.GiftDialog
import com.yizhuan.erban.ui.widget.GiftDialog.OnGiftDialogBtnClickListener
import com.yizhuan.erban.ui.widget.GiftDialog.SenGiftCallback
import com.yizhuan.erban.ui.widget.UserInfoDialog
import com.yizhuan.erban.ui.widget.dynamicface.DynamicFaceDialog
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil
import com.yizhuan.erban.ui.widget.rollviewpager.RollPagerView
import com.yizhuan.erban.ui.widget.rollviewpager.Util
import com.yizhuan.erban.ui.widget.rollviewpager.hintview.ColorPointHintView
import com.yizhuan.erban.utils.KeyBoardUtils
import com.yizhuan.tutu.music.widget.MusicPlayerView
import com.yizhuan.tutu.room_chat.activity.RoomMsgActivity
import com.yizhuan.xchat_android_constants.XChatConstants
import com.yizhuan.xchat_android_core.Constants
import com.yizhuan.xchat_android_core.DemoCache
import com.yizhuan.xchat_android_core.UriProvider
import com.yizhuan.xchat_android_core.auth.AuthModel
import com.yizhuan.xchat_android_core.bean.RoomMicInfo
import com.yizhuan.xchat_android_core.gift.GiftModel
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo
import com.yizhuan.xchat_android_core.gift.event.RoomFreeGiftEvent
import com.yizhuan.xchat_android_core.helper.AtProxy
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
import com.yizhuan.xchat_android_core.home.event.OpenRoomMessageInputEvent
import com.yizhuan.xchat_android_core.im.custom.bean.RoomFollowOwnerAttachment
import com.yizhuan.xchat_android_core.im.custom.bean.RoomFollowOwnerAttachment2
@@ -97,7 +83,6 @@ import com.yizhuan.xchat_android_core.manager.RoomEvent
import com.yizhuan.xchat_android_core.mentoring_relationship.event.MentoringStopCountingEvent
import com.yizhuan.xchat_android_core.room.anotherroompk.ShowGiftDialogEvent
import com.yizhuan.xchat_android_core.room.anotherroompk.ShowUserInfoDialogEvent
import com.yizhuan.xchat_android_core.room.bean.RoomContributeUserInfo
import com.yizhuan.xchat_android_core.room.bean.RoomInfo
import com.yizhuan.xchat_android_core.room.event.RoomAtEvent
import com.yizhuan.xchat_android_core.room.event.RoomClearScreenEvent
@@ -147,7 +132,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
protected lateinit var inputSend: ImageView
protected lateinit var microView: MicroView
private var musicPlayerView: MusicPlayerView? = null
private var ivRadishEntrance: View? = null
private var mVsMusicPlayer: ViewStub? = null
private var mDisposable: Disposable? = null
private var isCloseScreen = false
@@ -207,7 +191,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
inputSend = mView.findViewById(R.id.input_send)
microView = mView.findViewById(R.id.micro_view)
mVsMusicPlayer = mView.findViewById(R.id.vs_music_player)
ivRadishEntrance = mView.findViewById(R.id.iv_radish_entrance)
messageView.setClickConsumer {
if (!TextUtils.isEmpty(it) && it != "0") {
showUserCardDialog(it)
@@ -287,13 +270,8 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
// 刷新禮物列表,獲取房間專屬禮物列表
GiftModel.get().refreshGiftList(AvRoomDataManager.get().roomUid.toString()).subscribe()
checkFollowOwner()
mvpPresenter?.loadRoomRank()
GiftValueMrg.get().updateRoomGiftValue(false)
//先隐藏航海冒险
// ivRadishEntrance?.isVisible =
// !GoldBoxHelper.needIntegrateBoxEntrance() && GoldBoxHelper.isShowRadish()
//获取免费礼物详情
mvpPresenter?.queryFreeFlower()
initRoomAlbum()
@@ -355,6 +333,7 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
updateRemoteMuteBtn()
openOrCloseGiftValue(true)
GiftValueMrg.get().updateRoomGiftValue(false)
onEnterRoom()
}
RoomEvent.ADD_BLACK_LIST -> onChatRoomMemberBlackAdd(roomEvent.account)
@@ -464,68 +443,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
}
}
fun initRoomAct(
rollPagerView: RollPagerView,
dialogInfo: List<BannerInfo>,
bottomDp: Float = 0f
) {
if (!ListUtils.isListEmpty(dialogInfo)) {
rollPagerView.visibility = View.VISIBLE
// 只有一個圖標,隱藏底部指示器
val show = dialogInfo.size > 1
rollPagerView.setHintView(object : ColorPointHintView(
mContext, Color.WHITE, ContextCompat.getColor(
mContext,
R.color.color_66FFFFFF
)
) {
override fun makeFocusDrawable(): Drawable? {
val dotFocus = GradientDrawable()
dotFocus.setColor(Color.WHITE)
dotFocus.cornerRadius = Util.dip2px(
context, 2f
).toFloat()
dotFocus.setSize(
Util.dip2px(context, 9f), Util.dip2px(
context, 4f
)
)
return if (show) dotFocus else null
}
override fun makeNormalDrawable(): Drawable? {
val dotNormal = GradientDrawable()
dotNormal.setColor(ContextCompat.getColor(mContext, R.color.color_66FFFFFF))
dotNormal.cornerRadius = Util.dip2px(
context, 2f
).toFloat()
dotNormal.setSize(
Util.dip2px(context, 4f), Util.dip2px(
context, 4f
)
)
return if (show) dotNormal else null
}
})
val bannerAdapter = RoomActAdapter(mContext, dialogInfo)
rollPagerView.adapter = bannerAdapter
rollPagerView.setPlayDelay(3000)
//設置透明度
rollPagerView.setAnimationDurtion(500)
bannerAdapter.notifyDataSetChanged()
bannerAdapter.setRoomActClickListener { url ->
DialogWebViewActivity.start(mContext, url)
}
// 模擬指示器在viewpager底部效果
val viewPager = rollPagerView.viewPager
viewPager.offscreenPageLimit = dialogInfo.size
val layoutParams = viewPager.layoutParams as RelativeLayout.LayoutParams
layoutParams.setMargins(0, 0, 0, UIUtil.dip2px(mContext, bottomDp.toDouble()))
viewPager.layoutParams = layoutParams
}
}
private fun releaseView() {
roomFreeGiftDialog?.dismiss()
messageView.release()
@@ -557,6 +474,9 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
if (isOnMic) {
if (musicPlayerView == null) {
musicPlayerView = mVsMusicPlayer?.inflate() as? MusicPlayerView
musicPlayerView?.let {
onInitMusicPlayerView(it)
}
}
musicPlayerView?.visibility = View.VISIBLE
} else {
@@ -586,10 +506,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
) {
@@ -678,17 +595,6 @@ 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)
}
}
@@ -1161,18 +1067,6 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
microView.adapter.notifyDataSetChanged()
}
override fun updateRoomRanks(data: List<RoomContributeUserInfo>) {
// val avatarList = arrayListOf<ImageView?>(
// mView.findViewById(R.id.iv_rank_0),
// mView.findViewById(R.id.iv_rank_1),
// mView.findViewById(R.id.iv_rank_2)
// )
//
// for (i in 0 until avatarList.size) {
// avatarList[i]?.loadAvatar(data.getOrNull(i)?.avatar)
// }
}
private fun onSendGiftBtnClick(giftId: Int = 0) {
if (giftDialog == null) {
GiftDialog.GIFT_DIALOG_FROM = getString(R.string.room)
@@ -1337,6 +1231,10 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
return this
}
override fun findWidget(name: String): RoomWidget? {
return widgets[name]
}
open fun initWidget() {
}
@@ -1365,4 +1263,12 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
inputEdit.requestFocus()
KeyBoardUtils.showKeyBoard(context, inputEdit)
}
protected open fun onEnterRoom(){
}
protected open fun onInitMusicPlayerView(view: MusicPlayerView) {
}
}

View File

@@ -10,15 +10,16 @@ import com.yizhuan.erban.R
import com.yizhuan.erban.avroom.adapter.GameMicroViewAdapter
import com.yizhuan.erban.avroom.adapter.GameMiniMicroViewAdapter
import com.yizhuan.erban.avroom.adapter.OnMicroItemClickListener
import com.yizhuan.erban.avroom.banner.RoomBannerWidget
import com.yizhuan.erban.avroom.firstcharge.FirstChargePrizeDialog
import com.yizhuan.erban.avroom.game.GameDelegate
import com.yizhuan.erban.avroom.game.OnGameStatusChangeListener
import com.yizhuan.erban.avroom.presenter.GameRoomPresenter
import com.yizhuan.erban.avroom.rank.RoomRankWidget
import com.yizhuan.erban.avroom.redpackage.RedPackageWidget
import com.yizhuan.erban.avroom.view.IGameRoomView
import com.yizhuan.erban.databinding.FragmentGameRoomBinding
import com.yizhuan.erban.ui.widget.GiftDialog.OnGiftDialogBtnClickListener
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
import com.yizhuan.xchat_android_core.music.model.PlayerModel
import com.yizhuan.xchat_android_core.pay.event.FirstChargeEvent
@@ -68,9 +69,9 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
AvRoomDataManager.get().mCurrentRoomInfo?.mgId
)
gameDelegate.setOnGameStatusChangeListener(this)
gameBinding.rankWidget.setContentBackgroundResource(R.drawable.room_rank_widget_bg_game)
}
@SuppressLint("CheckResult")
override fun initiate() {
gameBinding.microView.bindAdapter(GameMicroViewAdapter(context))
@@ -78,7 +79,6 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
//游戏模式暂时不需要这个
PlayerModel.get().stop()
gameBinding.roomInfo = AvRoomDataManager.get().mCurrentRoomInfo
mvpPresenter?.getBannerList()
gameBinding.tvShowMiniMic.setOnClickListener { showMiniMic() }
gameBinding.ivShowMic.setOnClickListener { showMic() }
}
@@ -150,10 +150,6 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
}
}
override fun onShowBanner(dialogInfos: List<BannerInfo>) {
initRoomAct(gameBinding.activityImg, dialogInfos)
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun onFinishAvRoomEvent(event: FinishAvRoomEvent) {
gameDelegate.exitGame()
@@ -161,6 +157,8 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
@Subscribe(threadMode = ThreadMode.MAIN)
fun onFirstRechargeEvent(event: FirstChargeEvent) {
// banner里可能有首充入口刷新下
gameBinding.bannerWidget.refreshData()
FirstChargePrizeDialog(
requireContext(),
event.chargeProdTitle,
@@ -196,6 +194,9 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
override fun initWidget() {
super.initWidget()
gameBinding.bannerWidget.disabledIndicator()
registerWidget(RedPackageWidget::class.java.simpleName, gameBinding.redPackageWidget)
registerWidget(RoomRankWidget::class.java.simpleName, gameBinding.rankWidget)
registerWidget(RoomBannerWidget::class.java.simpleName, gameBinding.bannerWidget)
}
}

View File

@@ -16,8 +16,11 @@ import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.core.content.ContextCompat;
import androidx.core.util.Consumer;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.netease.nim.uikit.common.util.string.StringUtil;
@@ -37,7 +40,9 @@ import com.yizhuan.erban.base.BaseFragment;
import com.yizhuan.erban.databinding.FragmentChatroomGameMainBinding;
import com.yizhuan.erban.friend.view.SelectFriendActivity;
import com.yizhuan.erban.home.helper.OpenRoomHelper;
import com.yizhuan.erban.ui.widget.GiftDialog;
import com.yizhuan.erban.ui.widget.ShareDialog;
import com.yizhuan.erban.ui.widget.UserInfoDialog;
import com.yizhuan.erban.utils.RegexUtil;
import com.yizhuan.xchat_android_core.gift.bean.GiftMultiReceiverInfo;
import com.yizhuan.xchat_android_core.gift.bean.GiftReceiveInfo;
@@ -114,6 +119,7 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
private String FOLLOW_ROOM_TYPE = "";
private SelectGameAdapter gameAdapter;
public final MutableLiveData<Boolean> playNotifyStateLiveData = new MutableLiveData<Boolean>(false);
public static HomePartyFragment newInstance() {
HomePartyFragment homePartyFragment = new HomePartyFragment();
@@ -213,11 +219,22 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
ivRoomShare.setOnClickListener(this);
gameMainBinding.llRoomInfo.setOnClickListener(this);
gameMainBinding.ivBack.setOnClickListener(this);
mRoomEffectView.setShowUserCardAction(s -> {
if (roomFragment instanceof GiftDialog.OnGiftDialogBtnClickListener) {
UserInfoDialog.showNewUserInfoDialog(
mContext,
JavaUtil.str2long(s),
true,
true,
true, (GiftDialog.OnGiftDialogBtnClickListener) roomFragment
);
}
});
mRoomEffectView.setPlayNotifyStateListener(playNotifyStateLiveData);
mRoomEffectView.setOnPlayAnimCallback(new Function0<Boolean>() {
@Override
public Boolean invoke() {
return getIsAnim();
return isShowingGiftNotify();
}
});
}
@@ -360,18 +377,22 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
*
* @return
*/
private boolean getIsAnim() {
if (giftView != null) {
return giftView.getIsPlayAnim();
private boolean isShowingGiftNotify() {
if ((getActivity() instanceof AVRoomActivity)) {
return ((AVRoomActivity) getActivity()).isShowingGiftNotify();
}
return false;
}
/**
* 获取玩法飘屏是否展示
*/
private boolean getIsPlayAnim() {
return mRoomEffectView.getIsPlayAnim();
public LiveData<Boolean> getPlayNotifyState(){
return playNotifyStateLiveData;
}
public boolean isShowingPlayNotify(){
if(playNotifyStateLiveData.getValue()==null) {
return false;
}
return playNotifyStateLiveData.getValue();
}
private void onReceiveLuckyGiftToMultiMsg(LuckyBagGifts giftMultiReceiverInfo) {

View File

@@ -5,6 +5,7 @@ import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import com.netease.nim.uikit.common.util.log.LogUtil;
@@ -19,13 +20,17 @@ import com.yizhuan.erban.avroom.adapter.MicroViewAdapter;
import com.yizhuan.erban.avroom.anotherroompk.RoomPkFinishDialog;
import com.yizhuan.erban.avroom.anotherroompk.RoomPkForceFinishDialog;
import com.yizhuan.erban.avroom.anotherroompk.RoomPkReceivedDialog;
import com.yizhuan.erban.avroom.banner.RoomBannerWidget;
import com.yizhuan.erban.avroom.dialog.MicQueueDialog;
import com.yizhuan.erban.avroom.dialog.PKMicQueueDialog;
import com.yizhuan.erban.avroom.dialog.PKResultDialog;
import com.yizhuan.erban.avroom.dialog.PKScoreBoardDialog;
import com.yizhuan.erban.avroom.firstcharge.FirstChargePrizeDialog;
import com.yizhuan.erban.avroom.gameplay.RoomGameplayListWidget;
import com.yizhuan.erban.avroom.gameplay.RoomGameplayWidget;
import com.yizhuan.erban.avroom.giftvalue.GiftValueDialogUiHelper;
import com.yizhuan.erban.avroom.presenter.HomePartyPresenter;
import com.yizhuan.erban.avroom.rank.RoomRankWidget;
import com.yizhuan.erban.avroom.redpackage.RedPackageWidget;
import com.yizhuan.erban.avroom.view.IHomePartyView;
import com.yizhuan.erban.avroom.widget.PKBoardView;
@@ -36,6 +41,7 @@ import com.yizhuan.erban.treasure_box.widget.GoldBoxHelper;
import com.yizhuan.erban.ui.webview.DatingRuleWebViewActivity;
import com.yizhuan.erban.ui.webview.DialogWebViewActivity;
import com.yizhuan.erban.utils.UserUtils;
import com.yizhuan.tutu.music.widget.MusicPlayerView;
import com.yizhuan.xchat_android_core.Constants;
import com.yizhuan.xchat_android_core.UriProvider;
import com.yizhuan.xchat_android_core.auth.AuthModel;
@@ -138,6 +144,10 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
public void initWidget() {
super.initWidget();
registerWidget(RedPackageWidget.class.getSimpleName(), gameBinding.redPackageWidget);
registerWidget(RoomRankWidget.class.getSimpleName(), gameBinding.rankWidget);
registerWidget(RoomBannerWidget.class.getSimpleName(), gameBinding.bannerWidget);
registerWidget(RoomGameplayListWidget.class.getSimpleName(), gameBinding.gameplayListWidget);
registerWidget(RoomGameplayWidget.class.getSimpleName(), gameBinding.gameplayWidget);
}
@SuppressLint("CheckResult")
@@ -151,7 +161,6 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
updateQueuingMicBtn();
updatePkScoreBoard();
initRoomPkOrder(AvRoomDataManager.get().showPkBeginTime, AvRoomDataManager.get().pkBeginTime);
getMvpPresenter().getBannerList();
// if (!GoldBoxHelper.needIntegrateBoxEntrance()) {
// UserModel.get().getCurrentUserInfo()
// .compose(bindToLifecycle())
@@ -603,7 +612,7 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
getMvpPresenter().cancelDragon();
});
break;
case R.id.tv_hour_rank:
case R.id.layout_hour_rank:
DialogWebViewActivity.start(
mContext,
UriProvider.getRoomHourRankUrl(AvRoomDataManager.get().getRoomUid())
@@ -787,7 +796,6 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
private void hideKtvRelaView() {
gameBinding.setKtvModel(false);
gameBinding.contributeList.setVisibility(View.VISIBLE);
changeModelShowView();
gameBinding.bottomView.showKtvBottom(false);
}
@@ -799,40 +807,10 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
}
if (AvRoomDataManager.get().mCurrentRoomInfo.getIsPermitRoom() == 1) {
gameBinding.tvHourRank.setVisibility(View.VISIBLE);
gameBinding.layoutHourRank.setVisibility(View.VISIBLE);
} else {
gameBinding.tvHourRank.setVisibility(View.GONE);
gameBinding.layoutHourRank.setVisibility(View.GONE);
}
if (!GoldBoxHelper.needIntegrateBoxEntrance()) {
GoldBoxHelper.isHideBox().subscribe(
hide -> {
if (hide != null && !hide) {
if (AvRoomDataManager.get().isCpRoom()) {
gameBinding.ivTreasureBoxCp.setVisibility(View.VISIBLE);
gameBinding.ivTreasureBox.setVisibility(View.GONE);
} else {
gameBinding.ivTreasureBoxCp.setVisibility(View.GONE);
gameBinding.ivTreasureBox.setVisibility(View.VISIBLE);
GlideApp.with(BasicConfig.INSTANCE.getAppContext())
.load(GoldBoxHelper.getBoxIcon())
.error(R.drawable.icon_room_treasure_box)
.into(gameBinding.ivTreasureBox);
}
} else {
gameBinding.ivTreasureBoxCp.setVisibility(View.GONE);
gameBinding.ivTreasureBox.setVisibility(View.GONE);
}
},
throwable -> {
gameBinding.ivTreasureBoxCp.setVisibility(View.GONE);
gameBinding.ivTreasureBox.setVisibility(View.GONE);
});
} else {
gameBinding.ivTreasureBoxCp.setVisibility(View.GONE);
gameBinding.ivTreasureBox.setVisibility(View.GONE);
}
setDragonView();
}
@@ -966,15 +944,11 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
return pkMicQueueDialog != null && pkMicQueueDialog.isShowing();
}
@Override
public void onShowBanner(List<BannerInfo> bannerInfos) {
initRoomAct(gameBinding.activityImg, bannerInfos, 11f);
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onFirstRechargeEvent(FirstChargeEvent event) {
gameBinding.ivFirstChargeEnter.setVisibility(View.GONE);
// banner里可能有首充入口刷新下
gameBinding.bannerWidget.refreshData();
new FirstChargePrizeDialog(requireContext(), event.getChargeProdTitle(), event.getFirstChargeRewardList()).openDialog();
}
@@ -1070,4 +1044,10 @@ public class HomePartyRoomFragment extends BaseRoomFragment<IHomePartyView, Home
}
}
}
@Override
protected void onInitMusicPlayerView(@NonNull MusicPlayerView view) {
super.onInitMusicPlayerView(view);
view.linkIconView(gameBinding.ivMusic, gameBinding.ivMusic);
}
}

View File

@@ -7,28 +7,24 @@ import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.netease.nim.uikit.common.util.sys.NetworkUtil;
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMember;
import com.orhanobut.logger.Logger;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadmoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import com.yizhuan.erban.R;
import com.yizhuan.erban.avroom.adapter.OnlineUserAdapter;
import com.yizhuan.erban.avroom.presenter.HomePartyUserListPresenter;
import com.yizhuan.erban.avroom.view.IHomePartyUserListView;
import com.yizhuan.erban.base.BaseMvpFragment;
import com.yizhuan.erban.ui.widget.UserInfoDialog;
import com.yizhuan.xchat_android_core.Constants;
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
import com.yizhuan.xchat_android_core.room.bean.OnlineChatMember;
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
import com.yizhuan.xchat_android_core.super_admin.util.SuperAdminUtil;
import com.yizhuan.xchat_android_core.room.bean.RoomOnlineUserBean;
import com.yizhuan.xchat_android_library.base.factory.CreatePresenter;
import com.yizhuan.xchat_android_library.utils.JavaUtil;
import com.yizhuan.xchat_android_library.utils.ListUtils;
import com.yizhuan.xchat_android_library.utils.ResUtil;
import java.util.Iterator;
import java.util.List;
/**
@@ -44,7 +40,6 @@ public class OnlineUserFragment extends BaseMvpFragment<IHomePartyUserListView,
private SmartRefreshLayout mRefreshLayout;
private OnlineUserAdapter mOnlineUserAdapter;
private int mPage = Constants.PAGE_START;
private boolean isShowToUser = false;
@Override
@@ -58,24 +53,12 @@ public class OnlineUserFragment extends BaseMvpFragment<IHomePartyUserListView,
public void onFindViews() {
mRecyclerView = mView.findViewById(R.id.recycler_view);
mRefreshLayout = mView.findViewById(R.id.refresh_layout);
mRefreshLayout.setEnableLoadmore(false);
}
@Override
public void onSetListener() {
mRefreshLayout.setOnRefreshLoadmoreListener(new OnRefreshLoadmoreListener() {
@Override
public void onLoadmore(RefreshLayout refreshLayout) {
if (!NetworkUtil.isNetAvailable(mContext)) {
mRefreshLayout.finishLoadmore();
return;
}
List<OnlineChatMember> data = mOnlineUserAdapter.getData();
if (ListUtils.isListEmpty(data)) {
mRefreshLayout.finishLoadmore();
return;
}
loadData(data.get(data.size() - 1).chatRoomMember.getEnterTime());
}
mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh(RefreshLayout refreshLayout) {
@@ -106,53 +89,24 @@ public class OnlineUserFragment extends BaseMvpFragment<IHomePartyUserListView,
public void firstLoad() {
mPage = Constants.PAGE_START;
loadData(0);
loadData();
}
private void loadData(long time) {
getMvpPresenter().requestChatMemberByPage(mPage, time,
mOnlineUserAdapter == null ? null : mOnlineUserAdapter.getData());
private void loadData() {
getMvpPresenter().requestRoomOnlineList(AvRoomDataManager.get().getRoomUid());
}
@Override
public void onRequestChatMemberByPageSuccess(List<OnlineChatMember> chatRoomMemberList, int page) {
mPage = page;
if (!ListUtils.isListEmpty(chatRoomMemberList)) {
//超管不显示
Iterator<OnlineChatMember> iterator = chatRoomMemberList.iterator();
while (iterator.hasNext()) {
OnlineChatMember member = iterator.next();
if (member != null && SuperAdminUtil.isSuperAdmin(member.chatRoomMember)) {
iterator.remove();
}
}
mOnlineUserAdapter.setNewData(chatRoomMemberList);
if (mPage == Constants.PAGE_START) {
mRefreshLayout.finishRefresh();
} else {
mRefreshLayout.finishLoadmore(0);
}
mPage++;
} else {
if (mPage == Constants.PAGE_START) {
mRefreshLayout.finishRefresh();
} else {
mRefreshLayout.finishLoadmore(0);
}
}
public void onRequestRoomOnlineListSuccess(List<RoomOnlineUserBean> list) {
mOnlineUserAdapter.setNewData(list);
mRefreshLayout.finishRefresh();
}
@Override
public void onRequestChatMemberByPageFail(String errorStr, int page) {
Logger.i(ResUtil.getString(R.string.avroom_fragment_onlineuserfragment_01) + page);
mPage = page;
if (mPage == Constants.PAGE_START) {
mRefreshLayout.finishRefresh();
} else {
mRefreshLayout.finishLoadmore(0);
}
mRefreshLayout.finishRefresh();
}
@Override
@@ -166,16 +120,15 @@ public class OnlineUserFragment extends BaseMvpFragment<IHomePartyUserListView,
public void onItemClick(BaseQuickAdapter baseQuickAdapter, View view, int position) {
RoomInfo currentRoom = AvRoomDataManager.get().mCurrentRoomInfo;
if (currentRoom != null) {
List<OnlineChatMember> chatRoomMembers = mOnlineUserAdapter.getData();
List<RoomOnlineUserBean> chatRoomMembers = mOnlineUserAdapter.getData();
if (ListUtils.isListEmpty(chatRoomMembers)) return;
OnlineChatMember onlineChatMember = chatRoomMembers.get(position);
ChatRoomMember chatRoomMember = onlineChatMember.chatRoomMember;
if (chatRoomMember != null) {
RoomOnlineUserBean onlineChatMember = chatRoomMembers.get(position);
if (onlineChatMember != null) {
if (onlineChatMember.getItemType() == OnlineChatMember.NOBLE) {
return;
}
UserInfoDialog.showNewUserInfoDialog(mContext,
JavaUtil.str2long(chatRoomMember.getAccount()),
onlineChatMember.getUid(),
true,
false,
true,
@@ -185,28 +138,25 @@ public class OnlineUserFragment extends BaseMvpFragment<IHomePartyUserListView,
}
@Override
public void onMemberIn(String account, List<OnlineChatMember> dataList) {
// if (!isResumed()) return;
// getMvpPresenter().onMemberInRefreshData(account, dataList, mPage);
public void onMemberIn(String account) {
}
@Override
public void onMemberExit(String account, List<OnlineChatMember> dataList) {
public void onMemberExit(String account) {
// if (!isResumed()) return;
// if (!isShowToUser()) return;
// firstLoad();
}
@Override
public void onMemberDownUpMic(String account, boolean isUpMic, List<OnlineChatMember> dataList) {
if (!isResumed()) return;
getMvpPresenter().onMemberDownUpMic(account, isUpMic, dataList, mPage);
public void onMemberDownUpMic(String account, boolean isUpMic) {
}
@Override
public void onUpdateMemberManager(String account, boolean isRemoveManager, List<OnlineChatMember> dataList) {
if (!isResumed()) return;
getMvpPresenter().onUpdateMemberManager(account, dataList, isRemoveManager, mPage);
public void onUpdateMemberManager(String account, boolean isRemoveManager) {
}
@Override

View File

@@ -13,9 +13,13 @@ import com.yizhuan.erban.R
import com.yizhuan.erban.avroom.adapter.OnMicroItemClickListener
import com.yizhuan.erban.avroom.adapter.SingleAnchorMicroViewAdapter
import com.yizhuan.erban.avroom.adapter.SingleRoomPKMicroViewAdapter
import com.yizhuan.erban.avroom.banner.RoomBannerWidget
import com.yizhuan.erban.avroom.dialog.RequestUpMicDialog
import com.yizhuan.erban.avroom.firstcharge.FirstChargePrizeDialog
import com.yizhuan.erban.avroom.gameplay.RoomGameplayListWidget
import com.yizhuan.erban.avroom.gameplay.RoomGameplayWidget
import com.yizhuan.erban.avroom.presenter.SingleRoomPresenter
import com.yizhuan.erban.avroom.rank.RoomRankWidget
import com.yizhuan.erban.avroom.redpackage.RedPackageWidget
import com.yizhuan.erban.avroom.singleroompk.SingleRoomPkFinishDialog
import com.yizhuan.erban.avroom.singleroompk.SingleRoomPkForceFinishDialog
@@ -25,14 +29,12 @@ import com.yizhuan.erban.databinding.FragmentSingleRoomBinding
import com.yizhuan.erban.fansteam.FansTeamJoinActivity
import com.yizhuan.erban.fansteam.FansTeamJoinedActivity
import com.yizhuan.erban.fansteam.FansTeamViewModel
import com.yizhuan.erban.treasure_box.widget.GoldBoxHelper
import com.yizhuan.erban.ui.utils.load
import com.yizhuan.erban.ui.webview.CommonWebViewActivity
import com.yizhuan.erban.ui.webview.DialogWebViewActivity
import com.yizhuan.tutu.music.widget.MusicPlayerView
import com.yizhuan.xchat_android_core.UriProvider
import com.yizhuan.xchat_android_core.auth.AuthModel
import com.yizhuan.xchat_android_core.fansteam.FansTeamInitInfo
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
import com.yizhuan.xchat_android_core.im.custom.bean.FansTeamMsgAttachment
import com.yizhuan.xchat_android_core.im.custom.bean.RequestUpmicAttachment
import com.yizhuan.xchat_android_core.im.custom.bean.RoomPKAttachment
@@ -83,24 +85,7 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
@SuppressLint("CheckResult")
override fun initiate() {
super.initiate()
mvpPresenter?.getBannerList()
initSpeedyMessage(gameBinding.flSpeedyMessage)
GoldBoxHelper.isHideBox().subscribe(
{
if (it == false) {
gameBinding.ivTreasureBox.visibility = View.VISIBLE
gameBinding.ivTreasureBox.load(
GoldBoxHelper.getBoxIcon(),
defaultRes = R.drawable.icon_room_treasure_box
)
} else {
gameBinding.ivTreasureBox.visibility = View.GONE
}
}
) {
gameBinding.ivTreasureBox.visibility = View.GONE
}
fansTeamViewModel.loadFansTeamInitInfo()
fansTeamViewModel.fansTeamInitInfoLiveData.observe(viewLifecycleOwner) {
@@ -109,7 +94,7 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
}
}
gameBinding.tvHourRank.setOnClickListener {
gameBinding.layoutHourRank.setOnClickListener {
DialogWebViewActivity.start(
mContext,
UriProvider.getSingleRoomHourRankUrl(AvRoomDataManager.get().roomUid)
@@ -120,16 +105,10 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
@SuppressLint("SetTextI18n")
private fun updateFansTeamInfo(initInfo: FansTeamInitInfo) {
var clickListener: View.OnClickListener? = null
if (!AvRoomDataManager.get().isRoomOwner && !initInfo.isAnchorFans && initInfo.hasFansTeamCurrentRoom) {
gameBinding.flFansTeamJoinTip.isVisible = true
gameBinding.tvFansTeamOpt.isVisible = false
} else {
gameBinding.flFansTeamJoinTip.isVisible = false
gameBinding.tvFansTeamOpt.isVisible = true
}
if (initInfo.hasFansTeamCurrentRoom) {
if (AvRoomDataManager.get().isRoomOwner) {
gameBinding.flFansTeamJoinTip.isVisible = false
gameBinding.tvFansTeamOpt.isVisible = true
gameBinding.tvFansTeamOpt.text = "粉絲團(${initInfo.anchorFansNum})"
clickListener = View.OnClickListener {
DialogWebViewActivity.start(
@@ -139,12 +118,16 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
}
} else {
if (initInfo.isAnchorFans) {
gameBinding.flFansTeamJoinTip.isVisible = false
gameBinding.tvFansTeamOpt.isVisible = true
gameBinding.tvFansTeamOpt.text =
"粉絲LV.${if (initInfo.fansLevelSeq == 0) 1 else initInfo.fansLevelSeq}"
clickListener = View.OnClickListener {
FansTeamJoinedActivity.start(requireContext())
}
} else {
gameBinding.flFansTeamJoinTip.isVisible = true
gameBinding.tvFansTeamOpt.isVisible = false
clickListener = View.OnClickListener {
FansTeamJoinActivity.start(requireContext())
}
@@ -152,6 +135,8 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
}
} else {
if (AvRoomDataManager.get().isRoomOwner) {
gameBinding.flFansTeamJoinTip.isVisible = false
gameBinding.tvFansTeamOpt.isVisible = true
gameBinding.tvFansTeamOpt.text = "開通粉絲團"
clickListener = View.OnClickListener {
CommonWebViewActivity.start(
@@ -160,7 +145,9 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
)
}
} else {
gameBinding.tvFansTeamOpt.text = "該主播暫未開通粉絲團"
gameBinding.flFansTeamJoinTip.isVisible = false
gameBinding.tvFansTeamOpt.isVisible = true
gameBinding.tvFansTeamOpt.text = "TA暫未開通粉絲團"
}
}
gameBinding.flFansTeam.setOnClickListener(clickListener)
@@ -230,6 +217,11 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
bottomView.setBottomViewListener(BaseRoomBottomViewWrapper())
}
override fun onEnterRoom() {
super.onEnterRoom()
fansTeamViewModel.loadFansTeamInitInfo()
}
override fun updateView() {
super.updateView()
if (AvRoomDataManager.get().isOpenAnotherPKMode && gameBinding.microView.adapter !is SingleRoomPKMicroViewAdapter) {
@@ -249,13 +241,10 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
}
}
override fun onShowBanner(dialogInfos: List<BannerInfo>) {
initRoomAct(gameBinding.activityImg, dialogInfos, 10f)
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun onFirstRechargeEvent(event: FirstChargeEvent) {
gameBinding.ivFirstChargeEnter.visibility = View.GONE
// banner里可能有首充入口刷新下
gameBinding.bannerWidget.refreshData()
FirstChargePrizeDialog(
requireContext(),
event.chargeProdTitle,
@@ -266,5 +255,14 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
override fun initWidget() {
super.initWidget()
registerWidget(RedPackageWidget::class.java.simpleName, gameBinding.redPackageWidget)
registerWidget(RoomRankWidget::class.java.simpleName, gameBinding.rankWidget)
registerWidget(RoomBannerWidget::class.java.simpleName, gameBinding.bannerWidget)
registerWidget(RoomGameplayListWidget::class.java.simpleName, gameBinding.gameplayListWidget)
registerWidget(RoomGameplayWidget::class.java.simpleName, gameBinding.gameplayWidget)
}
override fun onInitMusicPlayerView(view: MusicPlayerView) {
super.onInitMusicPlayerView(view)
view.linkIconView(gameBinding.ivMusic, gameBinding.ivMusic)
}
}

View File

@@ -34,7 +34,7 @@ class GameDelegate(val activity: Activity, val container: FrameLayout, var mgId:
private val TAG = "GameDelegate"
private var APP_CODE = ""
private val mRoomID = AvRoomDataManager.get().roomUid.toString()
private val mRoomID :String get() = AvRoomDataManager.get().roomUid.toString()
private val mLanguage = "zh-TW" //語言
//調用遊戲SDK的接口,成功加載遊戲後可用:
@@ -84,7 +84,10 @@ class GameDelegate(val activity: Activity, val container: FrameLayout, var mgId:
}
fun updateGame(mgId: Long?) {
if (mgId == null || mgId == 0L || mgId == mMGID || iSudFSTAPP == null) return
if (mgId == null || mgId == 0L) return
if (mgId == mMGID && iSudFSTAPP != null) {
return
}
mMGID = mgId
updateMyMicQueue(GameStatus.STATUS_NOT_JOIN)
loadMG(activity, mUid, mRoomID, APP_CODE, mMGID, mLanguage)

View File

@@ -0,0 +1,25 @@
package com.yizhuan.erban.avroom.gameplay
import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import androidx.recyclerview.widget.RecyclerView
/**
* Created by Max on 2024/2/23 16:09
* Desc:
**/
class GameplayRecyclerView : RecyclerView {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
)
override fun onInterceptTouchEvent(e: MotionEvent?): Boolean {
parent.requestDisallowInterceptTouchEvent(true)
return super.onInterceptTouchEvent(e)
}
}

View File

@@ -0,0 +1,70 @@
package com.yizhuan.erban.avroom.gameplay
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.ViewConfiguration
import androidx.databinding.DataBindingUtil
import com.yizhuan.erban.R
import com.yizhuan.erban.databinding.RoomGameplayListWidgetBinding
import com.yizhuan.xchat_android_core.room.bean.RoomIcon
import com.yizhuan.xchat_android_core.support.room.FrameLayoutRoomWidget
/**
* Created by Max on 2024/2/20 10:42
* Desc:玩法活动
**/
class RoomGameplayListWidget : FrameLayoutRoomWidget {
private val adapter = RoomPlayListAdapter()
private val binding: RoomGameplayListWidgetBinding =
DataBindingUtil.inflate(
LayoutInflater.from(
context
), R.layout.room_gameplay_list_widget, this, true
)
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
)
constructor(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int,
defStyleRes: Int
) : super(context, attrs, defStyleAttr, defStyleRes)
init {
binding.recyclerView.adapter = adapter
binding.ivSwitch.setOnClickListener {
getGameplayIconWidget()?.switchUI(false)
}
adapter.setOnItemClickListener { adapter, view, position ->
(adapter.getItem(position) as? RoomIcon)?.let {
getGameplayIconWidget()?.jump(it)
}
}
}
private fun getGameplayIconWidget(): RoomGameplayWidget? {
return roomView?.findWidget(
RoomGameplayWidget::class.simpleName ?: ""
) as? RoomGameplayWidget
}
fun loadData(list: List<RoomIcon>) {
adapter.setNewData(list)
if (list.size > 6) {
binding.recyclerView.isScrollbarFadingEnabled = false
binding.recyclerView.scrollBarFadeDuration = 0
} else {
binding.recyclerView.isScrollbarFadingEnabled = true
binding.recyclerView.scrollBarFadeDuration =
ViewConfiguration.getScrollBarFadeDuration()
}
}
}

View File

@@ -0,0 +1,131 @@
package com.yizhuan.erban.avroom.gameplay
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import androidx.core.view.isVisible
import androidx.databinding.DataBindingUtil
import com.chuhai.utils.ktx.singleClick
import com.yizhuan.erban.R
import com.yizhuan.erban.avroom.firstcharge.FirstChargeDialog
import com.yizhuan.erban.databinding.RoomGameplayWidgetBinding
import com.yizhuan.erban.shipantics.PullRadishActivity
import com.yizhuan.erban.treasure_box.widget.GoldBoxHelper
import com.yizhuan.erban.treasurefairy.HomeFairyActivity
import com.yizhuan.erban.ui.utils.load
import com.yizhuan.erban.ui.webview.CommonWebViewActivity
import com.yizhuan.erban.ui.webview.room_banner.RoomWebDialogActivity
import com.yizhuan.erban.utils.CommonJumpHelper
import com.yizhuan.xchat_android_core.room.bean.RoomIcon
import com.yizhuan.xchat_android_core.room.model.AvRoomModel
import com.yizhuan.xchat_android_core.support.room.FrameLayoutRoomWidget
import com.yizhuan.xchat_android_core.support.room.RoomContext
import com.yizhuan.xchat_android_core.support.room.RoomView
/**
* Created by Max on 2024/2/20 10:42
* Desc:玩法活动
**/
class RoomGameplayWidget : FrameLayoutRoomWidget {
private val binding: RoomGameplayWidgetBinding =
DataBindingUtil.inflate(
LayoutInflater.from(
context
), R.layout.room_gameplay_widget, this, true
)
private var isOpened = false
private var list: List<RoomIcon>? = null
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
)
constructor(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int,
defStyleRes: Int
) : super(context, attrs, defStyleAttr, defStyleRes)
init {
binding.ivSwitch.setOnClickListener {
switchUI(!isOpened)
}
binding.ivIcon.singleClick {
list?.getOrNull(0)?.let {
jump(it)
}
}
}
override fun onInitialize(roomView: RoomView, roomContext: RoomContext) {
super.onInitialize(roomView, roomContext)
refreshData()
}
private fun refreshData() {
val disposable = AvRoomModel.get().roomGamePlayList
.subscribe { list: List<RoomIcon> ->
loadData(list)
}
getCompositeDisposable().add(disposable)
}
fun switchUI(openListWidget: Boolean) {
this.isOpened = openListWidget
if (openListWidget) {
this.visibility = View.INVISIBLE
getGameplayListWidget()?.visibility = View.VISIBLE
} else {
this.visibility = View.VISIBLE
getGameplayListWidget()?.visibility = View.GONE
}
}
private fun loadData(list: List<RoomIcon>) {
this.list = list
this.isVisible = list.isNotEmpty()
val listWidget = getGameplayListWidget()
if (list.isEmpty()) {
listWidget?.isVisible = false
}
listWidget?.loadData(list)
binding.ivIcon.load(list.firstOrNull()?.icon)
}
fun jump(data: RoomIcon) {
if (data.isSeizeTreasure()) {
HomeFairyActivity.start(context)
} else if (data.isFirstCharge()) {
FirstChargeDialog.start(context)
} else if (data.isFindLove()) {
GoldBoxHelper.handleBoxClick(context)
} else if (data.isNauticalAdventure()) {
PullRadishActivity.start(context)
} else {
val url = data.skipContent
if (data.skipType == 3 && !url.isNullOrEmpty()) {
if (data.showType == 2) {
RoomWebDialogActivity.start(context, url, false)
} else {
CommonWebViewActivity.start(context, url)
}
} else {
CommonJumpHelper.bannerJump(context, data)
}
}
}
private fun getGameplayListWidget(): RoomGameplayListWidget? {
return roomView?.findWidget(
RoomGameplayListWidget::class.simpleName ?: ""
) as? RoomGameplayListWidget
}
}

View File

@@ -0,0 +1,19 @@
package com.yizhuan.erban.avroom.gameplay
import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.yizhuan.erban.R
import com.yizhuan.erban.ui.utils.load
import com.yizhuan.xchat_android_core.room.bean.RoomIcon
/**
* Created by Max on 2024/2/20 11:38
* Desc:
**/
class RoomPlayListAdapter :
BaseQuickAdapter<RoomIcon, BaseViewHolder>(R.layout.room_gameplay_item) {
override fun convert(helper: BaseViewHolder, item: RoomIcon?) {
helper.getView<ImageView>(R.id.iv_icon).load(item?.icon)
}
}

View File

@@ -21,6 +21,7 @@ import com.netease.nimlib.sdk.util.Entry;
import com.yizhuan.erban.R;
import com.yizhuan.erban.avroom.activity.AVRoomActivity;
import com.yizhuan.erban.avroom.core.AudioRoomContext;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomPkBean;
import com.yizhuan.xchat_android_core.support.room.RoomContext;
import com.yizhuan.erban.avroom.view.IAvRoomView;
import com.yizhuan.erban.base.BaseMvpPresenter;
@@ -120,7 +121,6 @@ public class AvRoomPresenter extends BaseMvpPresenter<IAvRoomView> {
exitRoom();
}
AvRoomDataManager.get().updateServiceRoomInfo(roomInfo);
initAnotherPKData();
mAvRoomModel.enterRoom(roomInfo.getRoomId(), 3, fromType, fromNick, fromUid)
.flatMap(this::dealServerMicInfo)
.map(this::dealMicMemberFromIMNet)
@@ -143,6 +143,7 @@ public class AvRoomPresenter extends BaseMvpPresenter<IAvRoomView> {
.subscribe((stringServiceResult) -> EventBus.getDefault().post(new AudioPartyOpenEvent()));
mAvRoomModel.loadMessageHistory(AvRoomDataManager.get().clearScreenTime);
IMNetEaseManager.get().joinAvRoom();
initAnotherPKData();
}, this::dealEnterRoomError);
}
@@ -151,7 +152,15 @@ public class AvRoomPresenter extends BaseMvpPresenter<IAvRoomView> {
if (AvRoomDataManager.get().isOpenAnotherPKMode()) {
RoomPKModel.INSTANCE.getRoomPKData(AvRoomDataManager.get().getRoomUid())
.compose(bindToLifecycle())
.subscribe(roomPkBean -> AvRoomDataManager.get().roomPkLiveData.setValue(roomPkBean));
.subscribe(roomPkBean -> {
AvRoomDataManager.get().roomPkLiveData.setValue(roomPkBean);
if (AvRoomDataManager.get().isSingleRoom()){
AudioEngineManager.get().setRemoteMute(roomPkBean.getAUid(), roomPkBean.getAMicStatus() == 0);
if (AvRoomDataManager.get().isRoomOwner()) {
AudioEngineManager.get().connectOtherRoom(String.valueOf(roomPkBean.getARoomId()), roomPkBean.getAUid());
}
}
});
}
}

View File

@@ -525,20 +525,6 @@ public class BaseRoomPresenter<V extends IBaseRoomView> extends BaseMvpPresenter
});
}
@SuppressLint("CheckResult")
public void loadRoomRank() {
String type = AvRoomDataManager.get().isSingleRoom() ? RoomContributeDataInfo.TYPE_ROOM_WEEK_RANKING : RoomContributeDataInfo.TYPE_ROOM_DAY_RANKING;
RoomContributeListModel.get().getSingleRoomRanking(1, type)
.compose(bindToLifecycle())
.compose(RxHelper.handleBeanData())
.subscribe(roomContributeDataInfo -> {
if (getMvpView() == null) {
return;
}
getMvpView().updateRoomRanks(roomContributeDataInfo.getRankings());
});
}
/***
* 發送房間消息
* @param message

View File

@@ -1,15 +1,7 @@
package com.yizhuan.erban.avroom.presenter;
import android.annotation.SuppressLint;
import com.yizhuan.erban.avroom.view.IGameRoomView;
import com.yizhuan.erban.treasure_box.widget.GoldBoxHelper;
import com.yizhuan.erban.utils.UserUtils;
import com.yizhuan.xchat_android_core.home.bean.BannerInfo;
import com.yizhuan.xchat_android_core.room.model.AvRoomModel;
import java.util.ArrayList;
import java.util.List;
/**
@@ -20,37 +12,4 @@ import java.util.List;
*/
public class GameRoomPresenter extends BaseRoomPresenter<IGameRoomView> {
@SuppressLint("CheckResult")
public void getBannerList() {
AvRoomModel.get().getRoomBanner()
.compose(bindToLifecycle())
.subscribe(bannerInfos -> {
if (bannerInfos == null) bannerInfos = new ArrayList<>();
final boolean firstCharge = UserUtils.getUserInfo().isFirstCharge();
if (firstCharge) {
BannerInfo bannerInfo = new BannerInfo();
bannerInfo.setFirstCharge(true);
bannerInfos.add(0, bannerInfo);
}
if(GoldBoxHelper.isShowFairy()){
BannerInfo bannerInfo = new BannerInfo();
bannerInfo.setFairy(true);
bannerInfos.add(firstCharge ? 1 : 0, bannerInfo);
}
List<BannerInfo> finalBannerInfos = bannerInfos;
GoldBoxHelper.isHideBox()
.subscribe(isHide -> {
if (!isHide) {
BannerInfo bannerInfo = new BannerInfo();
bannerInfo.setBox(true);
int index = 0;
if (firstCharge) index++;
if (GoldBoxHelper.isShowFairy()) index++;
finalBannerInfos.add(index, bannerInfo);
}
getMvpView().onShowBanner(finalBannerInfos);
}, throwable -> getMvpView().onShowBanner(finalBannerInfos));
});
}
}

View File

@@ -12,12 +12,10 @@ import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
import com.yizhuan.erban.R;
import com.yizhuan.erban.avroom.view.IHomePartyView;
import com.yizhuan.erban.treasure_box.widget.GoldBoxHelper;
import com.yizhuan.erban.utils.UserUtils;
import com.yizhuan.xchat_android_core.Constants;
import com.yizhuan.xchat_android_core.auth.AuthModel;
import com.yizhuan.xchat_android_core.bean.RoomQueueInfo;
import com.yizhuan.xchat_android_core.home.bean.BannerInfo;
import com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.FaceAttachment;
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
@@ -297,49 +295,4 @@ public class HomePartyPresenter extends BaseRoomPresenter<IHomePartyView> {
.subscribe(s -> SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_presenter_homepartypresenter_01))
, e -> SingleToastUtil.showToast(e.getMessage()));
}
@SuppressLint("CheckResult")
public void getBannerList() {
mAvRoomModel.getRoomBanner()
.compose(bindToLifecycle())
.subscribe(bannerInfos -> {
final boolean firstCharge = UserUtils.getUserInfo().isFirstCharge();
if (GoldBoxHelper.needIntegrateBoxEntrance()) {
if (firstCharge) {
BannerInfo bannerInfo = new BannerInfo();
bannerInfo.setFirstCharge(true);
bannerInfos.add(0, bannerInfo);
}
if (GoldBoxHelper.isShowRadish()) {
BannerInfo bannerInfo = new BannerInfo();
bannerInfo.setRadish(true);
bannerInfos.add(firstCharge ? 1 : 0, bannerInfo);
}
GoldBoxHelper.isHideBox()
.subscribe(isHide -> {
if (!isHide) {
BannerInfo bannerInfo = new BannerInfo();
bannerInfo.setBox(true);
int index = 0;
if (firstCharge) index++;
if (GoldBoxHelper.isShowRadish()) index++;
bannerInfos.add(index, bannerInfo);
}
getMvpView().onShowBanner(bannerInfos);
}, throwable -> getMvpView().onShowBanner(bannerInfos));
} else {
if(GoldBoxHelper.isShowFairy()){
BannerInfo bannerInfo = new BannerInfo();
bannerInfo.setFairy(true);
bannerInfos.add(0, bannerInfo);
}
if (firstCharge) {
BannerInfo bannerInfo = new BannerInfo();
bannerInfo.setFirstCharge(true);
bannerInfos.add(0, bannerInfo);
}
getMvpView().onShowBanner(bannerInfos);
}
});
}
}

View File

@@ -2,15 +2,9 @@ package com.yizhuan.erban.avroom.presenter;
import android.annotation.SuppressLint;
import com.orhanobut.logger.Logger;
import com.yizhuan.erban.R;
import com.yizhuan.erban.avroom.view.IHomePartyUserListView;
import com.yizhuan.erban.base.BaseMvpPresenter;
import com.yizhuan.xchat_android_core.room.bean.OnlineChatMember;
import com.yizhuan.xchat_android_core.room.model.HomePartyUserListModel;
import com.yizhuan.xchat_android_library.utils.ResUtil;
import java.util.List;
/**
* <p> </p>
@@ -26,49 +20,17 @@ public class HomePartyUserListPresenter extends BaseMvpPresenter<IHomePartyUserL
mHomePartyUserListMode = new HomePartyUserListModel();
}
/**
* 分页获取房间成员第一页包含队列成员固定成员游客50人之后每一页获取游客50人
*
* @param page 页数
* @param time 固定成员列表用updateTime,
* 游客列表用进入enterTime
* 填0会使用当前服务器最新时间开始查询即第一页单位毫秒
*/
@SuppressLint("CheckResult")
public void requestChatMemberByPage(final int page, long time, List<OnlineChatMember> oldList) {
mHomePartyUserListMode.getOnLinePageMembers(page, time, oldList)
.subscribe(onlineChatMembers -> {
Logger.i(ResUtil.getString(R.string.avroom_presenter_homepartyuserlistpresenter_01), page, onlineChatMembers.size());
if (getMvpView() != null) {
getMvpView().onRequestChatMemberByPageSuccess(onlineChatMembers, page);
}
}, throwable -> {
throwable.printStackTrace();
Logger.i(ResUtil.getString(R.string.avroom_presenter_homepartyuserlistpresenter_02), page, throwable.getMessage());
if (getMvpView() != null) {
getMvpView().onRequestChatMemberByPageFail(throwable.getMessage(), page);
}
});
public void requestRoomOnlineList(long roomUid){
mHomePartyUserListMode.getRoomOnlineList(roomUid).compose(bindToLifecycle()).subscribe((data, throwable) -> {
if (getMvpView() != null) {
if (data != null) {
getMvpView().onRequestRoomOnlineListSuccess(data);
} else {
getMvpView().onRequestChatMemberByPageFail(throwable.getMessage(), 1);
}
}
});
}
public void onMemberDownUpMic(String account, boolean isUpMic, List<OnlineChatMember> dataList,
final int page) {
mHomePartyUserListMode.onMemberDownUpMic(account, isUpMic, dataList)
.subscribe(onlineChatMembers -> {
if (getMvpView() != null)
getMvpView().onRequestChatMemberByPageSuccess(onlineChatMembers, page);
});
}
public void onUpdateMemberManager(String account, List<OnlineChatMember> dataList,
boolean isRemoveManager, final int page) {
mHomePartyUserListMode.onUpdateMemberManager(account, isRemoveManager, dataList)
.subscribe(onlineChatMembers -> {
if (getMvpView() != null)
getMvpView().onRequestChatMemberByPageSuccess(onlineChatMembers, page);
});
}
}

View File

@@ -70,10 +70,20 @@ public class RoomManagerPresenter extends BaseMvpPresenter<IRoomManagerView> {
Iterator<ChatRoomMember> iterator = paramList.iterator();
while (iterator.hasNext()) {
ChatRoomMember member = iterator.next();
if (member != null
&& !TextUtils.isEmpty(member.getAccount())
&& map.containsKey(member.getAccount())) {
iterator.remove();
if (member != null && !TextUtils.isEmpty(member.getAccount())) {
if (map.containsKey(member.getAccount())) {
iterator.remove();
} else {
if (member.getNick() == null || member.getAvatar() == null) {
for (UserInfo info : userInfos) {
if (String.valueOf(info.getUid()).equals(member.getAccount())) {
member.setNick(info.getNick());
member.setAvatar(info.getAvatar());
break;
}
}
}
}
}
}
return paramList;

View File

@@ -1,11 +1,7 @@
package com.yizhuan.erban.avroom.presenter;
import android.annotation.SuppressLint;
import com.yizhuan.erban.avroom.view.ISingleRoomView;
import com.yizhuan.erban.treasure_box.widget.GoldBoxHelper;
import com.yizhuan.erban.utils.UserUtils;
import com.yizhuan.xchat_android_core.home.bean.BannerInfo;
/**
* <p> </p>
@@ -14,50 +10,4 @@ import com.yizhuan.xchat_android_core.home.bean.BannerInfo;
* @date 2017/12/8
*/
public class SingleRoomPresenter extends BaseRoomPresenter<ISingleRoomView> {
@SuppressLint("CheckResult")
public void getBannerList() {
mAvRoomModel.getRoomBanner()
.compose(bindToLifecycle())
.subscribe(bannerInfos -> {
final boolean firstCharge = UserUtils.getUserInfo().isFirstCharge();
if (GoldBoxHelper.needIntegrateBoxEntrance()) {
if (firstCharge) {
BannerInfo bannerInfo = new BannerInfo();
bannerInfo.setFirstCharge(true);
bannerInfos.add(0, bannerInfo);
}
if (GoldBoxHelper.isShowRadish()) {
BannerInfo bannerInfo = new BannerInfo();
bannerInfo.setRadish(true);
bannerInfos.add(firstCharge ? 1 : 0, bannerInfo);
}
GoldBoxHelper.isHideBox()
.subscribe(isHide -> {
if (!isHide) {
BannerInfo bannerInfo = new BannerInfo();
bannerInfo.setBox(true);
int index = 0;
if (firstCharge) index++;
if (GoldBoxHelper.isShowRadish()) index++;
bannerInfos.add(index, bannerInfo);
}
getMvpView().onShowBanner(bannerInfos);
}, throwable -> getMvpView().onShowBanner(bannerInfos));
} else {
if(GoldBoxHelper.isShowFairy()){
BannerInfo bannerInfo = new BannerInfo();
bannerInfo.setFairy(true);
bannerInfos.add(0, bannerInfo);
}
if (firstCharge) {
BannerInfo bannerInfo = new BannerInfo();
bannerInfo.setFirstCharge(true);
bannerInfos.add(0, bannerInfo);
}
getMvpView().onShowBanner(bannerInfos);
}
});
}
}

View File

@@ -0,0 +1,94 @@
package com.yizhuan.erban.avroom.rank
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.core.view.isVisible
import androidx.databinding.DataBindingUtil
import com.chuhai.utils.ktx.singleClick
import com.yizhuan.erban.R
import com.yizhuan.erban.databinding.RoomRankWidgetBinding
import com.yizhuan.erban.ui.utils.loadAvatar
import com.yizhuan.erban.ui.webview.DialogWebViewActivity
import com.yizhuan.xchat_android_core.support.room.FrameLayoutRoomWidget
import com.yizhuan.xchat_android_core.support.room.RoomContext
import com.yizhuan.xchat_android_core.support.room.RoomView
import com.yizhuan.xchat_android_core.support.room.RoomWidget
import com.yizhuan.xchat_android_core.UriProvider
import com.yizhuan.xchat_android_core.room.bean.RoomContributeDataInfo
import com.yizhuan.xchat_android_core.room.bean.RoomContributeUserInfo
import com.yizhuan.xchat_android_core.room.model.RoomContributeListModel
import com.yizhuan.xchat_android_core.utils.net.RxHelper
/**
* 房间榜单入口
*/
class RoomRankWidget : FrameLayoutRoomWidget, RoomWidget {
private val binding: RoomRankWidgetBinding =
DataBindingUtil.inflate(
LayoutInflater.from(
context
), R.layout.room_rank_widget, this, true
)
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
)
constructor(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int,
defStyleRes: Int
) : super(context, attrs, defStyleAttr, defStyleRes)
init {
this.singleClick {
DialogWebViewActivity.start(context, UriProvider.getRoomRanking())
refreshData()
}
}
override fun onInitialize(roomView: RoomView, roomContext: RoomContext) {
super.onInitialize(roomView, roomContext)
refreshData()
}
override fun onUnbindContext() {
super.onUnbindContext()
updateView(null)
}
private fun refreshData() {
val disposable = RoomContributeListModel.get()
.getSingleRoomRanking(1, RoomContributeDataInfo.TYPE_ROOM_DAY_RANKING)
.compose(RxHelper.handleBeanData())
.subscribe { roomContributeDataInfo: RoomContributeDataInfo ->
updateView(roomContributeDataInfo.rankings)
}
getCompositeDisposable().add(disposable)
}
private fun updateView(list: List<RoomContributeUserInfo>?) {
arrayListOf(
binding.ivRank0, binding.ivRank1, binding.ivRank2
).forEachIndexed { index, imageView ->
val url = list?.getOrNull(index)?.avatar
if (url.isNullOrEmpty()) {
imageView.isVisible = false
} else {
imageView.loadAvatar(url)
imageView.isVisible = true
}
}
}
fun setContentBackgroundResource(resId: Int) {
binding.layoutRoot.setBackgroundResource(resId)
}
}

View File

@@ -56,8 +56,6 @@ class RedPackageWidget : FrameLayoutRoomWidget, RoomWidget {
), R.layout.red_package_widget, this, true
)
private var compositeDisposable: CompositeDisposable? = null
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
@@ -218,26 +216,14 @@ class RedPackageWidget : FrameLayoutRoomWidget, RoomWidget {
getCompositeDisposable().add(disposable)
}
private fun getCompositeDisposable(): CompositeDisposable {
var disposable = compositeDisposable
if (disposable == null) {
disposable = CompositeDisposable()
compositeDisposable = disposable
}
return disposable
}
override fun onStop() {
super.onStop()
this.dialogManager?.dismissDialog()
this.dialogManager = null
this.roomView = null
}
override fun onUnbindContext() {
super.onUnbindContext()
compositeDisposable?.dispose()
compositeDisposable = null
loadData(null)
}

View File

@@ -251,7 +251,7 @@ class UploadRoomAlbumDialogFragment : BottomSheetDialogFragment() {
}
if (requestCode == 200) {
PhotoProvider.getResultPathListAsync(data) {
it?.let { paths ->
it?.mapNotNull { it.path }?.let { paths ->
compressPhotos(paths.toMutableList())
}
}

View File

@@ -17,8 +17,10 @@ import com.yizhuan.erban.ui.user.activity.UserInfoActivity
import com.yizhuan.erban.ui.utils.load
import com.yizhuan.xchat_android_core.im.custom.bean.RoomPkBean
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
import com.yizhuan.xchat_android_core.room.anotherroompk.SingleRoomPKModel
import com.yizhuan.xchat_android_core.utils.CurrentTimeUtils
import com.yizhuan.xchat_android_core.utils.subAndReplaceDot
import com.yizhuan.xchat_android_core.utils.toast
import com.yizhuan.xchat_android_library.utils.ResUtil
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
@@ -30,7 +32,7 @@ class SingleRoomPKBoardView @JvmOverloads constructor(
) : FrameLayout(context, attrs, defStyleAttr) {
private val binding = LayoutSingleRoomPkBoardViewBinding.inflate(LayoutInflater.from(context))
private val observer = Observer<RoomPkBean> { updateView(it) }
private val observer = Observer<RoomPkBean?> { updateView(it) }
private var disposable: Disposable? = null
private var roomPkBean: RoomPkBean? = null
@@ -55,6 +57,20 @@ class SingleRoomPKBoardView @JvmOverloads constructor(
SingleRoomPkRuleDialog.newInstance().show(context)
}
binding.ivMuteAnother.setOnClickListener {
if (AvRoomDataManager.get().isRoomOwner) {
roomPkBean?.let {
if (it.roundId == null) {
return@let
}
SingleRoomPKModel
.muteSingleRoomPkOtherMic(it.roundId, it.aMicStatus xor 1)
.subscribe()
}
} else {
"主播已關閉對方房間的聲音".toast()
}
}
}
override fun onDetachedFromWindow() {
@@ -118,7 +134,13 @@ class SingleRoomPKBoardView @JvmOverloads constructor(
binding.ivPkResult.isVisible = true
binding.ivPkResult.setImageResource(R.drawable.single_room_pk_ic_result_win)
}
if (roomPkBean?.aMicStatus == 0) {
binding.ivMuteAnother.isVisible = true
binding.ivMuteAnother.setImageResource(R.drawable.single_room_pk_ic_another_mic_close)
} else {
binding.ivMuteAnother.setImageResource(R.drawable.single_room_pk_ic_another_mic_open)
binding.ivMuteAnother.isVisible = AvRoomDataManager.get().isRoomOwner
}
}
}

View File

@@ -20,6 +20,7 @@ import com.yizhuan.xchat_android_core.utils.ifNotNullOrEmpty
import com.yizhuan.xchat_android_core.utils.subAndReplaceDot
import com.yizhuan.xchat_android_core.utils.toIntOrDef
import com.yizhuan.xchat_android_core.utils.toast
import com.yizhuan.xchat_android_library.common.application.Env
import com.yizhuan.xchat_android_library.utils.ResUtil
class SingleRoomPKCreateActivity : BaseViewBindingActivity<ActivitySingleRoomPkCreateBinding>() {
@@ -94,7 +95,8 @@ class SingleRoomPKCreateActivity : BaseViewBindingActivity<ActivitySingleRoomPkC
binding.tvOk.setOnClickListener {
if (pkTime < 5 || pkTime > 30) {
ResUtil.getString(R.string.avroom_singleroompk_singleroompkcreateactivity_01).toast()
ResUtil.getString(R.string.avroom_singleroompk_singleroompkcreateactivity_01)
.toast()
return@setOnClickListener
}
currSimpleRoomInfo?.let {

View File

@@ -71,6 +71,4 @@ interface IBaseRoomView : IMvpBaseView {
fun updateMicView()
fun updateRoomRanks(data: List<RoomContributeUserInfo>)
}

View File

@@ -1,8 +1,5 @@
package com.yizhuan.erban.avroom.view;
import com.yizhuan.xchat_android_core.home.bean.BannerInfo;
import java.util.List;
/**
* <p> 轰趴房View层 </p>
@@ -12,6 +9,4 @@ import java.util.List;
*/
public interface IGameRoomView extends IBaseRoomView {
void onShowBanner(List<BannerInfo> dialogInfos);
}

View File

@@ -3,6 +3,7 @@ package com.yizhuan.erban.avroom.view;
import com.yizhuan.xchat_android_core.room.bean.OnlineChatMember;
import com.yizhuan.xchat_android_core.room.bean.RoomOnlineUserBean;
import com.yizhuan.xchat_android_library.base.IMvpBaseView;
import java.util.List;
@@ -14,7 +15,8 @@ import java.util.List;
* @date 2017/12/8
*/
public interface IHomePartyUserListView extends IMvpBaseView {
void onRequestChatMemberByPageSuccess(List<OnlineChatMember> memberList, int page);
void onRequestRoomOnlineListSuccess(List<RoomOnlineUserBean> list);
void onRequestChatMemberByPageFail(String errorStr, int page);

View File

@@ -1,9 +1,7 @@
package com.yizhuan.erban.avroom.view;
import com.yizhuan.xchat_android_core.home.bean.BannerInfo;
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
import java.util.List;
/**
* <p> 轰趴房View层 </p>
@@ -20,6 +18,4 @@ public interface IHomePartyView extends IBaseRoomView {
* 礼物值模式下换麦
*/
void onGiftValueChangeMic(int micPosition, String uId, boolean isInviteUpMic, RoomInfo roomInfo);
void onShowBanner(List<BannerInfo> bannerInfos);
}

View File

@@ -1,8 +1,5 @@
package com.yizhuan.erban.avroom.view;
import com.yizhuan.xchat_android_core.home.bean.BannerInfo;
import java.util.List;
/**
* <p> 轰趴房View层 </p>
@@ -12,6 +9,4 @@ import java.util.List;
*/
public interface ISingleRoomView extends IBaseRoomView {
void onShowBanner(List<BannerInfo> dialogInfos);
}

View File

@@ -2,8 +2,10 @@ package com.yizhuan.erban.avroom.widget;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAIRY;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GIFT_COMPOUND;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GUARDIAN_PLANET;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_RED_PACKAGE;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ROOM_ALBUM;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ROOM_TEMPLATE;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ME;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_CONVERT_L1;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_CONVERT_L2;
@@ -18,6 +20,7 @@ import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUS
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_GIFT_L5;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_FANS_TEAM_JOIN;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_GIFT_COMPOUND;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUPER_LUCKY_GIFT_TEMPLATE;
import static com.yizhuan.xchat_android_core.redpackage.RedPackageTypeKt.ALL_DIAMOND;
import static com.yizhuan.xchat_android_core.redpackage.RedPackageTypeKt.ALL_GIFT;
import static com.yizhuan.xchat_android_core.redpackage.RedPackageTypeKt.ROOM_DIAMOND;
@@ -119,6 +122,7 @@ import com.yizhuan.xchat_android_core.im.custom.bean.GiftAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.GiftBatchAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.GiftCompoundAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.GiftCompoundMsgBean;
import com.yizhuan.xchat_android_core.im.custom.bean.GuardianPlanetAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.JoinMiniWorldAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.JoinMiniWorldNoticeAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.MagicAllMicAttachment;
@@ -143,6 +147,7 @@ import com.yizhuan.xchat_android_core.im.custom.bean.RoomReceivedLuckyGiftAttach
import com.yizhuan.xchat_android_core.im.custom.bean.RoomTipAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.TarotAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.TarotMsgBean;
import com.yizhuan.xchat_android_core.im.custom.bean.TemplateMessageAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.User;
import com.yizhuan.xchat_android_core.im.custom.bean.VipMessageAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.WelcomeAttachment;
@@ -253,6 +258,7 @@ public class MessageView extends FrameLayout {
private OnClick onClick;
private OnMsgLongClickListener onLongClickListener;
private TemplateMessageAdapter templateMessageAdapter;
public MessageView(Context context) {
this(context, null);
@@ -433,7 +439,17 @@ public class MessageView extends FrameLayout {
}
}
});
}
private TemplateMessageAdapter getTemplateMessageAdapter() {
if (templateMessageAdapter == null) {
templateMessageAdapter = new TemplateMessageAdapter(uid -> {
if (clickConsumer != null) {
Single.just(String.valueOf(uid)).subscribe(clickConsumer);
}
});
}
return templateMessageAdapter;
}
public void onCurrentRoomReceiveNewMsg(List<ChatRoomMessage> messages) {
@@ -617,6 +633,19 @@ public class MessageView extends FrameLayout {
builder.setSpan(imageSpan, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
return this;
}
/**
* @param drawable -icon url
* @return -返回一個spannableStringBuilder
*/
public SpannableBuilder appendImg(String drawable, Object what) {
if (TextUtils.isEmpty(drawable)) return this;
int start = builder.length();
builder.append("-");
CustomImageSpan imageSpan = new CustomImageSpan(new ColorDrawable(Color.TRANSPARENT), textView, drawable);
builder.setSpan(imageSpan, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
builder.setSpan(what, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
return this;
}
/**
* @param drawable -icon url
@@ -633,6 +662,16 @@ public class MessageView extends FrameLayout {
return this;
}
public SpannableBuilder append(String drawable, int width, int height, Object what) {
if (TextUtils.isEmpty(drawable)) return this;
int start = builder.length();
builder.append("-");
CustomImageSpan imageSpan = new CustomImageSpan(new ColorDrawable(Color.TRANSPARENT), textView, drawable, width, height);
builder.setSpan(imageSpan, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
builder.setSpan(what, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
return this;
}
/**
* 文本和背景分離的情況
*/
@@ -674,6 +713,16 @@ public class MessageView extends FrameLayout {
return this;
}
public SpannableBuilder append(String imgUrl, int height, Object what) {
if (TextUtils.isEmpty(imgUrl)) return this;
int start = builder.length();
builder.append("-");
builder.setSpan(new CustomAutoWidthImageSpan(new ColorDrawable(Color.TRANSPARENT), textView, imgUrl, height)
, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
builder.setSpan(what, start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
return this;
}
/**
* @param drawable -icon
* @param width 寬
@@ -1032,6 +1081,22 @@ public class MessageView extends FrameLayout {
setFairyMsg(chatRoomMessage, tvContent);
} else if (first == CUSTOM_MSG_ROOM_ALBUM) {
setRoomAlbumMsg(chatRoomMessage, baseViewHolder);
} else if (first == CUSTOM_MSG_GUARDIAN_PLANET) {
setGuardianPlanetMsg(chatRoomMessage, tvContent);
} else if (first == CUSTOM_MSG_ROOM_TEMPLATE) {
TemplateMessageAttachment templateMessageAttachment = (TemplateMessageAttachment) chatRoomMessage.getAttachment();
if (templateMessageAttachment != null) {
getTemplateMessageAdapter().convert(tvContent, templateMessageAttachment.getTemplateMessage());
} else {
getTemplateMessageAdapter().convert(tvContent, null);
}
} else if (first == CUSTOM_MSG_SUPER_LUCKY_GIFT_TEMPLATE) {
TemplateMessageAttachment templateMessageAttachment = (TemplateMessageAttachment) chatRoomMessage.getAttachment();
if (templateMessageAttachment != null) {
getTemplateMessageAdapter().convert(tvContent, templateMessageAttachment.getTemplateMessage());
} else {
getTemplateMessageAdapter().convert(tvContent, null);
}
} else {
tvContent.setTextColor(Color.WHITE);
tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip));
@@ -1948,6 +2013,37 @@ public class MessageView extends FrameLayout {
tvContent.setText(text.build());
}
private void setGuardianPlanetMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) {
GuardianPlanetAttachment attachment = (GuardianPlanetAttachment) chatRoomMessage.getAttachment();
// 內容
SpannableBuilder text = new SpannableBuilder(tvContent)
.append(ResUtil.getString(R.string.congratulation), new ForegroundColorSpan(greyColor))
.append(attachment.getNick(), new ForegroundColorSpan(roomTipNickColor),
new OriginalDrawStatusClickSpan() {
@Override
public void onClick(@NonNull View widget) {
if (clickConsumer != null) {
Single.just(String.valueOf(attachment.getUid())).subscribe(clickConsumer);
}
}
})
.append(
ResUtil.getString(R.string.guardian_planet_msg_1),
new ForegroundColorSpan(greyColor)
)
.append(
String.valueOf(attachment.getDiamonds()),
new ForegroundColorSpan(whiteColor)
)
.append(
ResUtil.getString(R.string.guardian_planet_msg_2),
new ForegroundColorSpan(greyColor)
);
tvContent.setText(text.build());
tvContent.setOnClickListener(null);
tvContent.setMovementMethod(new LinkMovementMethod());
}
private void setLuckySeaMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) {
RoomLuckySeaAttachment attachment = (RoomLuckySeaAttachment) chatRoomMessage.getAttachment();
RoomLuckySeaMsgBean bean = attachment.getRoomLuckySeaMsgInfo();
@@ -2248,8 +2344,12 @@ public class MessageView extends FrameLayout {
//等級
builder.append(userLevel, expLevelHeight);
//銘牌
boolean isCustom = NobleUtil.getExtBoolean( chatRoomMessage,UserInfo.NAMEPLATE_IS_CUSTOM,false);
String tvNamePlate = NobleUtil.getNamePlate(UserInfo.NAMEPLATE_WORD, chatRoomMessage).trim();
String ivNamePlate = NobleUtil.getNamePlate(UserInfo.NAMEPLATE_PIC, chatRoomMessage);
if (isCustom) {
tvNamePlate = null;
}
if (!TextUtils.isEmpty(tvNamePlate) && !TextUtils.isEmpty(ivNamePlate)) { // extension != null 表示自己
builder.appendBgAndContent(ivNamePlate, tvNamePlate);
} else if (!TextUtils.isEmpty(ivNamePlate)) {

View File

@@ -151,8 +151,8 @@ class RoomEffectBoxView @JvmOverloads constructor(
.subscribe { roomEvent: RoomEvent? ->
if (roomEvent == null || AvRoomDataManager.get().isSelfGamePlaying) return@subscribe
when (roomEvent.event) {
RoomEvent.BOX_NOTIFY -> addBoxNotify(roomEvent.chatRoomMessage)
RoomEvent.BOX_NOTIFY_SVGA -> addBoxNotify(roomEvent.chatRoomMessage)
// RoomEvent.BOX_NOTIFY -> addBoxNotify(roomEvent.chatRoomMessage)
// RoomEvent.BOX_NOTIFY_SVGA -> addBoxNotify(roomEvent.chatRoomMessage)
RoomEvent.DATING_ALL_NOTIFY -> addDatingAllNotify(roomEvent.chatRoomMessage)
RoomEvent.RADISH_NOTIFY,
RoomEvent.RADISH_NOTIFY_SVGA -> addRadishNotify(roomEvent.chatRoomMessage)

View File

@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.Drawable
import android.text.Layout
import android.text.StaticLayout
import android.text.TextPaint
@@ -19,34 +20,49 @@ import android.view.animation.AnimationUtils
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.NonNull
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
import androidx.core.text.HtmlCompat
import androidx.core.util.Consumer
import androidx.lifecycle.MutableLiveData
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.transition.Transition
import com.chuhai.utils.UiUtils
import com.chuhai.utils.ktx.setPadding2
import com.coorchice.library.SuperTextView
import com.netease.nim.uikit.common.util.sys.ScreenUtil
import com.netease.nim.uikit.support.glide.GlideApp
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage
import com.netease.nimlib.sdk.chatroom.model.ChatRoomNotificationAttachment
import com.opensource.svgaplayer.*
import com.opensource.svgaplayer.SVGAParser.Companion.shareParser
import com.yizhuan.erban.R
import com.yizhuan.erban.application.XChatApplication
import com.yizhuan.erban.avroom.activity.AVRoomActivity
import com.yizhuan.erban.avroom.bean.RoomPlayBean
import com.yizhuan.erban.avroom.helper.AnimHelper
import com.yizhuan.erban.base.TitleBar
import com.yizhuan.erban.common.svga.SimpleSvgaCallback
import com.yizhuan.erban.databinding.LayoutRoomEffectBinding
import com.yizhuan.erban.treasure_box.activity.TreasureBoxActivity
import com.yizhuan.erban.ui.utils.ImageLoadUtils
import com.yizhuan.erban.ui.utils.isDestroyed
import com.yizhuan.erban.ui.utils.load
import com.yizhuan.erban.ui.utils.loadAnim
import com.yizhuan.erban.ui.webview.CommonWebViewActivity
import com.yizhuan.erban.ui.widget.SimpleAnimListener
import com.yizhuan.erban.ui.widget.dialog.AllServiceGiftGoRoomTipsDialog
import com.yizhuan.erban.ui.widget.dialog.AllServiceGiftGoRoomTipsDialog.Companion.isNeedTips
import com.yizhuan.erban.ui.widget.drawgift.DrawGiftPlayHelper
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil
import com.yizhuan.erban.utils.CommonJumpHelper
import com.yizhuan.erban.utils.MsgBuilder
import com.yizhuan.erban.utils.RegexUtil
import com.yizhuan.erban.utils.SpannableBuilder
import com.yizhuan.xchat_android_constants.XChatConstants
import com.yizhuan.xchat_android_core.auth.AuthModel
import com.yizhuan.xchat_android_core.decoration.car.bean.CarInfo
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
import com.yizhuan.xchat_android_core.im.custom.bean.*
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager
@@ -134,14 +150,37 @@ class RoomEffectView @JvmOverloads constructor(
private val drawGiftPlayHelper: DrawGiftPlayHelper by lazy { DrawGiftPlayHelper(context as Activity) }
private var isPlayAnim = false
private var playNotifyStateLiveData: MutableLiveData<Boolean>? = null
private var showUserCardAction: ((String) -> Unit)? = null
private val templateMessageAdapter =
TemplateMessageAdapter(listener = object : TemplateMessageAdapter.Listener {
override fun onShowUserCard(uid: String) {
showUserCardAction?.invoke(uid)
}
})
private var onPlayAnimCallback: (() -> Boolean)? = null
fun setPlayNotifyStateListener(stateLiveData: MutableLiveData<Boolean>) {
this.playNotifyStateLiveData = stateLiveData
}
fun setOnPlayAnimCallback(onPlayAnimCallback: (() -> Boolean)) {
this.onPlayAnimCallback = onPlayAnimCallback
}
fun setShowUserCardAction(call: Consumer<String>) {
this.showUserCardAction = {
call.accept(it)
}
}
@NonNull
private fun isShowingGiftNotify(): Boolean {
return onPlayAnimCallback?.invoke() ?: false
}
private fun loopCarAnim() {
if (context.isDestroyed()) return
isSvgaPlaying = false
@@ -194,6 +233,18 @@ class RoomEffectView @JvmOverloads constructor(
addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage)
}
RoomEvent.CRAZY_ZOO_ROOM_NOTIFY -> {// 疯狂动物园-房间
addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage)
}
RoomEvent.CRAZY_ZOO_ALL_ROOM_NOTIFY -> {// 疯狂动物园-全服
addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage)
}
RoomEvent.TEMPLATE_NOTIFY -> {// 通用模版飘屏
addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage)
}
RoomEvent.FAIRY_DRAW_GIFT_L4,
RoomEvent.FAIRY_DRAW_GIFT_L5,
RoomEvent.FAIRY_CONVERT_L1,
@@ -230,7 +281,7 @@ class RoomEffectView @JvmOverloads constructor(
RoomEvent.ROOM_PK_NOTIFY -> addRoomPKNotify(roomEvent.chatRoomMessage)
RoomEvent.SINGLE_ROOM_PK_NOTIFY -> addSingleRoomPKNotify(roomEvent.chatRoomMessage)
RoomEvent.SINGLE_ROOM_RANK_TOP_NOTIFY -> 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
@@ -265,6 +316,11 @@ class RoomEffectView @JvmOverloads constructor(
loopCarAnim()
}
})
var statusBarHeight = TitleBar.getStatusBarHeight()
if (statusBarHeight == 0) {
statusBarHeight = UiUtils.dip2px(25f)
}
binding.clNotify.setPadding2(top = binding.clNotify.paddingTop + statusBarHeight)
}
/**
@@ -285,29 +341,18 @@ class RoomEffectView @JvmOverloads constructor(
if (binding.flPlayNotify.childCount != 0) {
return@subscribe
}
if (binding.flTemplateNotify.childCount != 0) {
return@subscribe
}
if (binding.flLuckyBagNotify.childCount != 0) {
return@subscribe
}
val isPlay = onPlayAnimCallback?.invoke() ?: false
when (messagesPlay[0].event) {
RoomEvent.BOX_NOTIFY -> {//寻爱
if ((mContext as AVRoomActivity).isTopActivity) {
isPlayAnim = true
val isPlay = onPlayAnimCallback?.invoke() ?: false
if (isPlay) {
margin(
binding.clNotify,
0,
UIUtil.dip2px(context, 180.0),
0,
0
)
} else {
margin(
binding.clNotify,
0,
UIUtil.dip2px(context, 60.0),
0,
0
)
}
if ((mContext as AVRoomActivity).isTopActivity || XChatApplication.gStack.topActivity is TreasureBoxActivity) {
playNotifyStateLiveData?.value = true
resetPlayNotifyMargin()
showBoxNotify(
messagesPlay.removeAt(0)
)
@@ -315,51 +360,17 @@ class RoomEffectView @JvmOverloads constructor(
}
RoomEvent.BOX_NOTIFY_SVGA -> {//寻爱
if ((mContext as AVRoomActivity).isTopActivity) {
isPlayAnim = true
val isPlay = onPlayAnimCallback?.invoke() ?: false
if (isPlay) {
margin(
binding.clNotify,
0,
UIUtil.dip2px(context, 180.0),
0,
0
)
} else {
margin(
binding.clNotify,
0,
UIUtil.dip2px(context, 60.0),
0,
0
)
}
if ((mContext as AVRoomActivity).isTopActivity || XChatApplication.gStack.topActivity is TreasureBoxActivity) {
playNotifyStateLiveData?.value = true
resetPlayNotifyMargin()
showBoxNotifyBySVGA(messagesPlay.removeAt(0))
}
}
RoomEvent.TAROT_NOTIFY -> {
if ((mContext as AVRoomActivity).isTopActivity) {
isPlayAnim = true
val isPlay = onPlayAnimCallback?.invoke() ?: false
if (isPlay) {
margin(
binding.clNotify,
0,
UIUtil.dip2px(context, 180.0),
0,
0
)
} else {
margin(
binding.clNotify,
0,
UIUtil.dip2px(context, 60.0),
0,
0
)
}
playNotifyStateLiveData?.value = true
resetPlayNotifyMargin()
showTarotNotify(
messagesPlay.removeAt(0)
)
@@ -368,25 +379,8 @@ class RoomEffectView @JvmOverloads constructor(
RoomEvent.TAROT_NOTIFY_SVGA -> {
if ((mContext as AVRoomActivity).isTopActivity) {
isPlayAnim = true
val isPlay = onPlayAnimCallback?.invoke() ?: false
if (isPlay) {
margin(
binding.clNotify,
0,
UIUtil.dip2px(context, 180.0),
0,
0
)
} else {
margin(
binding.clNotify,
0,
UIUtil.dip2px(context, 60.0),
0,
0
)
}
playNotifyStateLiveData?.value = true
resetPlayNotifyMargin()
showTarotNotifyBySVGA(messagesPlay.removeAt(0))
}
}
@@ -395,17 +389,8 @@ class RoomEffectView @JvmOverloads constructor(
if (!(mContext as AVRoomActivity).isTopActivity) {
return@subscribe
}
isPlayAnim = true
val isPlay = onPlayAnimCallback?.invoke() ?: false
margin(
binding.clNotify,
0,
UIUtil.dip2px(context, if (isPlay) 180.0 else 60.0),
0,
0
)
playNotifyStateLiveData?.value = true
resetPlayNotifyMargin()
val msg = messagesPlay.removeAt(0)
val attachment = msg.chatRoomMessage.attachment as NotifyH5Attachment
val bean = attachment.bean ?: return@subscribe
@@ -418,56 +403,58 @@ class RoomEffectView @JvmOverloads constructor(
}
RoomEvent.RECEIVE_ROOM_LUCKY_BAG_NOTICE, RoomEvent.RECEIVE_SERVICE_LUCKY_BAG_NOTICE -> {//福袋
isPlayAnim = true
val isPlay = onPlayAnimCallback?.invoke() ?: false
if (isPlay) {
margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0)
} else {
margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0)
}
playNotifyStateLiveData?.value = true
resetPlayNotifyMargin()
showLuckyBagNotify(
messagesPlay.removeAt(0)
)
}
RoomEvent.LUCKY_SEA_GIFT_ROOM_NOTIFY -> {//星级厨房
isPlayAnim = true
val isPlay = onPlayAnimCallback?.invoke() ?: false
if (isPlay) {
margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0)
} else {
margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0)
}
playNotifyStateLiveData?.value = true
resetPlayNotifyMargin()
showLuckySeaNotify(
messagesPlay.removeAt(0)
)
}
RoomEvent.LUCKY_SEA_GIFT_SERVER_NOTIFY -> {//星级厨房
isPlayAnim = true
val isPlay = onPlayAnimCallback?.invoke() ?: false
if (isPlay) {
margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0)
} else {
margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0)
}
playNotifyStateLiveData?.value = true
resetPlayNotifyMargin()
showLuckySeaNotifyBySVGA(
messagesPlay.removeAt(0)
)
}
RoomEvent.CRAZY_ZOO_ROOM_NOTIFY -> {//疯狂动物园-房间(静态)
playNotifyStateLiveData?.value = true
resetPlayNotifyMargin()
showZooNotify(
messagesPlay.removeAt(0)
)
}
RoomEvent.CRAZY_ZOO_ALL_ROOM_NOTIFY -> {//疯狂动物园-全服(动态)
playNotifyStateLiveData?.value = true
resetPlayNotifyMargin()
showZooNotifyBySVGA(
messagesPlay.removeAt(0)
)
}
RoomEvent.TEMPLATE_NOTIFY -> {//通用模版飘屏
resetPlayNotifyMargin()
showTemplateNotify(
messagesPlay.removeAt(0)
)
}
RoomEvent.FAIRY_DRAW_GIFT_L4,
RoomEvent.FAIRY_DRAW_GIFT_L5,
RoomEvent.FAIRY_CONVERT_L1,
RoomEvent.FAIRY_CONVERT_L2,
RoomEvent.FAIRY_CONVERT_L3 -> {//夺宝
isPlayAnim = true
val isPlay = onPlayAnimCallback?.invoke() ?: false
if (isPlay) {
margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0)
} else {
margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0)
}
playNotifyStateLiveData?.value = true
resetPlayNotifyMargin()
showFairyNotify(
messagesPlay.removeAt(0)
)
@@ -494,8 +481,8 @@ class RoomEffectView @JvmOverloads constructor(
textView.startAnimation(animationPlay)
binding.flPlayNotify.postDelayed(
{
playNotifyStateLiveData?.value = false
binding.flPlayNotify.removeView(textView)
isPlayAnim = false
},
SHOW_TIME.toLong()
)
@@ -521,8 +508,8 @@ class RoomEffectView @JvmOverloads constructor(
svgaImageView.callback = object : SimpleSvgaCallback() {
override fun onFinished() {
binding.flPlayNotify.post {
playNotifyStateLiveData?.value = false
binding.flPlayNotify.removeView(svgaImageView)
isPlayAnim = false
}
}
}
@@ -641,6 +628,19 @@ class RoomEffectView @JvmOverloads constructor(
) + ""
}
/**
* 重置玩法飘窗间距
*/
private fun resetPlayNotifyMargin() {
var top = 0
if (isShowingGiftNotify()) {
// 有礼物飘窗展示时,需要在它下面展示
// 间距 = 礼物飘窗高度(375:69) + 10DP间距
top = (width / 375f * 69).toInt() + UiUtils.dip2px(10f)
}
margin(binding.clNotify, 0, top, 0, 0)
}
private fun margin(v: View, l: Int, t: Int, r: Int, b: Int) {
if (v.layoutParams is MarginLayoutParams) {
val params = v.layoutParams as MarginLayoutParams
@@ -653,89 +653,69 @@ class RoomEffectView @JvmOverloads constructor(
val message = roomPlayBean.chatRoomMessage
val attachment = message.attachment as? RoomReceivedLuckyGiftAttachment ?: return
val noticeInfo = attachment.luckyBagNoticeInfo ?: return
val roomView = LayoutInflater.from(mContext)
.inflate(R.layout.layout_room_lucky_bag_notify, null)
val bagImageView = roomView.findViewById<ImageView>(R.id.iv_bag)
bagImageView.load(noticeInfo.luckyBagGiftPic)
val giftImageView = roomView.findViewById<ImageView>(R.id.iv_gift)
giftImageView.load(noticeInfo.giftPic)
val messageTextView = roomView.findViewById<TextView>(R.id.tv_message)
val text = SpannableBuilder()
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_04),
noticeInfo.nick.subAndReplaceDot(6),
ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_FFF45E))
)
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_027),
ForegroundColorSpan(Color.WHITE)
)
.append(
noticeInfo.nick.subAndReplaceDot(6) + " ",
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
noticeInfo.luckyBagName,
ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_FFF45E))
)
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_05),
ResUtil.getString(R.string.avroom_widget_roomeffectview_028),
ForegroundColorSpan(Color.WHITE)
)
.append(
noticeInfo.luckyBagName + " ",
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
noticeInfo.goldPrice + ResUtil.getString(R.string.diamond_name),
ForegroundColorSpan(ContextCompat.getColor(context, 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),
ResUtil.getString(R.string.avroom_widget_roomeffectview_029),
ForegroundColorSpan(Color.WHITE)
)
.append(
noticeInfo.giftName,
ForegroundColorSpan(resources.getColor(R.color.notice_nick))
ForegroundColorSpan(ContextCompat.getColor(context, R.color.notice_nick))
)
if (noticeInfo.giftNum > 1) {
text.append(
"X" + noticeInfo.giftNum,
ForegroundColorSpan(ContextCompat.getColor(context, R.color.white))
)
val svgaImageView = SVGAImageView(mContext)
svgaImageView.loops = 1
svgaImageView.clearsAfterStop = true
shareParser().decodeFromAssets(
"svga/lucky_gift_notify.svga",
object : SVGAParser.ParseCompletion {
override fun onComplete(videoItem: SVGAVideoEntity) {
binding.flPlayNotify.addView(svgaImageView)
val dynamicEntity = SVGADynamicEntity()
val textPaint = TextPaint()
textPaint.color = Color.WHITE //字體顏色
textPaint.textSize = 24f //字體大小
dynamicEntity.setDynamicText(
StaticLayout(
text.build(),
0,
text.build().length,
textPaint,
0,
Layout.Alignment.ALIGN_CENTER,
1.0f,
0.0f,
false
), "fdpp_copywriting"
)
if (AvRoomDataManager.get().roomUid == noticeInfo.roomUid) {
dynamicEntity.setHidden(true, "img_206")
} else {
svgaImageView.setOnClickListener {
//跳轉房間要移除監聽,不然可能NPE
svgaImageView.callback = null
AVRoomActivity.start(mContext, noticeInfo.roomUid)
}
}
val drawable = SVGADrawable(videoItem, dynamicEntity)
svgaImageView.setImageDrawable(drawable)
svgaImageView.stepToFrame(0, true)
}
override fun onError() {}
})
svgaImageView.callback = object : SimpleSvgaCallback() {
override fun onFinished() {
binding.flPlayNotify.post {
binding.flPlayNotify.removeView(svgaImageView)
isPlayAnim = false
}
}
}
messageTextView.text = text.build()
bagImageView.setOnClickListener {
goRoom(noticeInfo.roomTitle, noticeInfo.roomUid)
}
giftImageView.setOnClickListener {
goRoom(noticeInfo.roomTitle, noticeInfo.roomUid)
}
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
binding.flLuckyBagNotify.addView(roomView)
roomView.startAnimation(animationPlay)
binding.flLuckyBagNotify.postDelayed(
{
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
roomView.startAnimation(animationPlay)
},
6500
)
binding.flLuckyBagNotify.postDelayed({
playNotifyStateLiveData?.value = false
binding.flLuckyBagNotify.removeView(roomView)
}, 7000)
}
private fun showLuckySeaNotify(roomPlayBean: RoomPlayBean) {
@@ -780,13 +760,212 @@ class RoomEffectView @JvmOverloads constructor(
textView.startAnimation(animationPlay)
binding.flPlayNotify.postDelayed(
{
playNotifyStateLiveData?.value = false
binding.flPlayNotify.removeView(textView)
isPlayAnim = false
},
SHOW_TIME.toLong()
)
}
private fun showZooNotify(roomPlayBean: RoomPlayBean) {
val chatRoomMessage = roomPlayBean.chatRoomMessage
val attachment = chatRoomMessage.attachment as RoomLuckySeaAttachment
val bean = attachment.roomLuckySeaMsgInfo
val textView =
LayoutInflater.from(mContext)
.inflate(R.layout.layout_room_zoo_notify, null) as TextView
val text = SpannableBuilder()
.append(
ResUtil.getString(R.string.congratulation),
ForegroundColorSpan(Color.WHITE)
)
.append(
bean.nick,
ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_FEF23E))
)
.append(
ResUtil.getString(R.string.in_the_zoo),
ForegroundColorSpan(Color.WHITE)
)
.append(
bean.itemMultiple.toString(),
ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_00EAFF))
)
.append(
ResUtil.getString(R.string.times_reward_get),
ForegroundColorSpan(Color.WHITE)
)
.append(
bean.diamonds.toString(),
ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_00EAFF))
)
.append(
ResUtil.getString(R.string.diamond_point),
ForegroundColorSpan(Color.WHITE)
)
textView.text = text.build()
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
binding.flPlayNotify.addView(textView)
textView.startAnimation(animationPlay)
binding.flPlayNotify.postDelayed(
{
playNotifyStateLiveData?.value = false
binding.flPlayNotify.removeView(textView)
},
SHOW_TIME.toLong()
)
}
private fun showTemplateNotify(roomPlayBean: RoomPlayBean) {
val chatRoomMessage = roomPlayBean.chatRoomMessage
val attachment =
chatRoomMessage.attachment as? RoomTemplateNotifyAttachment
val msgBean = attachment?.getTemplateMsg()
val resourceType = msgBean?.resourceType
if (resourceType == "IMAGE") {
showTemplateImageNotify(msgBean)
} else if (resourceType == "SVGA") {
showTemplateSvgaNotify(msgBean)
}
}
private fun showTemplateImageNotify(msgBean: RoomTemplateNotifyMsgBean) {
if (msgBean.resourceType != "IMAGE") {
return
}
val resourceContent = msgBean.resourceContent
if (resourceContent.isNullOrEmpty()) {
return
}
playNotifyStateLiveData?.value = true
val rootView = LayoutInflater.from(mContext)
.inflate(R.layout.layout_room_template_notify_image, null)
val textView = rootView.findViewById<TextView>(R.id.tv_text)
val textSize = msgBean.fontSize?.toFloat() ?: 12f
val textColor =
templateMessageAdapter.parseColor(msgBean.textColor) ?: Color.WHITE
textView.textSize = textSize
textView.setTextColor(textColor)
val bgView = rootView.findViewById<ImageView>(R.id.iv_bg)
val params = ConstraintLayout.LayoutParams(
ConstraintLayout.LayoutParams.MATCH_PARENT,
ConstraintLayout.LayoutParams.WRAP_CONTENT
)
binding.flTemplateNotify.addView(rootView, params)
val endAction = {
playNotifyStateLiveData?.value = false
binding.flTemplateNotify.removeView(rootView)
}
GlideApp.with(bgView)
.load(resourceContent).into(object : CustomTarget<Drawable>() {
override fun onResourceReady(
resource: Drawable,
transition: Transition<in Drawable>?
) {
templateMessageAdapter.convert(textView, msgBean)
bgView.setImageDrawable(resource)
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
rootView.startAnimation(animationPlay)
val skipType = msgBean.skipType
if (skipType != null) {
val clickAction = View.OnClickListener {
if (skipType == BannerInfo.SKIP_TYPE_ROOM_USER_CARD) {
showUserCardAction?.invoke(msgBean.skipContent ?: "")
} else {
CommonJumpHelper.bannerJump(context, skipType, msgBean.skipContent)
}
}
rootView.setOnClickListener(clickAction)
textView.setOnClickListener(clickAction)
}
binding.flTemplateNotify.postDelayed(endAction, SHOW_TIME.toLong())
}
override fun onLoadCleared(placeholder: Drawable?) {
endAction.invoke()
}
override fun onLoadFailed(errorDrawable: Drawable?) {
super.onLoadFailed(errorDrawable)
endAction.invoke()
}
})
}
private fun showTemplateSvgaNotify(msgBean: RoomTemplateNotifyMsgBean) {
if (msgBean.resourceType != "SVGA") {
return
}
val resourceContent = msgBean.resourceContent
if (resourceContent.isNullOrEmpty()) {
return
}
playNotifyStateLiveData?.value = true
val svgaImageView = SVGAImageView(mContext)
val endAction = {
playNotifyStateLiveData?.value = false
binding.flTemplateNotify.removeView(svgaImageView)
}
svgaImageView.loops = 1
svgaImageView.clearsAfterDetached = true
val params = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, 0)
params.dimensionRatio = msgBean.getDimensionRatio() ?: "75:11"
svgaImageView.layoutParams = params
svgaImageView.callback = object : SimpleSvgaCallback() {
override fun onFinished() {
endAction.invoke()
}
}
binding.flTemplateNotify.addView(svgaImageView)
shareParser().decodeFromURL(
URL(resourceContent),
object : SVGAParser.ParseCompletion {
override fun onComplete(videoItem: SVGAVideoEntity) {
val text = templateMessageAdapter.parse(context, msgBean) ?: ""
val textKey = msgBean.getSvgaTextKey()
val textSize = msgBean.fontSize?.toFloat() ?: 24f
val textColor =
templateMessageAdapter.parseColor(msgBean.textColor) ?: Color.WHITE
val dynamicEntity = SVGADynamicEntity()
val textPaint = TextPaint()
textPaint.color = textColor //字體顏色
textPaint.textSize = textSize //字體大小
dynamicEntity.setDynamicText(
StaticLayout(
text,
0,
text.length,
textPaint,
0,
Layout.Alignment.ALIGN_CENTER,
1.0f,
0.0f,
false
), textKey
)
val skipType = msgBean.skipType
if (skipType != null) {
svgaImageView.setOnClickListener {
if (skipType == BannerInfo.SKIP_TYPE_ROOM_USER_CARD) {
showUserCardAction?.invoke(msgBean.skipContent?:"")
} else {
CommonJumpHelper.bannerJump(context, skipType, msgBean.skipContent)
}
}
}
val drawable = SVGADrawable(videoItem, dynamicEntity)
svgaImageView.setImageDrawable(drawable)
svgaImageView.stepToFrame(0, true)
}
override fun onError() {
endAction.invoke()
}
},
null
)
}
private fun showLuckySeaNotifyBySVGA(roomPlayBean: RoomPlayBean) {
val chatRoomMessage = roomPlayBean.chatRoomMessage
val attachment = chatRoomMessage.attachment as RoomLuckySeaAttachment
@@ -828,8 +1007,8 @@ class RoomEffectView @JvmOverloads constructor(
svgaImageView.callback = object : SimpleSvgaCallback() {
override fun onFinished() {
binding.flPlayNotify.post {
playNotifyStateLiveData?.value = false
binding.flPlayNotify.removeView(svgaImageView)
isPlayAnim = false
}
}
}
@@ -871,9 +1050,93 @@ class RoomEffectView @JvmOverloads constructor(
)
}
private fun showZooNotifyBySVGA(roomPlayBean: RoomPlayBean) {
val chatRoomMessage = roomPlayBean.chatRoomMessage
val attachment = chatRoomMessage.attachment as RoomLuckySeaAttachment
val bean = attachment.roomLuckySeaMsgInfo
val text = SpannableBuilder()
.append(
ResUtil.getString(R.string.congratulation),
ForegroundColorSpan(Color.WHITE)
)
.append(
bean.nick + " ",
ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_FEF23E))
)
.append(
ResUtil.getString(R.string.in_the_zoo),
ForegroundColorSpan(Color.WHITE)
)
.append(
bean.itemMultiple.toString(),
ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_00EAFF))
)
.append(
ResUtil.getString(R.string.times_reward_get),
ForegroundColorSpan(Color.WHITE)
)
.append(
bean.diamonds.toString(),
ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_00EAFF))
)
.append(
ResUtil.getString(R.string.diamond_point),
ForegroundColorSpan(Color.WHITE)
)
val svgaImageView = SVGAImageView(mContext)
svgaImageView.loops = 1
svgaImageView.clearsAfterDetached = true
val params = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
svgaImageView.layoutParams = params
svgaImageView.callback = object : SimpleSvgaCallback() {
override fun onFinished() {
binding.flPlayNotify.post {
playNotifyStateLiveData?.value = false
binding.flPlayNotify.removeView(svgaImageView)
}
}
}
binding.flPlayNotify.addView(svgaImageView)
shareParser().decodeFromAssets(
"svga/zoo_notify.svga",
object : SVGAParser.ParseCompletion {
override fun onComplete(videoItem: SVGAVideoEntity) {
val dynamicEntity = SVGADynamicEntity()
val textPaint = TextPaint()
textPaint.color = Color.WHITE //字體顏色
textPaint.textSize = 24f //字體大小
dynamicEntity.setDynamicText(
StaticLayout(
text.build(),
0,
text.build().length,
textPaint,
0,
Layout.Alignment.ALIGN_CENTER,
1.0f,
0.0f,
false
), "noble_text_tx"
)
svgaImageView.setOnClickListener {
if (!TextUtils.isEmpty(bean.skipUrl)) {
CommonWebViewActivity.start(mContext, bean.skipUrl)
}
}
val drawable = SVGADrawable(videoItem, dynamicEntity)
svgaImageView.setImageDrawable(drawable)
svgaImageView.stepToFrame(0, true)
}
override fun onError() {}
},
null
)
}
private fun showNotifyH5(data: NotifyH5Info) {
val textView = LayoutInflater.from(mContext)
.inflate(R.layout.layout_notify_h5, null) as TextView
.inflate(R.layout.layout_notify_h5, null) as TextView
textView.text = data.content
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
binding.flPlayNotify.addView(textView)
@@ -886,8 +1149,8 @@ class RoomEffectView @JvmOverloads constructor(
SHOW_TIME.toLong()
)
binding.flPlayNotify.postDelayed({
playNotifyStateLiveData?.value = false
binding.flPlayNotify.removeView(textView)
isPlayAnim = false
}, CLOSE_TIME.toLong())
}
@@ -901,8 +1164,8 @@ class RoomEffectView @JvmOverloads constructor(
svgaImageView.callback = object : SimpleSvgaCallback() {
override fun onFinished() {
binding.flPlayNotify.post {
playNotifyStateLiveData?.value = false
binding.flPlayNotify.removeView(svgaImageView)
isPlayAnim = false
}
}
}
@@ -962,8 +1225,8 @@ class RoomEffectView @JvmOverloads constructor(
SHOW_TIME.toLong()
)
binding.flPlayNotify.postDelayed({
playNotifyStateLiveData?.value = false
binding.flPlayNotify.removeView(textView)
isPlayAnim = false
}, CLOSE_TIME.toLong())
}
@@ -1005,8 +1268,8 @@ class RoomEffectView @JvmOverloads constructor(
SHOW_TIME.toLong()
)
binding.flPlayNotify.postDelayed({
playNotifyStateLiveData?.value = false
binding.flPlayNotify.removeView(textView)
isPlayAnim = false
}, CLOSE_TIME.toLong())
}
@@ -1028,8 +1291,8 @@ class RoomEffectView @JvmOverloads constructor(
svgaImageView.callback = object : SimpleSvgaCallback() {
override fun onFinished() {
binding.flPlayNotify.post {
playNotifyStateLiveData?.value = false
binding.flPlayNotify.removeView(svgaImageView)
isPlayAnim = false
}
}
}
@@ -1100,8 +1363,8 @@ class RoomEffectView @JvmOverloads constructor(
animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close)
animationPlay!!.setAnimationListener(object : SimpleAnimationListener() {
override fun onAnimationEnd(animation: Animation?) {
playNotifyStateLiveData?.value = false
binding.flPlayNotify.removeView(svgaImageView)
isPlayAnim = false
}
})
binding.flPlayNotify.startAnimation(animationPlay)
@@ -1907,6 +2170,27 @@ class RoomEffectView @JvmOverloads constructor(
)
}
private fun showSingleRoomRankNotify(chatRoomMessage: ChatRoomMessage) {
if (binding.clNotify.visibility == GONE) {
binding.clNotify.visibility = VISIBLE
}
val roomPkBean = (chatRoomMessage.attachment as SingleRoomRankAttachment).msgBean
val rootView =
LayoutInflater.from(mContext).inflate(R.layout.layout_single_room_rank_notify, null)
(rootView.findViewById<View>(R.id.tv_nick) as TextView).text =
roomPkBean.nick.subAndReplaceDot(6)
(rootView.findViewById<View>(R.id.tv_desc) as TextView).text = roomPkBean.desc
rootView.findViewById<ImageView>(R.id.iv_avatar).load(roomPkBean.avatar)
rootView.setOnClickListener { AVRoomActivity.start(context, roomPkBean.uid) }
binding.flSingleRoomRankNotify.addView(rootView)
animationLuckyGift = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
rootView.startAnimation(animationLuckyGift)
binding.flSingleRoomRankNotify.postDelayed({
binding.flSingleRoomRankNotify.removeView(
rootView
)
}, SHOW_TIME.toLong())
}
private fun showRoomRankNotify(chatRoomMessage: ChatRoomMessage) {
if (binding.clNotify.visibility == GONE) {
@@ -1935,10 +2219,6 @@ class RoomEffectView @JvmOverloads constructor(
}, SHOW_TIME.toLong())
}
fun getIsPlayAnim(): Boolean {
return isPlayAnim
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
playDisposable?.dispose()
@@ -1952,7 +2232,20 @@ class RoomEffectView @JvmOverloads constructor(
disposableRoomPK?.dispose()
disposableSingleRoomPK?.dispose()
disposableGiftCompound?.dispose()
isPlayAnim = false
playNotifyStateLiveData?.value = false
}
private fun goRoom(roomTitle: String, roomUid: Long) {
if (roomUid <= 0L) {
return
}
if (roomUid == AvRoomDataManager.get().roomUid) {
return
}
if (isNeedTips()) {
AllServiceGiftGoRoomTipsDialog(context, roomTitle, roomUid).show()
} else {
AVRoomActivity.start(context, roomUid)
}
}
}

View File

@@ -0,0 +1,179 @@
package com.yizhuan.erban.avroom.widget
import android.content.Context
import android.graphics.Color
import android.text.SpannableStringBuilder
import android.text.method.LinkMovementMethod
import android.text.style.ForegroundColorSpan
import android.view.View
import android.widget.TextView
import com.chuhai.utils.UiUtils
import com.yizhuan.erban.common.widget.OriginalDrawStatusClickSpan
import com.yizhuan.erban.utils.CommonJumpHelper
import com.yizhuan.erban.utils.SpannableBuilder
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
import com.yizhuan.xchat_android_core.im.custom.bean.TemplateMessage
import com.yizhuan.xchat_android_core.im.custom.bean.TemplateMessage.TemplateNode
/**
* Created by Max on 2024/2/22 17:20
* Desc:模版消息适配器
**/
class TemplateMessageAdapter(val listener: Listener?) {
/**
* 解析为文本子节点只支持TEXT类型
*/
fun parse(context: Context, attachment: TemplateMessage?): SpannableStringBuilder? {
val builder = SpannableBuilder()
if (attachment == null) {
return null
}
val nodeList = attachment.getNodeList()
nodeList.forEach {
if (it is TemplateNode.NormalNode) {
val textColor = parseColor(it.textColor)
if (textColor != null) {
builder.append(it.text, ForegroundColorSpan(textColor))
} else {
builder.append(it.text)
}
} else if (it is TemplateNode.SpecialNode) {
when (it.content.type) {
TemplateMessage.Content.TEXT -> {
val text = it.content.text?.getFirstText()
if (!text.isNullOrEmpty()) {
val textColor = parseColor(it.content.textColor)
val clickSpan = createClickSpan(context, it.content, listener)
val list = ArrayList<Any>()
if (textColor != null) {
list.add(ForegroundColorSpan(textColor))
}
if (clickSpan != null) {
list.add(clickSpan)
}
builder.append(text, *list.toArray())
}
}
}
}
}
return builder.build()
}
fun convert(textView: TextView, attachment: TemplateMessage?) {
if (attachment == null) {
textView.text = ""
return
}
val nodeList = attachment.getNodeList()
val textBuilder = MessageView.SpannableBuilder(textView)
nodeList.forEach {
if (it is TemplateNode.NormalNode) {
val textColor = parseColor(it.textColor)
if (textColor != null) {
textBuilder.append(it.text, ForegroundColorSpan(textColor))
} else {
textBuilder.append(it.text)
}
} else if (it is TemplateNode.SpecialNode) {
when (it.content.type) {
TemplateMessage.Content.TEXT -> {
val text = it.content.text?.getFirstText()
if (!text.isNullOrEmpty()) {
val textColor = parseColor(it.content.textColor)
val clickSpan = createClickSpan(textView.context, it.content, listener)
val list = ArrayList<Any>()
if (textColor != null) {
list.add(ForegroundColorSpan(textColor))
}
if (clickSpan != null) {
list.add(clickSpan)
}
textBuilder.append(text, *list.toArray())
}
}
TemplateMessage.Content.IMAGE -> {
val image = it.content.image
val width = it.content.width ?: 0
val height = it.content.height ?: 0
val clickSpan = createClickSpan(textView.context, it.content, listener)
if (height > 0 && width == 0) {
if (clickSpan != null) {
textBuilder.append(
image,
UiUtils.dip2px(height.toFloat()),
clickSpan
)
} else {
textBuilder.append(image, UiUtils.dip2px(height.toFloat()))
}
} else if (height > 0 && width > 0) {
if (clickSpan != null) {
textBuilder.append(
image,
UiUtils.dip2px(width.toFloat()),
UiUtils.dip2px(height.toFloat()), clickSpan
)
} else {
textBuilder.append(
image,
UiUtils.dip2px(width.toFloat()),
UiUtils.dip2px(height.toFloat())
)
}
} else {
if (clickSpan != null) {
textBuilder.appendImg(image, clickSpan)
} else {
textBuilder.appendImg(image)
}
}
}
}
}
}
textView.text = textBuilder.build()
textView.setOnClickListener(null)
textView.movementMethod = LinkMovementMethod()
}
private fun createClickSpan(
context: Context,
content: TemplateMessage.Content,
listener: Listener?
): OriginalDrawStatusClickSpan? {
val skipType = content.getSkipType()
val skipUri = content.getSkipUri()
if (skipType > 0 && !skipUri.isNullOrEmpty()) {
return object : OriginalDrawStatusClickSpan() {
override fun onClick(widget: View) {
if (skipType == BannerInfo.SKIP_TYPE_ROOM_USER_CARD) {
listener?.onShowUserCard(skipUri)
} else {
CommonJumpHelper.bannerJump(context, content)
}
}
}
} else {
return null
}
}
fun parseColor(color: String?): Int? {
if (color == null) {
return null
}
try {
return Color.parseColor(color)
} catch (e: java.lang.Exception) {
e.printStackTrace()
}
return null
}
interface Listener {
fun onShowUserCard(uid: String)
}
}

View File

@@ -6,6 +6,8 @@ import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUS
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MESS_SUB_RENEWNOBLE;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_BOX;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_CRAZY_ZOO;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_CRAZY_ZOO_SUB_ALL_ROOM;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAIRY;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT;
@@ -17,6 +19,8 @@ import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUS
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DRAW_GIFT_L5;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ALL_DIAMOND;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY_ALL;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_VIP;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_VIP_USER_ALL_UPGRADE;
import static com.yizhuan.xchat_android_library.utils.UIUtils.getActivityByContext;
@@ -105,6 +109,7 @@ import com.yizhuan.xchat_android_core.im.custom.bean.NotifyH5Info;
import com.yizhuan.xchat_android_core.im.custom.bean.PlayEffectInfo;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeInfo;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomLuckySeaMsgBean;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomTemplateNotifyMsgBean;
import com.yizhuan.xchat_android_core.im.custom.bean.TarotMsgBean;
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager;
@@ -883,6 +888,10 @@ public abstract class BaseActivity extends RxAppCompatActivity
return rxPermissions.request(mPerms);
}
public RxPermissions getRxPermissions(){
return rxPermissions;
}
/**
* 接收到全局广播信息
*
@@ -992,17 +1001,10 @@ public abstract class BaseActivity extends RxAppCompatActivity
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();
if (isShowingPlayNotify()) {
return;
}
showGiftDialog();
}
break;
case CUSTOM_MSG_BOX://寻爱之旅
@@ -1106,7 +1108,7 @@ public abstract class BaseActivity extends RxAppCompatActivity
if (roomLuckySeaMsgBean == null) return;
if (baseProtocol.getSecond() == CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL) {
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
playEffectInfo.setSecond(CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL);
playEffectInfo.setSecond(baseProtocol.getSecond());
playEffectInfo.setRoomLuckySeaMsgBean(roomLuckySeaMsgBean);
playEffectList.add(playEffectInfo);
if (playEffectDialog != null && playEffectDialog.isShowing()) {
@@ -1122,6 +1124,64 @@ public abstract class BaseActivity extends RxAppCompatActivity
}
}
break;
case CUSTOM_MSG_CRAZY_ZOO://疯狂动物园
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|| this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|| UserUtils.getUserInfo() == null)
return;
if (playEffectList == null) {
playEffectList = new LinkedList<>();
}
RoomLuckySeaMsgBean roomLuckySeaMsgBean2 = JSON.parseObject(String.valueOf(baseProtocol.getData()), RoomLuckySeaMsgBean.class);
if (roomLuckySeaMsgBean2 == null) return;
if (baseProtocol.getSecond() == CUSTOM_MSG_CRAZY_ZOO_SUB_ALL_ROOM) {
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
playEffectInfo.setSecond(baseProtocol.getSecond());
playEffectInfo.setRoomLuckySeaMsgBean(roomLuckySeaMsgBean2);
playEffectList.add(playEffectInfo);
if (playEffectDialog != null && playEffectDialog.isShowing()) {
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
PlayEffectInfo dataBean = playEffectList.peekFirst();
if (dataBean != null) {
return;
} else {
playEffectDialog.dismiss();
}
} else {
showPlayEffectDialog();
}
}
break;
case CUSTOM_MSG_TEMPLATE_NOTIFY://通用飘屏
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
|| this instanceof TreasureBoxActivity || this instanceof HomeFairyActivity
|| UserUtils.getUserInfo() == null)
return;
if (playEffectList == null) {
playEffectList = new LinkedList<>();
}
if (baseProtocol.getSecond() == CUSTOM_MSG_TEMPLATE_NOTIFY_ALL) {
RoomTemplateNotifyMsgBean templateNotifyMsgBean = new Gson().fromJson(String.valueOf(baseProtocol.getData()), RoomTemplateNotifyMsgBean.class);
if (templateNotifyMsgBean == null) return;
PlayEffectInfo playEffectInfo = new PlayEffectInfo();
playEffectInfo.setSecond(baseProtocol.getSecond());
playEffectInfo.setTemplateNotifyMsgBean(templateNotifyMsgBean);
playEffectList.add(playEffectInfo);
if (playEffectDialog != null && playEffectDialog.isShowing()) {
// 如果当前以及有礼物弹窗在展示,则需要等到他 dismiss 后再显示下一个
PlayEffectInfo dataBean = playEffectList.peekFirst();
if (dataBean != null) {
return;
} else {
playEffectDialog.dismiss();
}
} else {
showPlayEffectDialog();
}
}
break;
case CUSTOM_MSG_LUCKY_GIFT://福袋
if (!isValid() || getWindow().getDecorView().getVisibility() != View.VISIBLE) return;
if (this instanceof AddUserInfoActivity || this instanceof AVRoomActivity
@@ -1187,8 +1247,11 @@ public abstract class BaseActivity extends RxAppCompatActivity
private void showPlayEffectDialog() {
if (playEffectList.size() == 0) return;
playEffectDialog = new AllPlayEffectDialog(this, playEffectList.peekFirst());
PlayEffectInfo info = playEffectList.peekFirst();
if (info == null) return;
playEffectDialog = new AllPlayEffectDialog(this, info, isShowingGiftNotify());
playEffectDialog.setOnDismissListener(dialog -> {
tryShowGiftDialog();
playEffectList.pollFirst();
PlayEffectInfo dataBean = playEffectList.peekFirst();
if (dataBean != null) {
@@ -1206,12 +1269,20 @@ public abstract class BaseActivity extends RxAppCompatActivity
}
}
private void tryShowGiftDialog() {
showGiftDialog();
}
private void showGiftDialog() {
if (giftList == null) return;
if (giftList.size() == 0) return;
AllServiceGiftProtocol.DataBean data = giftList.peekFirst();
if (data == null) {
return;
}
if (giftDialog != null && giftDialog.isShowing()) {
return;
}
if (!data.isHomeShow()) {
return;
}
@@ -1234,6 +1305,20 @@ public abstract class BaseActivity extends RxAppCompatActivity
}
}
private boolean isShowingGiftNotify() {
if (giftDialog != null && giftDialog.isShowing()) {
return true;
}
return false;
}
private boolean isShowingPlayNotify() {
if (playEffectDialog != null && playEffectDialog.isShowing()) {
return true;
}
return false;
}
private AllServiceGiftLevelDialog generateAllServiceGiftDialog(@NonNull Context context, @NonNull AllServiceGiftProtocol.DataBean dataBean) {
return new AllServiceGiftLevelDialog(context, dataBean);
}
@@ -1418,14 +1503,15 @@ public abstract class BaseActivity extends RxAppCompatActivity
JSONObject jsonObject;
try {
jsonObject = JSON.parseObject(contentStr);
if (jsonObject == null) return;
if (jsonObject.containsKey("body")) {
String body = jsonObject.getString("body");
if (TextUtils.isEmpty(body)) return;
baseMvpActivity.onReceivedNimBroadcastMessage(body);
}
} catch (Exception e) {
jsonObject = null;
}
if (jsonObject == null) return;
if (jsonObject.containsKey("body")) {
String body = jsonObject.getString("body");
if (TextUtils.isEmpty(body)) return;
baseMvpActivity.onReceivedNimBroadcastMessage(body);
e.printStackTrace();
}
}
}

View File

@@ -15,7 +15,7 @@ import java.lang.reflect.ParameterizedType
abstract class BaseDialog<T : ViewBinding> : RxDialogFragment() {
val isViewLoaded: Boolean get() = _binding != null
private var _binding: T? = null
protected var _binding: T? = null
private var onDismissListener: (() -> Unit)? = null
val binding get() = _binding!!
open var width = ScreenUtil.getDialogWidth()

View File

@@ -207,7 +207,7 @@ class PhotoDialog : BaseDialogFragment<PhotoDialogBinding>(), EasyPermissions.Pe
REQUEST_CODE_OPEN_CAMERA_PROVIDER -> {
if (mOnResultCallBack == null || data == null) return
PhotoProvider.getResultPathListAsync(data) { paths ->
val list = paths?.toMutableList() ?: ArrayList()
val list = paths?.mapNotNull { it.path }?.toMutableList() ?: ArrayList()
val path = list[0]
if (!TextUtils.isEmpty(path)) {
mJob?.cancel()
@@ -233,7 +233,7 @@ class PhotoDialog : BaseDialogFragment<PhotoDialogBinding>(), EasyPermissions.Pe
REQUEST_CODE_OPEN_PHOTO_PROVIDER -> {
if (mOnResultCallBack == null || data == null) return
PhotoProvider.getResultPathListAsync(data) { list ->
val paths = list?.toMutableList() ?: ArrayList()
val paths = list?.mapNotNull { it.path }?.toMutableList() ?: ArrayList()
if (paths.isEmpty()) {
mOnResultCallBack?.choicePhotoCallBack(paths)
} else {

View File

@@ -86,13 +86,25 @@ object PhotoProvider {
@JvmStatic
@JvmOverloads
fun photoProvider(activity: FragmentActivity, maxSelect: Int = 1, canChooseGif: Boolean = false, resultCode: Int, isClearCache: Boolean = true) {
fun photoProvider(
activity: FragmentActivity,
maxSelect: Int = 1,
canChooseGif: Boolean = false,
resultCode: Int,
isClearCache: Boolean = true,
useWidth: Boolean = false
) {
cancelJop()
mPhotoJob = MainScope().launch {
if (isClearCache && isClearByTime()) {
withContext(Dispatchers.IO) { clearCache() }
}
EasyPhotos.createAlbum(activity, false, false, GlideEngine())//参数说明上下文是否显示相机按钮是否使用宽高数据false时宽高数据为0扫描速度更快[配置Glide为图片加载引擎](https://github.com/HuanTanSheng/EasyPhotos/wiki/12-%E9%85%8D%E7%BD%AEImageEngine%EF%BC%8C%E6%94%AF%E6%8C%81%E6%89%80%E6%9C%89%E5%9B%BE%E7%89%87%E5%8A%A0%E8%BD%BD%E5%BA%93)
EasyPhotos.createAlbum(
activity,
false,
useWidth,
GlideEngine()
)//参数说明上下文是否显示相机按钮是否使用宽高数据false时宽高数据为0扫描速度更快[配置Glide为图片加载引擎](https://github.com/HuanTanSheng/EasyPhotos/wiki/12-%E9%85%8D%E7%BD%AEImageEngine%EF%BC%8C%E6%94%AF%E6%8C%81%E6%89%80%E6%9C%89%E5%9B%BE%E7%89%87%E5%8A%A0%E8%BD%BD%E5%BA%93)
.setCount(maxSelect)//参数说明最大可选数默认1
.setGif(canChooseGif)
.setPuzzleMenu(false)
@@ -131,7 +143,7 @@ object PhotoProvider {
}
@JvmStatic
fun getResultPathListAsync(data: Intent?, resultListener: ((List<String>?) -> Unit)) {
fun getResultPathListAsync(data: Intent?, resultListener: ((List<Photo>?) -> Unit)) {
cancelJop()
mPhotoJob = MainScope().launch {
val list: List<Photo>? = data?.getParcelableArrayListExtra(EasyPhotos.RESULT_PHOTOS)
@@ -151,22 +163,21 @@ object PhotoProvider {
* 1. 项目使用到BitmapFactory.decodeFile(imgPath, options)之类的方法该方法在android Q直接使用外部path测试中发现获取图片信息失败
*
*/
private fun copyToInternalCache(photos: List<Photo>?): List<String>? {
private fun copyToInternalCache(photos: List<Photo>?): List<Photo>? {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
val foldPath = getInternalPath() + File.separator
val newPaths = ArrayList<String>()
photos?.forEach {
if (it.uri != null && !it.name.isNullOrEmpty()) {
val path = "$foldPath${it.name}"
if (FileHelper.copyFileFromUri(it.uri, path, true)) {
newPaths.add(path)
it.path = path
Logger.debug(TAG, "path: ${it.path} , displayName: ${it.name} , newPath: $path ")
}
}
}
newPaths
photos
} else {
photos?.takeIf { it.isNotEmpty() }?.map { it.path }
photos
}
}

View File

@@ -2,33 +2,24 @@ package com.yizhuan.erban.common.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.Outline;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.widget.ImageView;
import android.view.View;
import android.view.ViewOutlineProvider;
import com.google.android.material.imageview.ShapeableImageView;
import com.google.android.material.shape.CornerFamily;
import com.google.android.material.shape.ShapeAppearanceModel;
import com.yizhuan.erban.R;
import java.io.InputStream;
/**
* 自定义View实现圆角圆形等效果
*
* @author zhy
*/
public class RectRoundImageView extends ImageView {
public class RectRoundImageView extends ShapeableImageView {
/**
* TYPE_CIRCLE / TYPE_ROUND
@@ -37,42 +28,11 @@ public class RectRoundImageView extends ImageView {
public static final int TYPE_CIRCLE = 0;
public static final int TYPE_ROUND = 1;
/**
* 图片
*/
private Bitmap mSrc;
/**
* 圆角的大小
*/
private int mRadius = 8;
/**
* 控件的宽度
*/
private int mWidth;
/**
* 控件的高度
*/
private int mHeight;
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public int getmRadius() {
return mRadius;
}
public void setmRadius(int mRadius) {
this.mRadius = mRadius;
}
public RectRoundImageView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
@@ -98,17 +58,6 @@ public class RectRoundImageView extends ImageView {
for (int i = 0; i < n; i++) {
int attr = a.getIndex(i);
switch (attr) {
case R.styleable.RectRoundImageView_src:
// mSrc = BitmapFactory.decodeResource(getResources(),
// a.getResourceId(attr, 0));
InputStream is = getResources().openRawResource(a.getResourceId(attr, 0));
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inTempStorage = new byte[100 * 1024];
opts.inPreferredConfig = Config.RGB_565;
opts.inPurgeable = true;
opts.inSampleSize = 4;
mSrc = BitmapFactory.decodeStream(is, null, opts);
break;
case R.styleable.RectRoundImageView_type:
type = a.getInt(attr, 0);// 默认为Circle
break;
@@ -121,197 +70,25 @@ public class RectRoundImageView extends ImageView {
}
setScaleType(ScaleType.CENTER_CROP);
a.recycle();
setup(type, mRadius);
}
/**
* 计算控件的高度和宽度
*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
Drawable drawable = getDrawable();
if (null != drawable) {
mSrc = drawableToBitmap(getDrawable());
}
/**
* 设置宽度
*/
int specMode = MeasureSpec.getMode(widthMeasureSpec);
int specSize = MeasureSpec.getSize(widthMeasureSpec);
if (specMode == MeasureSpec.EXACTLY)// match_parent , accurate
{
mWidth = specSize;
} else {
// 由图片决定的宽
int desireByImg = getPaddingLeft() + getPaddingRight()
+ mSrc.getWidth();
if (specMode == MeasureSpec.AT_MOST)// wrap_content
{
mWidth = Math.min(desireByImg, specSize);
} else
mWidth = desireByImg;
}
/***
* 设置高度
*/
specMode = MeasureSpec.getMode(heightMeasureSpec);
specSize = MeasureSpec.getSize(heightMeasureSpec);
if (specMode == MeasureSpec.EXACTLY)// match_parent , accurate
{
mHeight = specSize;
} else {
int desire = getPaddingTop() + getPaddingBottom()
+ mSrc.getHeight();
if (specMode == MeasureSpec.AT_MOST)// wrap_content
{
mHeight = Math.min(desire, specSize);
} else
mHeight = desire;
}
setMeasuredDimension(mWidth, mHeight);
}
/**
* 绘制
*/
@Override
protected void onDraw(Canvas canvas) {
switch (type) {
// 如果是TYPE_CIRCLE绘制圆形
case TYPE_CIRCLE:
int min = Math.min(mWidth, mHeight);
/**
* 长度如果不一致,按小的值进行压缩
*/
if (null != mSrc) {
mSrc = Bitmap.createScaledBitmap(mSrc, min, min, false);
canvas.drawBitmap(createCircleImage(mSrc, min), 0, 0, null);
private void setup(int type, int cornerSize) {
if (type == TYPE_CIRCLE) {
setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
int min = Math.min(view.getWidth(), view.getHeight());
int left = (view.getWidth() - min) / 2;
int top = (view.getHeight() - min) / 2;
outline.setOval(left, top, min, min);
}
break;
case TYPE_ROUND:
canvas.drawBitmap(createFramedPhoto(mWidth, mHeight, mSrc, mRadius), 0, 0, null);
break;
});
setClipToOutline(true);
} else if (type == TYPE_ROUND) {
setShapeAppearanceModel(ShapeAppearanceModel.builder()
.setAllCorners(CornerFamily.ROUNDED, cornerSize)
.build());
}
}
/**
* Drawable → Bitmap
*
* @param drawable
* @return
*/
public static Bitmap drawableToBitmap(Drawable drawable) {
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(),
drawable.getOpacity() != PixelFormat.OPAQUE ? Config.ARGB_8888
: Config.RGB_565);
Canvas canvas = new Canvas(bitmap);
//canvas.setBitmap(bitmap);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
drawable.draw(canvas);
return bitmap;
}
/**
* 根据原图和变长绘制圆形图片
*
* @param source
* @param min
* @return
*/
private Bitmap createCircleImage(Bitmap source, int min) {
final Paint paint = new Paint();
paint.setAntiAlias(true);
Bitmap target = Bitmap.createBitmap(min, min, Config.RGB_565);
/**
* 产生一个同样大小的画布
*/
Canvas canvas = new Canvas(target);
/**
* 首先绘制圆形
*/
canvas.drawCircle(min / 2, min / 2, min / 2, paint);
/**
* 使用SRC_IN参考上面的说明
*/
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
/**
* 绘制图片
*/
canvas.drawBitmap(source, 0, 0, paint);
return target;
}
/**
* 根据原图添加圆角
*
* @param source
* @return
*/
private Bitmap createRoundConerImage(Bitmap source) {
final Paint paint = new Paint();
paint.setAntiAlias(true);
Bitmap target = Bitmap.createBitmap(mWidth, mHeight, Config.ARGB_8888);
Canvas canvas = new Canvas(target);
RectF rect = new RectF(0, 0, source.getWidth(), source.getHeight());
canvas.drawRoundRect(rect, mRadius, mRadius, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(source, 0, 0, paint);
return target;
}
/**
* @param x 图像的宽度
* @param y 图像的高度
* @param image 源图片
* @param outerRadiusRat 圆角的大小
* @return 圆角图片
*/
Bitmap createFramedPhoto(int x, int y, Bitmap image, float outerRadiusRat) {
//根据源文件新建一个darwable对象
Drawable imageDrawable = new BitmapDrawable(image);
// 新建一个新的输出图片
Bitmap output = Bitmap.createBitmap(x, y, Config.ARGB_8888);
Canvas canvas = new Canvas(output);
// 新建一个矩形
RectF outerRect = new RectF(0, 0, x, y);
// 产生一个红色的圆角矩形
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.RED);
canvas.drawRoundRect(outerRect, outerRadiusRat, outerRadiusRat, paint);
// 将源图片绘制到这个圆角矩形上
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
imageDrawable.setBounds(0, 0, x, y);
canvas.saveLayer(outerRect, paint, Canvas.ALL_SAVE_FLAG);
imageDrawable.draw(canvas);
canvas.restore();
return output;
}
}

View File

@@ -79,7 +79,7 @@ class FansTeamJoinActivity : BaseViewBindingActivity<ActivityFansTeamJoinBinding
?.let { privilegeConfig ->
binding.ivJoinLogo.load(privilegeConfig.icon)
binding.tvJoin.text = privilegeConfig.name
binding.tvJoin.setOnClickListener {
binding.bgJoin.setOnClickListener {
privilegeConfig.giftVo?.let { giftInfo ->
GiftModel.get().sendFansTeamGift(
giftInfo.giftId,

View File

@@ -5,6 +5,7 @@ import androidx.lifecycle.MutableLiveData
import com.yizhuan.erban.base.BaseViewModel
import com.yizhuan.xchat_android_core.bean.response.ListResult
import com.yizhuan.xchat_android_core.fansteam.*
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
import com.yizhuan.xchat_android_core.utils.toast
class FansTeamViewModel : BaseViewModel() {
@@ -37,6 +38,9 @@ class FansTeamViewModel : BaseViewModel() {
}
fun loadFansTeamInitInfo() {
if (AvRoomDataManager.get().roomUid == 0L) {
return
}
safeLaunch {
_fansTeamInitInfoLiveData.value = FansTeamModel.getFansTeamInitInfo()
}

View File

@@ -14,8 +14,8 @@ import kotlinx.coroutines.async
class HomeViewModel : BaseViewModel() {
private val _tabHomeLiveData = MutableLiveData<List<HomeTabMapInfo>?>()
val tabHomeLiveData: MutableLiveData<List<HomeTabMapInfo>?> = _tabHomeLiveData
private val _tabHomeLiveData = MutableLiveData<ListResult<HomeRoomInfo>?>()
val tabHomeLiveData: MutableLiveData<ListResult<HomeRoomInfo>?> = _tabHomeLiveData
private val _bannerLiveData = MutableLiveData<List<BannerInfo>?>()
val bannerLiveData: MutableLiveData<List<BannerInfo>?> = _bannerLiveData
@@ -47,6 +47,8 @@ class HomeViewModel : BaseViewModel() {
private val _tagLiveData = MutableLiveData<List<HomeTagInfo>>()
val tagLiveData: LiveData<List<HomeTagInfo>> = _tagLiveData
val homeTagLiveData: MutableLiveData<List<HomeTagInfo>> = MutableLiveData<List<HomeTagInfo>>()
private val _emptyLiveData = MutableLiveData<Boolean>()
val emptyLiveData: LiveData<Boolean> = _emptyLiveData
@@ -62,13 +64,14 @@ class HomeViewModel : BaseViewModel() {
private val _newFriendLiveData = MutableLiveData<ListResult<UserInfo>>()
val newFriendLiveData: LiveData<ListResult<UserInfo>> = _newFriendLiveData
fun getHomeTabName() {
fun getHomeTabName(tabId: Int, pageNum: Int) {
safeLaunch(
onError = {
_tabHomeLiveData.value = null
_tabHomeLiveData.value = ListResult.failed(pageNum)
},
block = {
_tabHomeLiveData.value = HomeModel.getHomeTabHome()
val result = HomeModel.getHomeTabHome(tabId, pageNum, 20)
_tabHomeLiveData.value = ListResult.success(result, pageNum)
}
)
}
@@ -122,6 +125,12 @@ class HomeViewModel : BaseViewModel() {
)
}
fun getHomeTagInfo() {
safeLaunch {
homeTagLiveData.value = HomeModel.getNewHomeTag()
}
}
fun getTagInfo() {
safeLaunch {
_tagLiveData.value = HomeModel.getHomeTag()

View File

@@ -1,95 +0,0 @@
package com.yizhuan.erban.home.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.netease.nim.uikit.support.glide.GlideApp;
import com.yizhuan.erban.R;
import com.yizhuan.erban.avroom.firstcharge.FirstChargeDialog;
import com.yizhuan.erban.shipantics.PullRadishActivity;
import com.yizhuan.erban.treasure_box.widget.GoldBoxHelper;
import com.yizhuan.erban.treasurefairy.HomeFairyActivity;
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
import com.yizhuan.erban.ui.widget.rollviewpager.adapter.StaticPagerAdapter;
import com.yizhuan.erban.utils.CommonJumpHelper;
import com.yizhuan.xchat_android_core.home.bean.BannerInfo;
import com.yizhuan.xchat_android_core.room.model.AvRoomModel;
import com.yizhuan.xchat_android_library.utils.config.BasicConfig;
import java.util.List;
public class RoomActAdapter extends StaticPagerAdapter {
private Context mContext;
private List<BannerInfo> data;
private RoomActClickListener listener;
public RoomActAdapter(Context context, List<BannerInfo> data) {
this.data = data;
this.mContext = context;
}
@Override
public View getView(ViewGroup container, int position) {
View view = LayoutInflater.from(mContext).inflate(R.layout.item_room_act, container, false);
ImageView ivCover = view.findViewById(R.id.iv_cover);
BannerInfo bannerInfo = data.get(position);
String actId = String.valueOf(bannerInfo.getBannerId());
ivCover.setScaleType(ImageView.ScaleType.CENTER_CROP);
if (bannerInfo.isFairy()) {
ivCover.setImageResource(R.drawable.ic_fairy_entrance);
} else if (bannerInfo.isFirstCharge()) {
ivCover.setImageResource(R.drawable.ic_first_charge_enter);
} else if (bannerInfo.isBox()) {
GlideApp.with(BasicConfig.INSTANCE.getAppContext())
.load(GoldBoxHelper.getBoxIcon())
.error(R.drawable.icon_room_treasure_box)
.into(ivCover);
} else if (bannerInfo.isRadish()) {
ivCover.setImageResource(R.drawable.ic_radish_entrance);
} else {
ImageLoadUtils.loadImage(mContext, bannerInfo.getBannerPic(), ivCover, R.drawable.default_cover);
}
ivCover.setOnClickListener(v -> {
if (bannerInfo.isFairy()) {
HomeFairyActivity.start(mContext);
} else if (bannerInfo.isFirstCharge()) {
FirstChargeDialog.start(mContext);
} else if (bannerInfo.isBox()) {
GoldBoxHelper.handleBoxClick(mContext);
} else if (bannerInfo.isRadish()) {
PullRadishActivity.start(mContext);
} else {
AvRoomModel.get().activityClickLog("2", actId).subscribe();
if (bannerInfo.getSkipType() == 3 && bannerInfo.getShowType() != 1) {
if (listener != null) {
listener.onWebClick(bannerInfo.getSkipUri());
}
} else {
CommonJumpHelper.bannerJump(mContext, bannerInfo);
}
}
});
return view;
}
@Override
public int getCount() {
if (data != null) {
return data.size();
} else {
return 0;
}
}
public void setRoomActClickListener(RoomActClickListener listener) {
this.listener = listener;
}
public interface RoomActClickListener {
void onWebClick(String url);
}
}

View File

@@ -87,10 +87,6 @@ class RoomNewFriendsAdapter :
}
}
helper.getView<View>(R.id.iv_avatar).setOnClickListener {
UserInfoActivity.Companion.start(mContext, item.uid)
}
val tvNickname = helper.getView<TextView>(R.id.tv_nickname)
tvNickname.text = item.nick

View File

@@ -17,6 +17,7 @@ import com.yizhuan.erban.home.HomeViewModel
import com.yizhuan.erban.home.adapter.HomeChatAdapter
import com.yizhuan.erban.home.adapter.RoomNewFriendsAdapter
import com.yizhuan.erban.home.helper.OpenRoomHelper
import com.yizhuan.erban.ui.user.activity.UserInfoActivity
import com.yizhuan.erban.ui.utils.RVDelegate
import com.yizhuan.xchat_android_core.home.bean.HomeRoomInfo
import com.yizhuan.xchat_android_core.home.event.RefreshHomeDataEvent
@@ -116,6 +117,11 @@ class AccompanyFragment : BaseViewBindingFragment<FragmentAccompanyBinding>() {
private fun initHotRoomTab() {
roomNewFriendsAdapter = RoomNewFriendsAdapter()
roomNewFriendsAdapter.setOnItemClickListener { adapter, view, position ->
(adapter.getItem(position) as? UserInfo)?.let {
UserInfoActivity.Companion.start(context, it.uid)
}
}
rvDelegate = RVDelegate.Builder<UserInfo>()
.setAdapter(roomNewFriendsAdapter)
.setRecyclerView(binding.recyclerView)

View File

@@ -40,20 +40,22 @@ import com.zhpan.bannerview.BannerViewPager
class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClickListener,
MainIndicatorAdapter.OnItemSelectListener {
private val mFragments = mutableListOf<Class<out Fragment>>()
private val mTabInfoList = mutableListOf<HomeTagInfo>()
private val TAB_ID_RECOMMEND = Int.MAX_VALUE - 1
private val TAB_ID_ACCOMPANY = Int.MAX_VALUE - 2
private val tabList = mutableListOf<HomeTagInfo>()
private val tabTitleList = mutableListOf<String>()
private val homeViewModel: HomeViewModel by activityViewModels()
private var mBanner: BannerViewPager<BannerInfo>? = null
companion object {
private const val TAG = "HomeFragment"
}
override fun init() {
mBanner = view?.findViewById(R.id.banner)
initTitleTab()
initTab()
initListener()
homeViewModel.homeTagLiveData.observe(this) {
loadTabList(transformTabList(it))
}
homeViewModel.bannerLiveData.observe(this) {
it?.let {
if (ListUtils.isListEmpty(it)) {
@@ -71,7 +73,10 @@ class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClic
ReportManager.get().reportEvent(
IReportConstants.MODULE_HOMEPAGE_CLICK, mapOf(
Pair(IReportConstants.HOMEPAGE_TYPE, IReportConstants.SIX),
Pair(IReportConstants.MODULE, IReportConstants.PEKO_HOMEPAGE)
Pair(
IReportConstants.MODULE,
IReportConstants.PEKO_HOMEPAGE
)
)
)
CommonJumpHelper.bannerJump(context, it[position])
@@ -83,7 +88,7 @@ class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClic
}
homeViewModel.currentResourceLiveData.observe(this) {
it?.let {
if(it.size != 2){
if (it.size != 2) {
binding.csResource.visibility = View.GONE
return@observe
}
@@ -99,10 +104,12 @@ class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClic
it[i].resourceType == 5 -> {
CommonWebViewActivity.start(context, it[i].resourceContent)
}
i == 3 -> {
dialogManager.showProgressDialog(mContext)
homeViewModel.getHomeChatPick()
}
else -> {
dialogManager.showProgressDialog(mContext)
homeViewModel.getResourceJumpInfo(it[i].id)
@@ -131,6 +138,7 @@ class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClic
}
}
}
homeViewModel.getHomeTagInfo()
homeViewModel.getBannerInfo()
homeViewModel.getCurrentResourceInfo()
}
@@ -157,6 +165,7 @@ class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClic
DemoCache.saveAnchorCardView(1)
}
}
R.id.iv_ranking -> {
//首页_排行榜
ReportManager.get().reportEvent(
@@ -167,6 +176,7 @@ class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClic
)
CommonWebViewActivity.start(mContext, UriProvider.getRanking())
}
R.id.iv_my_room -> {
//首页_创建房间
ReportManager.get().reportEvent(
@@ -180,63 +190,100 @@ class HomeFragment : BaseViewBindingFragment<FragmentHomeBinding>(), View.OnClic
}
}
/**
* 初始化推荐
*/
private fun initTitleTab() {
mTabInfoList.add(
HomeTagInfo(
6,
ResUtil.getString(R.string.home_fragment_homefragment_04),
0
)
)
mTabInfoList.add(
HomeTagInfo(
7,
ResUtil.getString(R.string.home_fragment_homefragment_07),
0
)
)
mFragments.add(RecommendFragment::class.java)
mFragments.add(AccompanyFragment::class.java)
val commonNavigator = CommonNavigator(context)
commonNavigator.setTitleWrapContent(false)
commonNavigator.titleMargin = ScreenUtil.dip2px(2.0F)
commonNavigator.setTitleGravity(Gravity.CENTER_VERTICAL)
val magicIndicatorAdapter = MainIndicatorAdapter(context, mTabInfoList.map { it.name })
magicIndicatorAdapter.setOnItemSelectListener(this)
commonNavigator.adapter = magicIndicatorAdapter
binding.magicIndicator.navigator = commonNavigator
binding.viewPager.adapter =
object : FragmentStateAdapter(childFragmentManager, lifecycle) {
override fun createFragment(position: Int): Fragment {
return mFragments[position].newInstance()
}
override fun getItemCount(): Int {
return mFragments.size
}
}
ViewPagerHelper.bind(binding.magicIndicator, binding.viewPager)
binding.viewPager.offscreenPageLimit = 1
}
override fun onItemSelect(position: Int, view: TextView?) {
binding.viewPager.currentItem = position
//点击顶部tab上报
val map = HashMap<String, Any>(3)
map[IReportConstants.HOMEPAGE_TAB] = mTabInfoList[position].id
map[IReportConstants.HOMEPAGE_TAB] = tabList[position].id
map[IReportConstants.MODULE] = IReportConstants.PEKO_HOMEPAGE
ReportManager.get().reportEvent(IReportConstants.TAB_HOMEPAGE_CLICK, map)
}
override fun onDestroyView() {
super.onDestroyView()
mTabInfoList.clear()
mFragments.clear()
tabList.clear()
tabTitleList.clear()
}
private fun initTab() {
val commonNavigator = CommonNavigator(context)
commonNavigator.setTitleWrapContent(false)
commonNavigator.titleMargin = ScreenUtil.dip2px(2.0F)
commonNavigator.setTitleGravity(Gravity.CENTER_VERTICAL)
val magicIndicatorAdapter = MainIndicatorAdapter(context, tabTitleList)
magicIndicatorAdapter.setOnItemSelectListener(this)
commonNavigator.adapter = magicIndicatorAdapter
binding.magicIndicator.navigator = commonNavigator
binding.viewPager.adapter =
object : FragmentStateAdapter(childFragmentManager, lifecycle) {
override fun getItemId(position: Int): Long {
return tabList[position].id.toLong()
}
override fun containsItem(itemId: Long): Boolean {
return tabList.firstOrNull { it.id.toLong() == itemId } != null
}
override fun createFragment(position: Int): Fragment {
val itemId = getItemId(position)
return when (itemId) {
TAB_ID_RECOMMEND.toLong() -> {
RecommendFragment()
}
TAB_ID_ACCOMPANY.toLong() -> {
AccompanyFragment()
}
else -> {
HomeTabFragment.newInstance(itemId.toInt())
}
}
}
override fun getItemCount(): Int {
return tabList.size
}
}
ViewPagerHelper.bind(binding.magicIndicator, binding.viewPager)
loadTabList(transformTabList(emptyList()))
}
private fun transformTabList(list: List<HomeTagInfo>): List<HomeTagInfo> {
val finalList = ArrayList<HomeTagInfo>()
finalList.add(
HomeTagInfo(
TAB_ID_RECOMMEND,
ResUtil.getString(R.string.home_fragment_homefragment_04),
0
)
)
finalList.addAll(list)
finalList.add(
HomeTagInfo(
TAB_ID_ACCOMPANY,
ResUtil.getString(R.string.home_fragment_homefragment_07),
0
)
)
return finalList
}
private fun loadTabList(list: List<HomeTagInfo>) {
// 预防脏数据导致fragment复用问题
val newList = list.distinctBy {
it.id
}
val currentListId = tabList.joinToString { it.id.toString() }
val newListId = newList.joinToString { it.id.toString() }
if (currentListId == newListId) {
return
}
tabList.clear()
tabList.addAll(newList)
tabTitleList.clear()
tabTitleList.addAll(tabList.map { it.name })
binding.magicIndicator.navigator.notifyDataSetChanged()
binding.viewPager.adapter?.notifyDataSetChanged()
}
}

View File

@@ -0,0 +1,141 @@
package com.yizhuan.erban.home.fragment
import android.os.Bundle
import android.view.View
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.GridLayoutManager
import com.chad.library.adapter.base.BaseQuickAdapter
import com.yizhuan.erban.application.IReportConstants
import com.yizhuan.erban.application.ReportManager
import com.yizhuan.erban.avroom.activity.AVRoomActivity
import com.yizhuan.erban.base.BaseViewBindingFragment
import com.yizhuan.erban.common.EmptyViewHelper
import com.yizhuan.erban.databinding.FragmentRecommendBinding
import com.yizhuan.erban.home.HomeViewModel
import com.yizhuan.erban.home.adapter.HomeHotAdapter
import com.yizhuan.erban.ui.utils.RVDelegate
import com.yizhuan.xchat_android_core.home.bean.HomeRoomInfo
import com.yizhuan.xchat_android_core.home.event.RefreshHomeDataEvent
import com.yizhuan.xchat_android_core.room.event.RoomShieldEvent
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
/**
* Peko首页
*/
class HomeTabFragment : BaseViewBindingFragment<FragmentRecommendBinding>() {
private lateinit var roomHotAdapter: HomeHotAdapter
private lateinit var rvDelegate: RVDelegate<HomeRoomInfo>
private val homeViewModel: HomeViewModel by viewModels()
//是否需要刷新接口进行屏蔽房间操作
private var isShield = false
private var pageNum = 1
private var tabId: Int? = null
companion object {
fun newInstance(tabId: Int): HomeTabFragment {
return HomeTabFragment().apply {
arguments = Bundle().apply {
putInt("tabId", tabId)
}
}
}
}
override fun init() {
tabId = arguments?.getInt("tabId")
initRefreshView()
initHotRoomTab()
}
private fun initRefreshView() {
binding.refreshLayout.setOnRefreshListener {
loadData(true)
}
binding.refreshLayout.isEnableLoadmore = false
binding.refreshLayout.isEnableOverScrollBounce = false
}
private fun initHotRoomTab() {
roomHotAdapter = HomeHotAdapter()
roomHotAdapter.onItemClickListener =
BaseQuickAdapter.OnItemClickListener { _: BaseQuickAdapter<*, *>?, _: View?, position: Int ->
val homePlayInfo: HomeRoomInfo? = roomHotAdapter.getItem(position)
if (homePlayInfo != null) {
//首页_房间派对
ReportManager.get().reportEvent(
IReportConstants.MODULE_HOMEPAGE_CLICK, mapOf(
Pair(IReportConstants.HOMEPAGE_TYPE, IReportConstants.TEN),
Pair(IReportConstants.MODULE, IReportConstants.PEKO_HOMEPAGE)
)
)
AVRoomActivity.start(mContext, homePlayInfo.uid)
}
}
rvDelegate = RVDelegate.Builder<HomeRoomInfo>()
.setPageSize(20)
.setAdapter(roomHotAdapter)
.setRecyclerView(binding.mRecyclerRoom)
.setEmptyView(EmptyViewHelper.createEmptyTextViewHeight(context, "暂无數據"))
.setLayoutManager(GridLayoutManager(mContext, 2))
.build()
roomHotAdapter.setOnLoadMoreListener({
loadData(false)
}, binding.mRecyclerRoom)
homeViewModel.tabHomeLiveData.observe(this) {
binding.refreshLayout.finishRefresh()
rvDelegate.loadData(it)
}
}
override fun onLazyLoad() {
super.onLazyLoad()
loadData(true)
}
override fun onResume() {
super.onResume()
if (isShield) {
loadData(true)
isShield = false
}
}
private fun loadData(isRefresh: Boolean) {
if (isRefresh) {
pageNum = 1
} else {
pageNum++
}
homeViewModel.getHomeTabName(tabId ?: 0, pageNum)
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun onRefreshHomeDataEvent(event: RefreshHomeDataEvent?) {
if (isResumed) {
loadData(true)
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
EventBus.getDefault().register(this)
}
override fun onDestroyView() {
super.onDestroyView()
EventBus.getDefault().unregister(this)
}
@Subscribe(threadMode = ThreadMode.MAIN)
fun onRoomShieldEvent(event: RoomShieldEvent?) {
isShield = true
}
}

View File

@@ -533,6 +533,42 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
.noticeRoomEvent(message, RoomEvent.LUCKY_SEA_GIFT_SERVER_NOTIFY)
}
CustomAttachment.CUSTOM_MSG_CRAZY_ZOO -> if (baseProtocol.second == CustomAttachment.CUSTOM_MSG_CRAZY_ZOO_SUB_ALL_ROOM) {
val attachment = RoomLuckySeaAttachment(
CustomAttachment.CUSTOM_MSG_CRAZY_ZOO,
CustomAttachment.CUSTOM_MSG_CRAZY_ZOO_SUB_ALL_ROOM
)
attachment.setRoomLuckySeaMsgBean(
JSON.parseObject(
baseProtocol.data.toString(),
RoomLuckySeaMsgBean::class.java
)
)
val message = ChatRoomMessageBuilder.createChatRoomCustomMessage(
AvRoomDataManager.get().roomId.toString(),
attachment
)
IMNetEaseManager.get()
.noticeRoomEvent(message, RoomEvent.CRAZY_ZOO_ALL_ROOM_NOTIFY)
}
CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY -> if (baseProtocol.second == CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY_ALL) {
val attachment = RoomTemplateNotifyAttachment(
CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY,
CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY_ALL
)
attachment.msgBean = JSON.parseObject(
baseProtocol.data.toString(),
RoomTemplateNotifyMsgBean::class.java
)
val message = ChatRoomMessageBuilder.createChatRoomCustomMessage(
AvRoomDataManager.get().roomId.toString(),
attachment
)
IMNetEaseManager.get()
.noticeRoomEvent(message, RoomEvent.TEMPLATE_NOTIFY)
}
CustomAttachment.CUSTOM_MSG_LUCKY_GIFT -> if (baseProtocol.second == CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY || baseProtocol.second == CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL) {
val attachment =
RoomReceivedLuckyGiftAttachment(CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY)

View File

@@ -9,6 +9,7 @@ import androidx.databinding.ObservableField;
import com.yizhuan.erban.R;
import com.yizhuan.erban.vip.util.VipHelper;
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo;
import com.yizhuan.xchat_android_core.gift.bean.GiftType;
import com.yizhuan.xchat_android_core.gift.bean.SimpleVipInfo;
import com.yizhuan.xchat_android_library.bindinglist.BaseItem;
import com.yizhuan.xchat_android_library.utils.TimeUtils;
@@ -65,6 +66,11 @@ public class GiftInfoVm extends BaseItem<GiftInfo> {
*/
public boolean isFreeGift;
/**
* 是否超级幸运礼物
*/
public boolean isSuperLuckyGift;
public GiftInfoVm(Context context, GiftInfo data, boolean select, boolean isKnap) {
super(context, data);
this.isSelect.set(select);
@@ -100,6 +106,7 @@ public class GiftInfoVm extends BaseItem<GiftInfo> {
if (data.getConsumeType() == GiftInfo.CONSUME_TYPE_FREE_GIFT) {
isFreeGift = true;
}
isSuperLuckyGift = (data.getGiftType() == GiftType.GIFT_TYPE_SUPER_LUCKY);
SimpleVipInfo vipInfo = data.getGiftVipInfo();
isLocked = vipInfo != null && VipHelper.getMyVipLevel() < vipInfo.getVipLevel();
vipIcon = vipInfo == null ? "" : vipInfo.getVipIcon();

View File

@@ -53,6 +53,7 @@ import com.netease.nimlib.sdk.robot.model.RobotMsgType;
import com.tbruyelle.rxpermissions2.RxPermissions;
import com.yizhuan.erban.R;
import com.yizhuan.erban.common.widget.OriginalDrawStatusClickSpan;
import com.yizhuan.erban.common.widget.dialog.DialogManager;
import com.yizhuan.erban.ui.im.GreetPresenter;
import com.yizhuan.erban.ui.im.MessageListPanelEx;
import com.yizhuan.erban.ui.im.chat.MVHChatterBoxStart;
@@ -104,6 +105,8 @@ public class MessageFragment extends TFragment implements ModuleProxy, MessageLi
protected AitManager aitManager;
protected String recordId = "";
private DialogManager dialogManager;
/**
* 消息接收观察者
*/
@@ -189,6 +192,10 @@ public class MessageFragment extends TFragment implements ModuleProxy, MessageLi
if (aitManager != null) {
aitManager.reset();
}
if (dialogManager != null) {
dialogManager.dismissDialog();
}
dialogManager = null;
}
/**
@@ -333,7 +340,37 @@ public class MessageFragment extends TFragment implements ModuleProxy, MessageLi
if (!isAllowSendMessage(message)) {
return false;
}
MsgTypeEnum msgTypeEnum = message.getMsgType();
String content = null;
if (msgTypeEnum == MsgTypeEnum.text) {
content = message.getContent();
} else if (msgTypeEnum == MsgTypeEnum.audio) {
content = "";
} else if (msgTypeEnum == MsgTypeEnum.image) {
content = "";
}
if (content != null) {
showLoading();
Disposable disposable = IMCustomModel.get().privateChatCheck(message.getContent(), sessionId).subscribe(((privateChatLimitInfo, throwable) -> {
if (isDestroyed()) {
return;
}
dismissLoading();
if (throwable != null) {
throwable.printStackTrace();
SingleToastUtil.showToast(throwable.getMessage());
} else {
sendMessageImpl(message);
}
}));
compositeDisposable.add(disposable);
} else {
sendMessageImpl(message);
}
return true;
}
private void sendMessageImpl(IMMessage message) {
appendTeamMemberPush(message);
message = changeToRobotMsg(message);
Map<String, Object> payload = new HashMap<>();
@@ -357,7 +394,6 @@ public class MessageFragment extends TFragment implements ModuleProxy, MessageLi
NIMClient.getService(MsgService.class).sendMessage(message, false).setCallback(new RequestCallback<Void>() {
@Override
public void onSuccess(Void param) {
}
@Override
@@ -376,7 +412,6 @@ public class MessageFragment extends TFragment implements ModuleProxy, MessageLi
if (aitManager != null) {
aitManager.reset();
}
return true;
}
/**
@@ -599,7 +634,10 @@ public class MessageFragment extends TFragment implements ModuleProxy, MessageLi
tvChatLimit.setVisibility(View.GONE);
inputPanel.setLimitLevel(true, "");
} else {
IMCustomModel.get().getPrivateChatLimit(sessionId).subscribe(((privateChatLimitInfo, throwable) -> {
Disposable disposable = IMCustomModel.get().getPrivateChatLimit(sessionId).subscribe(((privateChatLimitInfo, throwable) -> {
if (isDestroyed()) {
return;
}
if (throwable != null) {
throwable.printStackTrace();
} else {
@@ -642,6 +680,7 @@ public class MessageFragment extends TFragment implements ModuleProxy, MessageLi
tvChatLimit.setVisibility(isChat ? View.GONE : View.VISIBLE);
}
}));
compositeDisposable.add(disposable);
}
}
}
@@ -685,4 +724,19 @@ public class MessageFragment extends TFragment implements ModuleProxy, MessageLi
public void setCurrentLevel(int currentLevel) {
}
private void showLoading(){
if (isDestroyed()) {
return;
}
if (dialogManager == null) {
dialogManager = new DialogManager(getContext());
}
dialogManager.showProgressDialog(getContext());
}
private void dismissLoading(){
if (dialogManager != null) {
dialogManager.dismissDialog();
}
}
}

View File

@@ -1,5 +1,6 @@
package com.yizhuan.erban.ui.im.model;
import com.google.gson.JsonElement;
import com.yizhuan.xchat_android_core.bean.PrivateChatLimitInfo;
import com.yizhuan.xchat_android_core.bean.response.ServiceResult;
import com.yizhuan.xchat_android_core.manager.BaseMvpModel;
@@ -31,6 +32,12 @@ public class IMCustomModel extends BaseMvpModel {
.compose(RxHelper.handleSchedulers());
}
public Single<String> privateChatCheck(String content, String receiverUid) {
return api.privateChatCheck(content, receiverUid)
.compose(RxHelper.handleIgnoreData())
.compose(RxHelper.handleSchedulers());
}
private interface Api {
/**
* 获取是否可以发送私聊
@@ -38,5 +45,11 @@ public class IMCustomModel extends BaseMvpModel {
*/
@GET("/privateChat/limit")
Single<ServiceResult<PrivateChatLimitInfo>> getPrivateChatLimit(@Query("receiverUid") String receiverUid);
/**
* 私聊发送消息时检测
*/
@GET("/privateChat/check")
Single<ServiceResult<JsonElement>> privateChatCheck(@Query("content") String content, @Query("toUid") String toUid);
}
}

View File

@@ -0,0 +1,196 @@
package com.yizhuan.erban.ui.invite
import android.Manifest
import android.app.Activity
import android.content.Context
import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Build
import android.view.LayoutInflater
import android.view.View
import androidx.core.view.drawToBitmap
import androidx.core.view.isVisible
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.LifecycleCoroutineScope
import androidx.lifecycle.lifecycleScope
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.transition.Transition
import com.chuhai.utils.ktx.saveToAlbum
import com.netease.nim.uikit.support.glide.GlideApp
import com.tbruyelle.rxpermissions2.RxPermissions
import com.yizhuan.erban.R
import com.yizhuan.erban.common.widget.dialog.DialogManager
import com.yizhuan.erban.databinding.ShareInviteImageLayoutBinding
import com.yizhuan.erban.ui.widget.magicindicator.buildins.UIUtil
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.suspendCancellableCoroutine
import kotlinx.coroutines.withContext
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
import kotlin.jvm.Throws
/**
* Created by Max on 2024/3/11 15:57
* Desc:邀请图片
**/
class InviteImageHelper {
fun saveToAlbum(
activity: FragmentActivity,
rxPermissions: RxPermissions,
data: ShareInviteInfo,
success: (() -> Unit)? = null
) {
checkStoragePermissions(rxPermissions) {
if (it) {
saveToAlbumImpl(activity, activity.lifecycleScope, data, success)
} else {
SingleToastUtil.showToast(activity.getString(R.string.ask_again))
}
}
}
private fun checkStoragePermissions(rxPermissions: RxPermissions, call: (Boolean) -> Unit) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
call.invoke(true)
} else {
val permissions = arrayOf(
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE
)
val d = rxPermissions.request(*permissions)?.subscribe({
if (it) {
call.invoke(true)
} else {
call.invoke(false)
}
}, {
it.printStackTrace()
})
}
}
private fun saveToAlbumImpl(
context: Activity,
lifecycleCoroutineScope: LifecycleCoroutineScope,
data: ShareInviteInfo,
success: (() -> Unit)? = null
) {
lifecycleCoroutineScope.launch {
val dialogManager = DialogManager(context)
dialogManager.showProgressDialog(context, false)
try {
val result = saveToAlbum(context, data)
if (result) {
SingleToastUtil.showToast(R.string.community_photo_bigphotoactivity_05)
success?.invoke()
} else {
SingleToastUtil.showToast(R.string.community_photo_bigphotoactivity_06)
}
} catch (e: Exception) {
e.printStackTrace()
SingleToastUtil.showToast(e.message)
} finally {
dialogManager.dismissDialog()
}
}
}
@Throws
suspend fun saveToAlbum(context: Context, data: ShareInviteInfo): Boolean {
val bitmap = generateBitmap(context, data)
return saveToAlbum(context, bitmap)
}
@Throws
suspend fun generateBitmap(context: Context, data: ShareInviteInfo): Bitmap {
val qrcodeUrl = data.qrCodeUrl
if (qrcodeUrl.isNullOrEmpty()) {
throw IllegalArgumentException(context.getString(R.string.utils_net_beanobserver_05))
}
val bitmap: Bitmap
withContext(Dispatchers.IO) {
val qrCode = loadQrcode(context, data.qrCodeUrl)
data.qrcodeDrawable = qrCode
val binding = createView(context)
withContext(Dispatchers.Main) {
bindView(binding, data)
}
bitmap = viewToBitmap(binding.root, UIUtil.dip2px(context, 375.0))
}
return bitmap
}
suspend fun saveToAlbum(context: Context, bitmap: Bitmap): Boolean {
val uri: Uri?
withContext(Dispatchers.IO) {
val fileName = "piko_invite_${System.currentTimeMillis()}.jpg"
uri = bitmap.saveToAlbum(
context = context,
fileName = fileName,
relativePath = null,
quality = 90
)
}
return uri != null
}
private fun bindView(
binding: ShareInviteImageLayoutBinding,
data: ShareInviteInfo
) {
binding.ivQrcode.setImageDrawable(data.qrcodeDrawable)
if (data.text.isNullOrEmpty()) {
binding.tvQrcodeTips.isVisible = false
} else {
binding.tvQrcodeTips.isVisible = true
binding.tvQrcodeTips.text = data.text
}
binding.tvCode.text =
binding.tvCode.context.getString(R.string.invite_code) + data.invitationCode
}
private suspend fun loadQrcode(context: Context, url: String): Drawable? {
return suspendCancellableCoroutine {
val target = GlideApp.with(context.applicationContext).load(url)
.into(object : CustomTarget<Drawable>() {
override fun onResourceReady(
resource: Drawable,
transition: Transition<in Drawable>?
) {
it.resume(resource)
}
override fun onLoadCleared(placeholder: Drawable?) {
}
override fun onLoadFailed(errorDrawable: Drawable?) {
super.onLoadFailed(errorDrawable)
it.resumeWithException(Exception(context.getString(R.string.utils_net_beanobserver_03)))
}
})
it.invokeOnCancellation {
it?.printStackTrace()
GlideApp.with(context.applicationContext).clear(target)
}
}
}
private fun createView(context: Context): ShareInviteImageLayoutBinding {
return ShareInviteImageLayoutBinding.inflate(LayoutInflater.from(context))
}
private fun viewToBitmap(view: View, width: Int): Bitmap {
val widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY)
val heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
view.measure(widthMeasureSpec, heightMeasureSpec)
val measureWidth = view.measuredWidth
val measureHeight = view.measuredHeight
view.layout(0, 0, measureWidth, measureHeight)
return view.drawToBitmap()
}
}

View File

@@ -0,0 +1,134 @@
package com.yizhuan.erban.ui.invite
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import cn.sharesdk.facebook.Facebook
import cn.sharesdk.framework.Platform
import cn.sharesdk.framework.PlatformActionListener
import cn.sharesdk.line.Line
import com.chuhai.utils.ktx.singleClick
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.tbruyelle.rxpermissions2.RxPermissions
import com.yizhuan.erban.R
import com.yizhuan.erban.databinding.ShareInviteDialogBinding
import com.yizhuan.xchat_android_library.utils.ResUtil
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
/**
* Created by Max on 2024/3/11 15:29
* Desc:分享邀请
**/
class ShareInviteDialog(val data: ShareInviteInfo) : BottomSheetDialogFragment() {
private var binding: ShareInviteDialogBinding? = null
private var rxPermissions: RxPermissions? = null
private val inviteImageHelper = InviteImageHelper()
override fun onAttach(context: Context) {
super.onAttach(context)
rxPermissions = RxPermissions(this)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initEvent()
}
private fun initEvent() {
binding?.let { binding ->
binding.tvCancel.singleClick {
dismissAllowingStateLoss()
}
binding.tvSaveToAlbum.singleClick {
rxPermissions?.let {
inviteImageHelper.saveToAlbum(requireActivity(), it, data) {
dismissAllowingStateLoss()
}
}
}
binding.tvShareLink.singleClick {
copyLink(data.toUrl ?: "")
}
binding.tvLine.singleClick {
share(Line(), data)
}
binding.tvFacebook.singleClick {
share(Facebook(), data)
}
}
}
private fun copyLink(data: String) {
try {
val cm =
requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager
cm?.setPrimaryClip(ClipData.newPlainText("text", data))
SingleToastUtil.showToast(R.string.have_copy)
dismissAllowingStateLoss()
} catch (e: Exception) {
e.printStackTrace()
SingleToastUtil.showToast(R.string.avroom_activity_roomblacklistactivity_015)
}
}
private fun share(platform: Platform, data: ShareInviteInfo) {
val url = data.toUrl
val sp = Platform.ShareParams()
sp.imageUrl = data.shareImg
when (platform.name) {
Facebook.NAME -> {
sp.title = data.shareTitle
sp.text = data.shareText
sp.url = url
sp.shareType = Platform.SHARE_WEBPAGE
}
Line.NAME -> {
sp.text = "${data.shareTitle}[$url]"
}
}
platform.platformActionListener = object : PlatformActionListener {
override fun onComplete(platform: Platform, i: Int, hashMap: HashMap<String, Any>) {
SingleToastUtil.showToast(R.string.xchat_android_core_share_sharemodel_01)
dismissAllowingStateLoss()
}
override fun onError(platform: Platform, i: Int, throwable: Throwable) {
val errorMsg: String
if (throwable.message?.contains("not installed") == true) {
errorMsg =
ResUtil.getString(R.string.not_install_app)
} else {
errorMsg =
ResUtil.getString(R.string.xchat_android_core_share_sharemodel_02)
}
SingleToastUtil.showToast(errorMsg)
}
override fun onCancel(platform: Platform, i: Int) {
SingleToastUtil.showToast(R.string.xchat_android_core_share_sharemodel_03)
}
}
platform.share(sp)
}
override fun getTheme(): Int {
return R.style.ErbanBottomSheetDialog
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = ShareInviteDialogBinding.inflate(inflater)
return binding?.root
}
}

View File

@@ -0,0 +1,31 @@
package com.yizhuan.erban.ui.invite
import android.graphics.drawable.Drawable
import androidx.annotation.Keep
import java.io.Serializable
/**
* Created by Max on 2024/3/11 18:56
* Desc:分享邀请相关信息
**/
@Keep
data class ShareInviteInfo(
// 二维码图片
val qrCodeUrl: String? = null,
// 邀请码
val invitationCode: String? = null,
// 页面文案
val text: String? = null,
// 分享文案
val shareText: String? = null,
// 分享图片
val shareImg: String? = null,
// 分享标题
val shareTitle: String? = null,
// 跳转网页地址
val toUrl: String? = null,
// 1分享2保存
val type: Int? = null,
@Transient
var qrcodeDrawable: Drawable? = null
) : Serializable

View File

@@ -3,17 +3,19 @@ package com.yizhuan.erban.ui.login
import android.app.Activity
import android.content.Intent
import android.view.View
import androidx.lifecycle.lifecycleScope
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.chuhai.utils.UiUtils
import com.chuhai.utils.ktx.getColorById
import com.netease.nim.uikit.StatusBarUtil
import com.trello.rxlifecycle3.android.ActivityEvent
import com.yizhuan.erban.R
import com.yizhuan.erban.base.BaseViewBindingActivity
import com.yizhuan.erban.databinding.ActivityAreaCodeBinding
import com.yizhuan.xchat_android_core.auth.AuthModel
import com.yizhuan.xchat_android_core.auth.bean.AreaInfoBean
import com.yizhuan.xchat_android_core.utils.Logger
import com.yizhuan.xchat_android_core.utils.net.BeanObserver
import com.yizhuan.erban.ui.widget.SideBarView
import com.yizhuan.xchat_android_core.region.RegionHelper
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
/**
* 区号
@@ -22,7 +24,9 @@ import com.yizhuan.xchat_android_core.utils.net.BeanObserver
*/
class AreaCodeActivity : BaseViewBindingActivity<ActivityAreaCodeBinding>() {
private val mCountries = ArrayList<AreaInfoBean>()
private val regionRepository = RegionHelper()
private val adapter = RegionListAdapter()
companion object {
const val COUNTRY_NUMBER = "country_number"
@@ -39,55 +43,51 @@ class AreaCodeActivity : BaseViewBindingActivity<ActivityAreaCodeBinding>() {
override fun init() {
initTitleBar(getString(R.string.select_area_code))
initCountryData()
initListView()
initSideBar()
loadData()
}
private fun initCountryData() {
val countryList = resources.getStringArray(R.array.country_code_list_ch)
for (s in countryList) {
val country = s.split("*").toTypedArray()
val countryName = country[0]
val countryNumber = country[1]
val c = AreaInfoBean(
name = countryName,
phoneAreaCode = countryNumber
)
mCountries.add(c)
private fun initSideBar() {
binding.sideBarView.setTextColor(context.getColorById(R.color.color_5caaff))
binding.sideBarView.setTextSize(UiUtils.dip2px(12f).toFloat())
binding.sideBarView.setListener(object : SideBarView.Listener {
override fun onSideBarScroll(word: String) {
val index = adapter.data.indexOfFirst {
it.itemType == RegionListAdapter.ITEM_TYPE_GROUP && it.groupName?.toString() == word
}
if (index >= 0) {
binding.mRecyclerView.scrollToPosition(index)
}
}
override fun onSideBarScrollEnd() {
}
})
}
private fun loadData() {
lifecycleScope.launch {
val list = regionRepository.getRegionSelectorList(RegionListAdapter.ITEM_TYPE_GROUP)
withContext(Dispatchers.Main) {
adapter.setNewData(list)
}
}
}
private fun initListView() {
val mAdapter = object :
BaseQuickAdapter<AreaInfoBean, BaseViewHolder>(R.layout.item_country) {
override fun convert(helper: BaseViewHolder, item: AreaInfoBean) {
helper.setText(R.id.tv_name, item.name)
helper.setText(R.id.tv_country_code, "+${item.phoneAreaCode}")
}
}
binding.mRecyclerView.adapter = mAdapter
mAdapter.setNewData(mCountries)
binding.mRecyclerView.adapter = adapter
//返回国家
mAdapter.setOnItemClickListener { adapter: BaseQuickAdapter<*, *>?, view: View?, position: Int ->
val country = mAdapter.data[position]
adapter.setOnItemClickListener { adapter: BaseQuickAdapter<*, *>?, view: View?, position: Int ->
val region = this.adapter.getItem(position)
if (region?.code.isNullOrEmpty()) {
return@setOnItemClickListener
}
val intent = Intent()
intent.putExtra(COUNTRY_NUMBER, "+${country.phoneAreaCode}")
intent.putExtra(COUNTRY_NUMBER, region?.fullCode)
setResult(RESULT_OK, intent)
finish()
}
AuthModel.get()
.areaCodeList
.compose(bindUntilEvent(ActivityEvent.DESTROY))
.subscribe(object : BeanObserver<List<AreaInfoBean>>() {
override fun onErrorMsg(error: String) {
Logger.error("areaCode", error)
}
override fun onSuccess(list: List<AreaInfoBean>) {
mAdapter.setNewData(list)
}
})
}
override fun needSteepStateBar() = true
@@ -97,5 +97,4 @@ class AreaCodeActivity : BaseViewBindingActivity<ActivityAreaCodeBinding>() {
StatusBarUtil.transparencyBar(this)
StatusBarUtil.StatusBarLightMode(this)
}
}

View File

@@ -16,9 +16,9 @@ import com.trello.rxlifecycle3.android.ActivityEvent
import com.yizhuan.erban.R
import com.yizhuan.erban.base.BaseViewBindingActivity
import com.yizhuan.erban.databinding.ActivityBindPhoneBinding
import com.yizhuan.erban.ui.login.BindPhoneActivity
import com.yizhuan.xchat_android_core.auth.AuthModel
import com.yizhuan.xchat_android_core.code.CodeType
import com.yizhuan.xchat_android_core.region.RegionHelper
import com.yizhuan.xchat_android_core.user.UserModel
import com.yizhuan.xchat_android_core.user.bean.UserInfo
import com.yizhuan.xchat_android_library.utils.NetworkUtils
@@ -50,6 +50,7 @@ class BindPhoneActivity : BaseViewBindingActivity<ActivityBindPhoneBinding>(),
override fun init() {
initTitleBar(getString(R.string.text_bind_phone))
initListener()
RegionHelper().loadRecommendRegion(lifecycle, binding.tvAreaCode)
}
private fun initListener() {

View File

@@ -35,7 +35,7 @@ import com.yizhuan.xchat_android_core.code.CodeType;
import com.yizhuan.xchat_android_library.common.SpConstants;
import com.yizhuan.xchat_android_library.common.util.SPUtils;
import com.yizhuan.xchat_android_library.utils.TextWatcherWrapper;
import com.yizhuan.xchat_android_core.region.RegionHelper;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
@@ -90,6 +90,7 @@ public class LoginPasswordActivity extends BaseActivity {
setContentView(R.layout.activity_login_password);
EventBus.getDefault().register(this);
initView();
new RegionHelper().loadRecommendRegion(getLifecycle(), tvAreaCode);
}
private void checkInput() {

View File

@@ -16,6 +16,7 @@ import com.yizhuan.erban.databinding.ActivityLoginPhoneBinding
import com.yizhuan.xchat_android_core.auth.AuthModel
import com.yizhuan.xchat_android_core.auth.event.LoginEvent
import com.yizhuan.xchat_android_core.code.CodeType
import com.yizhuan.xchat_android_core.region.RegionHelper
import io.reactivex.SingleObserver
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
@@ -43,6 +44,7 @@ class LoginPhoneActivity : BaseViewBindingActivity<ActivityLoginPhoneBinding>(),
override fun init() {
EventBus.getDefault().register(this)
initListener()
RegionHelper().loadRecommendRegion(lifecycle, binding.tvAreaCode)
}
private fun initListener() {

View File

@@ -0,0 +1,32 @@
package com.yizhuan.erban.ui.login
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.yizhuan.erban.R
import com.yizhuan.xchat_android_core.region.bean.RegionBean
/**
* Created by Max on 2023/12/7 19:34
* Desc:
**/
class RegionListAdapter() :
BaseMultiItemQuickAdapter<RegionBean, BaseViewHolder>(ArrayList<RegionBean>()) {
companion object {
const val ITEM_TYPE_GROUP = 1
}
init {
addItemType(0, R.layout.region_item_def)
addItemType(ITEM_TYPE_GROUP, R.layout.region_item_group)
}
override fun convert(helper: BaseViewHolder, item: RegionBean?) {
if (helper.itemViewType == ITEM_TYPE_GROUP) {
helper.setText(R.id.tv_group, item?.groupName?.toString() ?: "")
}
helper.setText(R.id.tv_name, item?.name ?: "")
helper.setText(R.id.tv_country_code, "+${item?.code}")
}
}

View File

@@ -1,6 +1,7 @@
package com.yizhuan.erban.ui.search;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
@@ -15,6 +16,7 @@ import com.yizhuan.erban.R;
import com.yizhuan.erban.avroom.activity.AVRoomActivity;
import com.yizhuan.erban.friend.action.AbstractSelectFriendAction;
import com.yizhuan.erban.ui.user.activity.UserInfoActivity;
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
import com.yizhuan.erban.ui.widget.NobleAvatarView;
import com.yizhuan.erban.utils.RegexUtil;
import com.yizhuan.xchat_android_core.room.bean.SearchRoomInfo;
@@ -112,16 +114,17 @@ public class SearchAdapter extends BaseQuickAdapter<SearchRoomInfo, SearchAdapte
holder.mNobleAvatarView.setData(item.getAvatar(), item.nobleUsers);
holder.erbanNo.setText(context.getString(R.string.me_user_id, item.getErbanNo()));
if (item.getGender() == 1) {
holder.mIvSex.setVisibility(View.VISIBLE);
holder.mIvSex.setImageResource(R.drawable.ic_gender_male);
} else if (item.getGender() == 2) {
holder.mIvSex.setVisibility(View.VISIBLE);
holder.mIvSex.setImageResource(R.drawable.ic_gender_female);
} else {
holder.mIvSex.setVisibility(View.GONE);
holder.wealthLevelView.setVisibility(View.GONE);
if (item.getUserLevelVo() != null && !TextUtils.isEmpty(item.getUserLevelVo().getExperUrl())) {
holder.wealthLevelView.setVisibility(View.VISIBLE);
ImageLoadUtils.loadImage(mContext, item.getUserLevelVo().getExperUrl(), holder.wealthLevelView);
}
holder.charmLevelView.setVisibility(View.GONE);
if (item.getUserLevelVo() != null && !TextUtils.isEmpty(item.getUserLevelVo().getCharmUrl())) {
holder.charmLevelView.setVisibility(View.VISIBLE);
ImageLoadUtils.loadImage(mContext, item.getUserLevelVo().getCharmUrl(), holder.charmLevelView);
}
}
static class ViewHolder extends BaseViewHolder {
@@ -132,7 +135,8 @@ public class SearchAdapter extends BaseQuickAdapter<SearchRoomInfo, SearchAdapte
private ImageView ivLive;
RelativeLayout container;
private NobleAvatarView mNobleAvatarView;
private ImageView mIvSex;
private ImageView wealthLevelView;
private ImageView charmLevelView;
private SuperTextView stvOp;
public ViewHolder(View itemView) {
@@ -142,7 +146,8 @@ public class SearchAdapter extends BaseQuickAdapter<SearchRoomInfo, SearchAdapte
erbanNo = itemView.findViewById(R.id.erban_no);
container = itemView.findViewById(R.id.container);
mNobleAvatarView = itemView.findViewById(R.id.noble_avatar_view);
mIvSex = itemView.findViewById(R.id.sex);
wealthLevelView = itemView.findViewById(R.id.iv_user_level);
charmLevelView = itemView.findViewById(R.id.iv_user_charm);
ivLive = itemView.findViewById(R.id.iv_living);
tvOnlineNum = itemView.findViewById(R.id.tv_online_num);
stvOp = itemView.findViewById(R.id.stv_op);

View File

@@ -20,6 +20,7 @@ import com.yizhuan.erban.ui.login.BindPhoneActivity
import com.yizhuan.erban.ui.login.helper.LogoutHelper
import com.yizhuan.xchat_android_core.auth.AuthModel
import com.yizhuan.xchat_android_core.code.CodeType
import com.yizhuan.xchat_android_core.region.RegionHelper
import com.yizhuan.xchat_android_core.user.UserModel
import com.yizhuan.xchat_android_library.utils.ResUtil
import com.yizhuan.xchat_android_library.utils.TextWatcherWrapper
@@ -59,6 +60,7 @@ class ResetPasswordActivity : BaseViewBindingActivity<ActivityResetLoginPwdBindi
// binding.etAccount.isEnabled = false
// }
initListener()
RegionHelper().loadRecommendRegion(lifecycle, binding.tvAreaCode)
}
private fun initListener() {

View File

@@ -6,7 +6,9 @@ import android.os.Build
import android.os.Environment
import android.text.SpannableString
import android.view.View
import com.alibaba.fastjson.JSON
import com.chuhai.utils.log.ILog
import com.google.gson.Gson
import com.netease.nim.uikit.StatusBarUtil
import com.tongdaxing.erban.upgrade.AppUpgradeHelper
import com.yizhuan.erban.BuildConfig
@@ -16,6 +18,8 @@ import com.yizhuan.erban.base.BaseViewBindingActivity
import com.yizhuan.erban.common.widget.dialog.DialogManager.OkCancelDialogListener
import com.yizhuan.erban.databinding.ActivitySettingBinding
import com.yizhuan.erban.ui.im.avtivity.BlackListManageActivity
import com.yizhuan.erban.ui.invite.ShareInviteDialog
import com.yizhuan.erban.ui.invite.ShareInviteInfo
import com.yizhuan.erban.ui.login.BindPhoneActivity
import com.yizhuan.erban.ui.login.ShowBindPhoneActivity
import com.yizhuan.erban.ui.login.helper.LogoutHelper
@@ -24,6 +28,7 @@ import com.yizhuan.erban.ui.webview.CommonWebViewActivity
import com.yizhuan.xchat_android_core.UriProvider
import com.yizhuan.xchat_android_core.auth.AuthModel
import com.yizhuan.xchat_android_core.auth.event.LogoutEvent
import com.yizhuan.xchat_android_core.im.custom.bean.RoomTemplateNotifyMsgBean
import com.yizhuan.xchat_android_core.user.UserModel
import com.yizhuan.xchat_android_core.user.bean.UserInfo
import com.yizhuan.xchat_android_core.utils.SharedPreferenceUtils
@@ -43,7 +48,8 @@ import kotlin.random.Random
* 设置页
* Created by wushaocheng on 2023/2/1.
*/
class SettingActivity : BaseViewBindingActivity<ActivitySettingBinding>(), View.OnClickListener,ILog {
class SettingActivity : BaseViewBindingActivity<ActivitySettingBinding>(), View.OnClickListener,
ILog {
override fun init() {
EventBus.getDefault().register(this)
initWhiteTitleBar(ResUtil.getString(R.string.ui_setting_settingactivity_01))
@@ -217,8 +223,54 @@ class SettingActivity : BaseViewBindingActivity<ActivitySettingBinding>(), View.
}
private fun debug() {
test()
// CommonWebViewActivity.start(
// this,
// "http://192.168.19.136:5502/view/peko/activity/2024-invitationFission/share.html"
// )
val qrcodeUrl =
"https://img0.baidu.com/it/u=4220524728,2310074610&fm=253&app=120&size=w931&n=0&f=JPEG&fmt=auto?sec=1710349200&t=39faa005691f3ebde5b8bf2b99708f1b"
val data = ShareInviteInfo(
qrCodeUrl = qrcodeUrl,
invitationCode = Random.nextInt().toString(),
text = "扫码下载PiKO并填写我的邀请码立得1000钻石!!",
shareTitle = "分享标题",
shareText = "分享文本",
shareImg = qrcodeUrl,
toUrl = "https://www.baidu.com",
)
// InviteImageHelper().saveToAlbum(this, rxPermissions, data)
// ShareInviteDialog(data).show(supportFragmentManager, "A")
// val json = "{\"data\":{\"diamonds\":225000,\"itemId\":32,\"itemMultiple\":45,\"nick\":\"XG001\",\"roomUid\":2881,\"uid\":2881},\"first\":95,\"second\":955}"
// RedPackageOpenDialog2().show(this)
val json = "{\"first\":3,\"second\":32,\"data\":{\"recvUserUid\":2735,\"recvUserAvatar\":\"https://img.pekolive.com/default_avatar.png\",\"recvUserNick\":\"66丢丢丢丢丢多多多的hhhh\",\"sendUserNick\":\"11的ass\",\"sendUserAvatar\":\"http://beta.img.pekolive.com/Fk7aur-1RBqKXC-qqBwMTjivZ3lV?imageslim\",\"sendUserUid\":2737,\"giftUrl\":\"http://beta.img.pekolive.com/Fn6h_gPFD5MwA-Ql_kcWqNpKp0JM?imageslim\",\"giftName\":\"幽靈糖果\",\"giftId\":2075,\"giftNum\":${Random.nextInt(1,1000)},\"giftGolds\":33440,\"notifyStaySecond\":5,\"isHomeShow\":true,\"isSkipRoom\":true,\"isFullScreen\":false,\"isSendMsg\":false,\"roomUid\":2737,\"roomErbanNo\":11,\"roomTitle\":\"11的工会\",\"levelNum\":${Random.nextInt(1,4)}}}"
onReceivedNimBroadcastMessage(json)
// val json = "{\"first\":85,\"second\":855,\"data\":{\"nick\":\"66丢丢丢丢丢多多多的hhhh\",\"preVipName\":\"子爵\",\"floatPic\":\"https://image.hfighting.com/Fq3JtbK2acO3FN-3vWZo8ldtHfse\",\"uid\":2735,\"currVipName\":\"侯爵\",\"erbanNo\":66,\"roomUid\":2734,\"avatar\":\"https://img.pekolive.com/default_avatar.png\",\"currVipLevel\":5}}"
// onReceivedNimBroadcastMessage(json)
// CommonWebViewActivity.start(this,"https://api.anan.chat/anan_vestBag/modules/rank/index.html#/rank")
// CommonWebViewActivity.start(this,"https://api.anan.chat/anan_vestBag/modules/myincome/index.html#/DiamondLog")
}
private fun test(){
logD("test()")
val json = "{\"fontSize\":12,\"resourceType\":\"IMAGE\",\"resourceContent\":\"https://piko-1320554189.cos.ap-singapore.myqcloud.com/gYWPkyh3s6FG1Cc4lfKowGUgyTYDaNPBYwXfcy79fnA2i1U4LFJJR.png\",\"resourceWidth\":750,\"resourceHeight\":121,\"svgaTextKey\":\"noble_text_tx\",\"template\":{\"zh-CN\":\"恭喜{senderNick}赠送{giftName},爆出{outputValue}钻石大奖!\"},\"textColor\":\"#FFFFFF\",\"contents\":[{\"text\":{\"zh-CN\":\"[2813]\"},\"fontSize\":12,\"textColor\":\"#FFFF00\",\"type\":\"TEXT\",\"key\":\"senderNick\"},{\"text\":{\"zh-CN\":\"[守護之星]\"},\"fontSize\":12,\"textColor\":\"#FFFF00\",\"type\":\"TEXT\",\"key\":\"giftName\"},{\"text\":{\"zh-CN\":\"597\"},\"fontSize\":12,\"textColor\":\"#FFFF00\",\"type\":\"TEXT\",\"key\":\"outputValue\"}]}"
try {
val data = JSON.parseObject(json, RoomTemplateNotifyMsgBean::class.java)
logD("data:${data}")
logD("data0:${data.contents?.size}")
logD("data1:${data.contents?.firstOrNull()?.key}")
logD("data2:${data.contents?.firstOrNull()?.text}")
}catch (e:Exception){
logD("test() error")
e.printStackTrace()
}
try {
val data2 = Gson().fromJson<RoomTemplateNotifyMsgBean>(json, RoomTemplateNotifyMsgBean::class.java)
logD("data:${data2}")
logD("data0:${data2.contents?.size}")
logD("data1:${data2.contents?.firstOrNull()?.key}")
logD("data2:${data2.contents?.firstOrNull()?.text}")
}catch (e:Exception){
logD("test() error2")
e.printStackTrace()
}
}
}

View File

@@ -19,6 +19,7 @@ import com.yizhuan.erban.ui.login.BindPhoneActivity
import com.yizhuan.xchat_android_core.auth.AuthModel
import com.yizhuan.xchat_android_core.code.CodeType
import com.yizhuan.xchat_android_core.pay.PayModel
import com.yizhuan.xchat_android_core.region.RegionHelper
import com.yizhuan.xchat_android_core.utils.net.BeanObserver
import com.yizhuan.xchat_android_library.utils.ResUtil
@@ -53,6 +54,7 @@ class VerifyPhoneActivity : BaseViewBindingActivity<ActivityVerifyPhoneBinding>(
resetPwd = intent.getBooleanExtra("resetPwd", false)
initListener()
RegionHelper().loadRecommendRegion(lifecycle, binding.tvAreaCode)
}
private fun initListener() {

View File

@@ -65,6 +65,7 @@ import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.Commo
import com.yizhuan.erban.ui.widget.rollviewpager.HintView;
import com.yizhuan.erban.ui.widget.rollviewpager.RollPagerView;
import com.yizhuan.erban.ui.widget.rollviewpager.adapter.StaticPagerAdapterWrapper;
import com.yizhuan.erban.utils.NamePlateHelper;
import com.yizhuan.erban.utils.RegexUtil;
import com.yizhuan.erban.vip.util.VipHelper;
import com.yizhuan.xchat_android_constants.XChatConstants;
@@ -317,7 +318,7 @@ public class UserInfoActivity extends BaseBindingActivity<ActivityUserInfoBindin
//等级魅力值
setUserLevel(userInfo.getUserLevelVo());
//铭牌
setOfficialMask(userInfo.getNameplateWord(), userInfo.getNameplatePic());
NamePlateHelper.INSTANCE.load(mBinding.inOfficialMask, tvOfficialMask, ivOfficialMask, userInfo);
if (AuthModel.get().getCurrentUid() != userInfo.getUid()) {
PraiseModel.get().isPraised(AuthModel.get().getCurrentUid(), userInfo.getUid()).subscribe();
}
@@ -626,19 +627,6 @@ public class UserInfoActivity extends BaseBindingActivity<ActivityUserInfoBindin
setLikedText(event.isPraise());
}
private void setOfficialMask(String name, String icon) {
if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(icon)) {
mBinding.inOfficialMask.setVisibility(View.VISIBLE);
if (tvOfficialMask != null && ivOfficialMask != null) {
tvOfficialMask.setText(name);
ImageLoadUtils.loadImage(this, icon, ivOfficialMask);
}
} else {
mBinding.inOfficialMask.setVisibility(View.GONE);
}
}
public void initVoiceShow(UserInfo.SoundBean audioCard) {
if (audioCard != null && !TextUtils.isEmpty(audioCard.getAudioUrl())) {
if (AuthModel.get().getCurrentUid() == userId) {//主态

View File

@@ -427,6 +427,11 @@ public class ImageLoadUtils {
GlideApp.with(context.getApplicationContext()).load(url).dontAnimate().into(imageView);
}
public static void loadImage(ImageView imageView, String url) {
GlideApp.with(imageView).load(url).dontAnimate().into(imageView);
}
public static void loadImage1(Context context, String url, ImageView imageView) {
GlideApp.with(context).load(url).optionalFitCenter().into(new SimpleTarget<Drawable>() {
@Override

View File

@@ -0,0 +1,56 @@
package com.yizhuan.erban.ui.wallet
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import com.chuhai.utils.log.ILog
import com.yizhuan.erban.application.XChatApplication
import com.yizhuan.erban.other.activity.SplashActivity
import com.yizhuan.xchat_android_core.auth.AuthModel
import com.yizhuan.xchat_android_core.pay.PayModel
/**
* Created by Max on 2024/1/31 10:50
* Desc:
**/
class PaymentResultActivity : Activity(), ILog {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
logD("onCreate()")
handler(intent)
}
private fun handler(intent: Intent?) {
val uri = intent?.data
logD("handler() uri:${uri}")
if (XChatApplication.gStack.activityNum == 1) {
logD("handler() open->splash")
SplashActivity.start(this)
finish()
} else {
val status = uri?.getQueryParameter("status")?.toIntOrNull()
logD("handler() status:$status")
val uid = AuthModel.get().currentUid
if (status == 1 && uid != 0L) {
PayModel.get().getWalletInfo(uid).subscribe()
}
}
finish()
}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
logD("onNewIntent()")
handler(intent)
}
override fun onDestroy() {
super.onDestroy()
logD("onDestroy()")
}
override fun getLogTag(): String {
return super.getLogTag()
}
}

View File

@@ -9,11 +9,11 @@ import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.net.http.SslError;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.view.View;
import android.webkit.SslErrorHandler;
@@ -54,12 +54,12 @@ import com.yizhuan.xchat_android_core.web.bean.WebJsBeanInfo;
import com.yizhuan.xchat_android_core.web.event.WebViewRefreshEvent;
import com.yizhuan.xchat_android_library.rxbus.RxBus;
import com.yizhuan.xchat_android_library.utils.ResUtil;
import com.yizhuan.xchat_android_library.utils.SingleToastUtil;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;
@@ -99,32 +99,6 @@ public class CommonWebViewActivity extends BaseActivity implements ShareDialog.O
private static final String POSITION = "position";
private int mPosition;
private int mProgress;
private Handler mHandler = new Handler();
private ProgressRunnable mProgressRunnable = new ProgressRunnable(this);
private static class ProgressRunnable implements Runnable {
private WeakReference<CommonWebViewActivity> mWeakReference;
ProgressRunnable(CommonWebViewActivity activity) {
mWeakReference = new WeakReference<>(activity);
}
@Override
public void run() {
CommonWebViewActivity activity = mWeakReference.get();
if (activity == null) return;
if (activity.mProgress < 96) {
activity.mProgress += 3;
activity.mProgressBar.setProgress(activity.mProgress);
activity.mHandler.postDelayed(activity.mProgressRunnable, 10);
}
}
}
public static void start(Context context, String url) {
Intent intent = new Intent(context, CommonWebViewActivity.class);
intent.putExtra("url", url);
@@ -222,7 +196,7 @@ public class CommonWebViewActivity extends BaseActivity implements ShareDialog.O
@SuppressLint("SetJavaScriptEnabled")
private void initData() {
mHandler.post(mProgressRunnable);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setLoadWithOverviewMode(true);
@@ -238,14 +212,13 @@ public class CommonWebViewActivity extends BaseActivity implements ShareDialog.O
webView.addJavascriptInterface(jsInterface, "androidJsObj");
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.setWebViewClient(new WebViewClient() {
String packageName;
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Logger.e("shouldOverrideUrlLoading--------" + url);
LogUtil.e("shouldOverrideUrlLoading" + url);
targetUrl = url;
if (url.contains("tel:")) {
//删除直接拨打电话的功能
return true;
@@ -253,6 +226,7 @@ public class CommonWebViewActivity extends BaseActivity implements ShareDialog.O
// ------- 处理结束 -------
if (!(url.startsWith("http") || url.startsWith("https"))) {
handleIntent(url);
return true;
}
@@ -290,9 +264,56 @@ public class CommonWebViewActivity extends BaseActivity implements ShareDialog.O
mProgressBar.setVisibility(View.GONE);
super.onPageFinished(view, url);
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
mProgressBar.setVisibility(View.VISIBLE);
}
private void handleIntent(String url) {
Intent intent;
try {
if (url.startsWith("intent://")) {
//MyCard、Line
intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
packageName = intent.getPackage();
} else { //第三方支付
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
}
startActivity(intent);
} catch (Exception e) {
handleCatch(e);
}
}
private void handleCatch(Exception ex) {
if (packageName != null) {
toGooglePaly(packageName);
} else {
SingleToastUtil.showToast(ex.getMessage());
}
}
private void toGooglePaly(String packageName) {
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageName)));
} catch (android.content.ActivityNotFoundException anfe) {
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + packageName)));
} catch (Exception e) {
e.printStackTrace();
}
}
}
});
//获取webviewtitle作为titlebar的title
wvcc = new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
mProgressBar.setProgress(newProgress);
}
@Override
public void onReceivedTitle(WebView view, String title) {
@@ -520,11 +541,6 @@ public class CommonWebViewActivity extends BaseActivity implements ShareDialog.O
@Override
protected void onDestroy() {
if (mHandler != null) {
mHandler.removeCallbacks(mProgressRunnable);
mProgressRunnable = null;
mHandler = null;
}
EventBus.getDefault().unregister(this);
if (webViewCallBack != null) {

View File

@@ -3,8 +3,8 @@ package com.yizhuan.erban.ui.webview;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
@@ -28,8 +28,17 @@ public class DialogWebViewActivity extends CommonWebViewActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, ScreenUtil.screenHeight / 3 * 2);
getWindow().setGravity(Gravity.BOTTOM);
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
);
getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
View topView = findViewById(R.id.v_top);
topView.setOnClickListener(v -> finish());
ViewGroup.LayoutParams params = topView.getLayoutParams();
params.height = getTopMargin();
showTitleBar = getIntent().getBooleanExtra("showTitleBar", true);
if (!showTitleBar) {
layoutTitleBar.setVisibility(View.GONE);
@@ -40,4 +49,8 @@ public class DialogWebViewActivity extends CommonWebViewActivity {
protected int getLayoutId() {
return R.layout.activity_dialog_web_view;
}
protected int getTopMargin() {
return ScreenUtil.screenHeight / 3;
}
}

View File

@@ -16,6 +16,7 @@ import android.webkit.WebView;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.netease.nim.uikit.common.util.log.LogUtil;
import com.orhanobut.logger.Logger;
import com.yizhuan.erban.UIHelper;
@@ -27,6 +28,9 @@ import com.yizhuan.erban.family.view.activity.FamilyHomeActivity;
import com.yizhuan.erban.public_chat_hall.activity.PublicChatHallHomeActivity;
import com.yizhuan.erban.ui.im.RouterHandler;
import com.yizhuan.erban.ui.im.avtivity.NimP2PMessageActivity;
import com.yizhuan.erban.ui.invite.InviteImageHelper;
import com.yizhuan.erban.ui.invite.ShareInviteDialog;
import com.yizhuan.erban.ui.invite.ShareInviteInfo;
import com.yizhuan.erban.ui.pay.ChargeActivity;
import com.yizhuan.erban.ui.webview.event.H5NotifyClientEvent;
import com.yizhuan.erban.ui.webview.event.ShowNavEvent;
@@ -63,6 +67,7 @@ import org.greenrobot.eventbus.EventBus;
import java.io.File;
import java.util.HashMap;
/**
* <p> html js 与webview 交互接口</p>
* Created by ${user} on 2017/11/6.
@@ -179,6 +184,31 @@ public class JSInterface {
}
}
@JavascriptInterface
public void savePictureShare(String json) {
Logger.e("savePictureShare: " + json);
try {
CommonWebViewActivity activity = mActivity;
if (activity == null) {
return;
}
ShareInviteInfo info = new Gson().fromJson(json,ShareInviteInfo.class);
if (info.getType() != null) {
if (info.getType() == 1) {
activity.runOnUiThread(() -> {
new ShareInviteDialog(info).show(activity.getSupportFragmentManager(), "SHARE_INVITE#JS");
});
} else if (info.getType() == 2) {
activity.runOnUiThread(() -> {
new InviteImageHelper().saveToAlbum(activity, activity.getRxPermissions(), info, null);
});
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 调转钱包页
*/

View File

@@ -0,0 +1,48 @@
package com.yizhuan.erban.ui.webview.room_banner
import android.view.View
import android.widget.ImageView
import androidx.core.view.isInvisible
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.yizhuan.erban.R
import com.yizhuan.erban.ui.utils.load
import com.yizhuan.xchat_android_core.home.bean.BannerInfo
import com.yizhuan.xchat_android_core.room.bean.RoomIcon
/**
* Created by Max on 2023/11/17 12:30
* Desc:
**/
class RoomBannerTabAdapter :
BaseQuickAdapter<RoomIcon, BaseViewHolder>(R.layout.room_banner_item_tab) {
private var selectedPosition = -1
override fun convert(helper: BaseViewHolder, item: RoomIcon?) {
helper.getView<ImageView>(R.id.iv_content).load(item?.url)
convertState(helper, item)
}
override fun convertPayloads(
helper: BaseViewHolder,
item: RoomIcon?,
payloads: MutableList<Any>
) {
super.convertPayloads(helper, item, payloads)
convertState(helper, item)
}
private fun convertState(helper: BaseViewHolder, item: RoomIcon?) {
helper.getView<View>(R.id.v_selector).isInvisible =
helper.absoluteAdapterPosition != selectedPosition
}
fun getSelectedPosition(): Int {
return selectedPosition
}
fun select(position: Int) {
this.selectedPosition = position
notifyItemRangeChanged(0, itemCount, true)
}
}

View File

@@ -0,0 +1,91 @@
package com.yizhuan.erban.ui.webview.room_banner
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.view.View
import android.view.WindowManager
import androidx.recyclerview.widget.RecyclerView
import com.chuhai.utils.UiUtils
import com.yizhuan.erban.R
import com.yizhuan.erban.ui.webview.CommonWebViewActivity
import com.yizhuan.xchat_android_core.room.bean.RoomIcon
/**
* Created by Max on 2023/11/17 11:38
* Desc:房间内-Banner-WEB展示页面
**/
class RoomBannerWebDialogActivity : CommonWebViewActivity() {
private var recyclerView: RecyclerView? = null
private var adapter: RoomBannerTabAdapter? = null
companion object {
@JvmStatic
fun start(context: Context, position: Int, list: List<RoomIcon>) {
val newList = ArrayList<RoomIcon>()
newList.addAll(list)
val intent = Intent(context, RoomBannerWebDialogActivity::class.java)
intent.putExtra("position", position)
intent.putExtra("list", newList)
context.startActivity(intent)
}
}
override fun getLayoutId(): Int {
return R.layout.room_banner_dialog
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_FULLSCREEN
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
window.setLayout(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT
)
val topView = findViewById<View>(R.id.v_top)
topView.setOnClickListener { v: View? -> finish() }
val params = topView.layoutParams
params.height = UiUtils.dip2px(168f)
topView.layoutParams = params
webView.setBackgroundColor(Color.parseColor("#C9CBD1"))
recyclerView = findViewById(R.id.recyclerView)
val position = 0.coerceAtLeast(intent.getIntExtra("position", 0))
val list = intent.getSerializableExtra("list") as? ArrayList<RoomIcon>
// if ((list?.size ?: 0) <= 1) {
// recyclerView?.isVisible = false
// }
adapter = RoomBannerTabAdapter().apply {
setOnItemClickListener { adapter, view, position ->
if (this@RoomBannerWebDialogActivity.adapter?.getSelectedPosition() == position) {
return@setOnItemClickListener
}
switchTab(position)
}
}
recyclerView?.adapter = adapter
adapter?.setNewData(list)
switchTab(position)
}
private fun switchTab(position: Int) {
val url = adapter?.getItem(position)?.skipContent
showWebView(url)
adapter?.select(position)
recyclerView?.post {
recyclerView?.scrollToPosition(position)
}
}
override fun showWebView(url: String?) {
if (url.isNullOrEmpty()) {
return
}
super.showWebView(url)
}
}

View File

@@ -0,0 +1,26 @@
package com.yizhuan.erban.ui.webview.room_banner
import android.content.Context
import android.content.Intent
import com.yizhuan.erban.ui.webview.DialogWebViewActivity
import com.yizhuan.erban.ui.widget.rollviewpager.Util
/**
* Created by Max on 2024/2/20 17:47
* Desc:房间半屏Web弹窗
**/
class RoomWebDialogActivity : DialogWebViewActivity() {
companion object {
fun start(context: Context, url: String, showTitleBar: Boolean) {
val intent = Intent(context, RoomWebDialogActivity::class.java)
intent.putExtra("url", url)
intent.putExtra("showTitleBar", showTitleBar)
context.startActivity(intent)
}
}
override fun getTopMargin(): Int {
return Util.dip2px(this, 168f)
}
}

View File

@@ -110,6 +110,8 @@ import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -162,7 +164,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
private View flLuckyDesc;
private RecyclerView rvLuckyMsg;
private ImageView ivOpenNoble;
private View ivFirstRecharge;
private View tvFirstRecharge;
private TextView tvLuckyBagIntro;
private TextView tvGiftValue;
private EditText etSendMessage;
@@ -207,6 +209,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
private BaseQuickAdapter<LuckyBagNoticeInfo, BaseViewHolder> luckyMsgAdapter;
private BannerViewPager<SimpleUserInfo> mStarWeekBanner;
private ImageView ivSuperLuckyGiftTips;
public GiftDialog(Context context, int giftId) {
this(context, 0, true, false, true, giftId);
@@ -394,6 +397,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
ivDrawGiftClose = root.findViewById(R.id.iv_draw_gift_close);
flLuckyDesc = findViewById(R.id.fl_lucky_desc);
rvLuckyMsg = findViewById(R.id.rv_lucky_msg);
ivSuperLuckyGiftTips = findViewById(R.id.iv_super_lucky_gift_tips);
ivDrawGiftClose.setOnClickListener(this);
ivDrawGiftRemoveLast.setOnClickListener(this);
ivDrawGiftRemoveAll.setOnClickListener(this);
@@ -408,6 +412,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
tabInfoList.add(new GiftTab(GiftIndicator.TYPE_NOBLE, ResUtil.getString(R.string.ui_widget_giftdialog_05), ResUtil.getString(R.string.ui_widget_giftdialog_06)));
tabInfoList.add(new GiftTab(GiftIndicator.TYPE_WEEK, ResUtil.getString(R.string.ui_widget_giftdialog_07), ResUtil.getString(R.string.ui_widget_giftdialog_08)));
// tabInfoList.add(new GiftTab(GiftIndicator.TYPE_DRAW_GIFT, ResUtil.getString(R.string.ui_widget_giftdialog_09), ResUtil.getString(R.string.ui_widget_giftdialog_010)));
tabInfoList.add(new GiftTab(GiftIndicator.TYPE_SING_ROOM, ResUtil.getString(R.string.ui_widget_giftdialog_hot), ResUtil.getString(R.string.ui_widget_giftdialog_hot)));
tabInfoList.add(new GiftTab(GiftIndicator.TYPE_KNAP, ResUtil.getString(R.string.ui_widget_giftdialog_011), ResUtil.getString(R.string.ui_widget_giftdialog_012)));
giftIndicator = root.findViewById(R.id.gift_indicator);
giftIndicator.initTab(
@@ -459,12 +464,12 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
ivOpenNoble.setOnClickListener(this);
sendContainer = root.findViewById(R.id.send_container);
layoutEmpty.setVisibility(View.GONE);
ivFirstRecharge = root.findViewById(R.id.iv_first_recharge);
tvFirstRecharge = root.findViewById(R.id.tv_first_recharge);
tvLuckyBagIntro = findViewById(R.id.tv_lucky_bag_intro);
tvGiftValue = root.findViewById(R.id.tv_gift_value);
mStarWeekBanner = findViewById(R.id.star_week_list);
ivFirstRecharge.setOnClickListener(this);
tvFirstRecharge.setOnClickListener(this);
tvLuckyBagIntro.setOnClickListener(this);
if (giftId == 0) {
// 更新所有礼物
@@ -492,6 +497,11 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
giftIndicator.setPosition(indicatorType);
updateGiftView(giftIndicator.getCurrrentType(), giftInfo);
}
if (AvRoomDataManager.get().isSingleRoom()) {
giftIndicator.showPosition(GiftIndicator.TYPE_SING_ROOM);
} else {
giftIndicator.hidePosition(GiftIndicator.TYPE_SING_ROOM);
}
View descLayout = root.findViewById(R.id.desc_layout);
@@ -535,11 +545,16 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
.compose(RxHelper.bindContext(context))
.subscribe(userInfo -> {
if (userInfo.isFirstCharge()) {
ivFirstRecharge.setVisibility(View.VISIBLE);
tvFirstRecharge.setVisibility(View.VISIBLE);
}
});
}
PayModel.get().getMyRemoteWalletInfo().compose(RxHelper.bindContext(context))
.subscribe(info -> {
goldWalletInfo = info;
setGoldOrRadishText(lastSelectedItem);
});
}
private void showLoadingAnimation() {
@@ -586,12 +601,20 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
if (goldWalletInfo == null) {
return;
}
String goldNumText = getContext().getString(R.string.gold_num_text, goldWalletInfo.getDiamondNum());
SpannableBuilder builder = new SpannableBuilder();
builder.append(context.getText(R.string.gift_wallet_overage), new ForegroundColorSpan(
context.getResources().getColor(R.color.white_transparent_50)))
.append(goldNumText);
tvTextGold.setText(builder.build());
if (goldWalletInfo.canGoldSendGift) {
findViewById(R.id.iv_plus).setVisibility(View.VISIBLE);
findViewById(R.id.iv_gold).setVisibility(View.VISIBLE);
BigDecimal total = BigDecimal.valueOf(goldWalletInfo.getDiamondNum());
total = total.add(BigDecimal.valueOf(goldWalletInfo.getGoldNum()));
total = total.setScale(0, RoundingMode.DOWN);
tvTextGold.setText(total.toPlainString());
} else {
findViewById(R.id.iv_plus).setVisibility(View.GONE);
findViewById(R.id.iv_gold).setVisibility(View.GONE);
BigDecimal total = BigDecimal.valueOf(goldWalletInfo.getDiamondNum());
total = total.setScale(0, RoundingMode.DOWN);
tvTextGold.setText(total.toPlainString());
}
}
private void setUpdateTipsText() {
@@ -620,6 +643,8 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
currentGiftInfoList = getWeekStarGiftInfos();
} else if (position == GiftIndicator.TYPE_DRAW_GIFT) {
currentGiftInfoList = getDrawGiftInfos();
} else if (position == GiftIndicator.TYPE_SING_ROOM) {
currentGiftInfoList = getSingleRoomGiftInfos();
}
// 有贵族礼物才显示贵族礼物的tab
if (ListUtils.isListEmpty(nobleGiftInfos)) {
@@ -643,11 +668,13 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
showEmptyView();
} else if (position == GiftIndicator.TYPE_LUCKY ||
position == GiftIndicator.TYPE_WEEK ||
position == GiftIndicator.TYPE_SING_ROOM ||
position == GiftIndicator.TYPE_DRAW_GIFT) {
showEmptyView();
updateWeekStarDesc();
isShowDrawGiftModel = false;
updateDrawGift();
updateSuperLuckyGiftTips();
} else {
showLoadFailedView();
}
@@ -657,7 +684,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
if (currentGiftInfo.isSendMsg()) {
etSendMessage.setVisibility(View.VISIBLE);
}
pagerList = beanTransformVm(context, currentGiftInfoList, isKnap, position == GiftIndicator.TYPE_WEEK ? 4 : 8, selectGiftInfo);
pagerList = beanTransformVm(context, currentGiftInfoList, isKnap, position == GiftIndicator.TYPE_WEEK ? 4 : 8, currentGiftInfo);
setGridViewData(pagerList);
if (isKnap) {
tvGiftValue.setVisibility(View.VISIBLE);
@@ -668,6 +695,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
}
}
updateLuckyBagIntro();
updateSuperLuckyGiftTips();
updateWeekStarDesc();
isShowDrawGiftModel = false;
updateDrawGift();
@@ -680,6 +708,20 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
});
}
private void updateSuperLuckyGiftTips(){
if (currentGiftInfo == null || TextUtils.isEmpty(currentGiftInfo.getBannerUrl()) || currentGiftInfo.getGiftType() != GiftType.GIFT_TYPE_SUPER_LUCKY) {
ivSuperLuckyGiftTips.setVisibility(View.GONE);
} else {
ivSuperLuckyGiftTips.setVisibility(View.VISIBLE);
ImageLoadUtils.loadImage(getContext(), currentGiftInfo.getBannerUrl(), ivSuperLuckyGiftTips);
ivSuperLuckyGiftTips.setOnClickListener(v -> {
if (!TextUtils.isEmpty(currentGiftInfo.getSkipUrl())) {
DialogWebViewActivity.start(context, currentGiftInfo.getSkipUrl(), true);
}
});
}
}
private void updateLuckyBagIntro() {
if (currentGiftInfo == null ||
(TextUtils.isEmpty(currentGiftInfo.getGiftExplainUrl()) && currentGiftInfo.getGiftType() != GiftType.GIFT_TYPE_LUCKY)) {
@@ -1015,6 +1057,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
currentGiftInfo = item.data;
setGoldOrRadishText(lastSelectedItem);
updateLuckyBagIntro();
updateSuperLuckyGiftTips();
updateWeekStarDesc();
isShowDrawGiftModel = true;
updateDrawGift();
@@ -1093,6 +1136,12 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
GiftType.GIFT_TYPE_DRAW_GIFT);
}
private List<GiftInfo> getSingleRoomGiftInfos() {
return GiftModel.get().getGiftInfosByType(
String.valueOf(AvRoomDataManager.get().getRoomUid()),
GiftType.GIFT_TYPE_SINGLE_ROOM);
}
private List<GiftInfo> getNobleGiftInfos() {
return GiftModel.get().getGiftInfoList(GiftType.GIFT_TYPE_VIP);
}
@@ -1340,7 +1389,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
ReportManager.get().reportEvent(IReportConstants.PAYPAGE_SHOW, map);
break;
case R.id.iv_first_recharge:
case R.id.tv_first_recharge:
FirstChargeDialog.start(context);
break;
@@ -1409,7 +1458,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
if (throwable == null) {
// 返回结果时,当前选中选项与请求时的选项一样时才显示
if (currentType == giftIndicator.getCurrrentType()) {
updateGiftView(giftIndicator.getCurrrentType());
updateGiftView(giftIndicator.getCurrrentType(), currentGiftInfo);
}
} else {
if (needShowLoading) showLoadFailedView();
@@ -1491,8 +1540,8 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
@Subscribe(threadMode = ThreadMode.MAIN)
public void onFirstRechargeEvent(FirstChargeEvent event) {
if (ivFirstRecharge != null) {
ivFirstRecharge.setVisibility(View.GONE);
if (tvFirstRecharge != null) {
tvFirstRecharge.setVisibility(View.GONE);
}
}

View File

@@ -0,0 +1,146 @@
package com.yizhuan.erban.ui.widget
import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Typeface
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View
import android.view.ViewParent
/**
* Created by Max on 2023/12/8 10:43
* Desc:字母索引
**/
class SideBarView : View {
private var selectIndex = 0
private var textSize = 0f
private var textColor = 0
private var textSizeFocus = 0f
private var textColorFocus = 0
//标记 避免重复调用
private var isDown = false
//这里也可以传入数组方式
private var list = listOf(
"A", "B", "C", "D", "E", "F", "G", "H", "I",
"J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
"W", "X", "Y", "Z", "#"
)
private var paint = Paint()
private var listener: Listener? = null
constructor(context: Context?) : super(context)
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
)
constructor(
context: Context?,
attrs: AttributeSet?,
defStyleAttr: Int,
defStyleRes: Int
) : super(context, attrs, defStyleAttr, defStyleRes)
fun setTextColor(textColor: Int, focusTextColor: Int = textColor) {
this.textColor = textColor
this.textColorFocus = focusTextColor
}
fun setTextSize(textSize: Float, focusTextSize: Float = textSize) {
this.textSize = textSize
this.textSizeFocus = focusTextSize
}
override fun onDraw(canvas: Canvas?) {
super.onDraw(canvas)
paintText(canvas)
}
private fun paintText(canvas: Canvas?) {
//计算每一个字母的高度,总告诉除以字母集合的高度就可以
val height: Int = height / list.size
for (i in list.indices) {
if (i == selectIndex) {
paint.color = textColorFocus
paint.textSize = textSizeFocus
} else {
paint.color = textColor
paint.textSize = textSize
}
paint.isAntiAlias = true //设置抗锯齿
paint.typeface = Typeface.DEFAULT_BOLD
//计算每一个字母x轴
val paintX = width / 2f - paint.measureText(list[i]) / 2
//计算每一个字母Y轴
val paintY = height * i + height
//绘画出来这个TextView
canvas?.drawText(list[i], paintX, paintY.toFloat(), paint)
//画完一个以后重置画笔
paint.reset()
}
}
override fun onTouchEvent(event: MotionEvent): Boolean {
val parent: ViewParent?
when (event.action) {
MotionEvent.ACTION_DOWN, MotionEvent.ACTION_MOVE -> {
val index = (event.y / height * list.size).toInt()
if (index >= 0 && index < list.size && selectIndex != index) {
listener?.onSideBarScroll(list[index])
selectIndex = index
invalidate()
//改变标记状态
isDown = true
}
parent = getParent()
parent?.requestDisallowInterceptTouchEvent(true)
}
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
listener?.onSideBarScrollEnd()
//改变标记状态
isDown = false
parent = getParent()
parent?.requestDisallowInterceptTouchEvent(false)
}
}
return true
}
interface Listener {
//滚动位置
fun onSideBarScroll(word: String)
//隐藏提示文本
fun onSideBarScrollEnd()
}
fun setListener(listener: Listener?) {
this.listener = listener
}
/**
* Item滚动 更新侧边栏字母
*
* @param word 字母
*/
fun onUpdateSideBarText(word: String?) {
//手指没触摸才调用
if (!isDown) {
for (i in list.indices) {
if (list[i] == word && selectIndex != i) {
selectIndex = i
invalidate()
}
}
}
}
}

View File

@@ -44,6 +44,7 @@ import com.yizhuan.erban.ui.user.activity.UserInfoActivity;
import com.yizhuan.erban.ui.user.adapter.SkillPicsAdapter;
import com.yizhuan.erban.ui.user.decorationsend.UserInfoSkillDecoration;
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
import com.yizhuan.erban.utils.NamePlateHelper;
import com.yizhuan.erban.utils.RegexUtil;
import com.yizhuan.erban.view.GenderAgeTextView;
import com.yizhuan.erban.vip.util.VipHelper;
@@ -574,11 +575,7 @@ public class UserInfoDialog extends AppCompatDialog implements View.OnClickListe
}
//铭牌
if (!TextUtils.isEmpty(userInfo.getNameplatePic()) && !TextUtils.isEmpty(userInfo.getNameplateWord())) {
setNamePlate(userInfo.getNameplatePic(), userInfo.getNameplateWord());
} else {
setNamePlate(null, null);
}
NamePlateHelper.INSTANCE.load(inNamePlate, inNamePlate.findViewById(R.id.tv_official_mask), inNamePlate.findViewById(R.id.iv_official_mask), userInfo);
// 改变贵族
updateNobleView();
UserInfo.NamePlate namePlate = userInfo.getNameplate();
@@ -660,26 +657,6 @@ public class UserInfoDialog extends AppCompatDialog implements View.OnClickListe
}
}
private void setNamePlate(String nameplatePic, String nameplateWord) {
if (!TextUtils.isEmpty(nameplateWord) && !TextUtils.isEmpty(nameplatePic)) {
inNamePlate.setVisibility(View.VISIBLE);
TextView tvNamePlate;
tvNamePlate = inNamePlate.findViewById(R.id.tv_official_mask);
if (tvNamePlate != null) {
tvNamePlate.setText(nameplateWord);
}
ImageView ivNamePlate;
ivNamePlate = inNamePlate.findViewById(R.id.iv_official_mask);
if (ivNamePlate != null) {
ImageLoadUtils.loadImage(context, nameplatePic, ivNamePlate);
}
} else {
inNamePlate.setVisibility(View.GONE);
}
}
private void setOfficialMask(String name, String icon) {
if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(icon)) {
inOfficialMask.setVisibility(View.VISIBLE);

View File

@@ -1,5 +1,6 @@
package com.yizhuan.erban.ui.widget.dialog;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_CRAZY_ZOO_SUB_ALL_ROOM;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL;
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_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA;
@@ -8,6 +9,7 @@ import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUS
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.Layout;
import android.text.Spanned;
@@ -20,12 +22,21 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;
import androidx.core.text.HtmlCompat;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
import com.netease.nim.uikit.support.glide.GlideApp;
import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGADynamicEntity;
import com.opensource.svgaplayer.SVGAImageView;
@@ -33,9 +44,12 @@ import com.opensource.svgaplayer.SVGAParser;
import com.opensource.svgaplayer.SVGAVideoEntity;
import com.yizhuan.erban.R;
import com.yizhuan.erban.avroom.activity.AVRoomActivity;
import com.yizhuan.erban.avroom.widget.TemplateMessageAdapter;
import com.yizhuan.erban.common.svga.SimpleSvgaCallback;
import com.yizhuan.erban.databinding.DialogAllPlayEffectBinding;
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2;
import com.yizhuan.erban.ui.webview.CommonWebViewActivity;
import com.yizhuan.erban.utils.CommonJumpHelper;
import com.yizhuan.erban.utils.RegexUtil;
import com.yizhuan.erban.utils.SpannableBuilder;
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagNoticeInfo;
@@ -44,23 +58,36 @@ import com.yizhuan.xchat_android_core.im.custom.bean.NotifyH5Info;
import com.yizhuan.xchat_android_core.im.custom.bean.PlayEffectInfo;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeInfo;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomLuckySeaMsgBean;
import com.yizhuan.xchat_android_core.im.custom.bean.RoomTemplateNotifyMsgBean;
import com.yizhuan.xchat_android_core.im.custom.bean.TarotMsgBean;
import com.yizhuan.xchat_android_core.treasurefairy.FairyMsgInfoBean;
import com.yizhuan.xchat_android_library.utils.ResUtil;
import com.yizhuan.xchat_android_library.utils.StringUtils;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
public class AllPlayEffectDialog extends BaseDialog {
private final PlayEffectInfo playEffectInfo;
private DialogAllPlayEffectBinding binding;
public AllPlayEffectDialog(Context context, @NonNull PlayEffectInfo playEffectInfo) {
private CompositeDisposable disposable = null;
private boolean belowGiftNotify;
public AllPlayEffectDialog(Context context, @NonNull PlayEffectInfo playEffectInfo, boolean belowGiftNotify) {
super(context, R.style.FullScreenDialog);
this.playEffectInfo = playEffectInfo;
this.belowGiftNotify = belowGiftNotify;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
disposable = new CompositeDisposable();
requestWindowFeature(Window.FEATURE_NO_TITLE);
binding = DialogAllPlayEffectBinding.inflate(LayoutInflater.from(getContext()));
setContentView(binding.getRoot());
@@ -80,6 +107,9 @@ public class AllPlayEffectDialog extends BaseDialog {
window.setAttributes(windowParams);
window.setWindowAnimations(R.style.anim_left);
}
if (belowGiftNotify) {
binding.vGiftNotifyPlaceholder.setVisibility(View.VISIBLE);
}
switch (playEffectInfo.getSecond()) {
case CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA:
showBoxNotifyBySVGA(playEffectInfo.getRoomBoxPrizeInfo());
@@ -87,6 +117,9 @@ public class AllPlayEffectDialog extends BaseDialog {
case CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_ALL:
showLuckySeaNotifyBySVGA(playEffectInfo.getRoomLuckySeaMsgBean());
break;
case CUSTOM_MSG_CRAZY_ZOO_SUB_ALL_ROOM:
showZooNotifyBySVGA(playEffectInfo.getRoomLuckySeaMsgBean());
break;
case CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL:
showLuckyBagNotify(playEffectInfo.getLuckyBagNoticeInfo());
break;
@@ -99,6 +132,9 @@ public class AllPlayEffectDialog extends BaseDialog {
case CustomAttachment.CUSTOM_MSG_NOTIFY_H5_SUB_WHOLE_SERVICE:
showNotifyH5BySvga(playEffectInfo.getNotifyH5());
break;
case CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY_ALL:
showTemplateNotify(playEffectInfo.getTemplateNotifyMsgBean());
break;
default:
break;
}
@@ -260,39 +296,35 @@ public class AllPlayEffectDialog extends BaseDialog {
}
}
private void showLuckyBagNotify(LuckyBagNoticeInfo luckyBagNoticeInfo) {
private void showZooNotifyBySVGA(RoomLuckySeaMsgBean roomLuckySeaMsgBean) {
SpannableBuilder text = new SpannableBuilder()
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_04),
ResUtil.getString(R.string.congratulation),
new ForegroundColorSpan(Color.WHITE)
)
.append(
subAndReplaceDot(luckyBagNoticeInfo.getNick(), 6) + " ",
new ForegroundColorSpan(ContextCompat.getColor(getContext(),R.color.notice_nick))
roomLuckySeaMsgBean.getNick() + " ",
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.color_FEF23E))
)
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_05),
ResUtil.getString(R.string.in_the_zoo),
new ForegroundColorSpan(Color.WHITE)
)
.append(
luckyBagNoticeInfo.getLuckyBagName() + " ",
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.notice_nick))
String.valueOf(roomLuckySeaMsgBean.getItemMultiple()),
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.color_00EAFF))
)
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_06),
ResUtil.getString(R.string.times_reward_get),
new ForegroundColorSpan(Color.WHITE)
)
.append(
luckyBagNoticeInfo.getGoldPrice() + " ",
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.notice_nick))
String.valueOf(roomLuckySeaMsgBean.getDiamonds()),
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.color_00EAFF))
)
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_07),
ResUtil.getString(R.string.diamond_point),
new ForegroundColorSpan(Color.WHITE)
)
.append(
luckyBagNoticeInfo.getGiftName(),
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.notice_nick))
);
SVGAImageView svgaImageView = new SVGAImageView(getContext());
svgaImageView.setLoops(1);
@@ -307,7 +339,7 @@ public class AllPlayEffectDialog extends BaseDialog {
});
binding.flSvgaNotify.addView(svgaImageView);
try {
SVGAParser.Companion.shareParser().decodeFromAssets("svga/lucky_gift_notify.svga", new SVGAParser.ParseCompletion() {
SVGAParser.Companion.shareParser().decodeFromAssets("svga/zoo_notify.svga", new SVGAParser.ParseCompletion() {
@Override
public void onComplete(@NonNull SVGAVideoEntity svgaVideoEntity) {
SVGADynamicEntity dynamicEntity = new SVGADynamicEntity();
@@ -324,13 +356,13 @@ public class AllPlayEffectDialog extends BaseDialog {
1.0f,
0.0f,
false
), "fdpp_copywriting");
), "noble_text_tx");
svgaImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//跳轉房間要移除監聽,不然可能NPE
svgaImageView.setCallback(null);
AVRoomActivity.start(getContext(), luckyBagNoticeInfo.getRoomUid());
if (!TextUtils.isEmpty(roomLuckySeaMsgBean.getSkipUrl())) {
CommonWebViewActivity.start(getContext(), roomLuckySeaMsgBean.getSkipUrl());
}
}
});
SVGADrawable drawable = new SVGADrawable(svgaVideoEntity, dynamicEntity);
@@ -349,6 +381,66 @@ public class AllPlayEffectDialog extends BaseDialog {
}
}
private void showLuckyBagNotify(LuckyBagNoticeInfo noticeInfo) {
View roomView = LayoutInflater.from(getContext())
.inflate(R.layout.layout_room_lucky_bag_notify, null);
ImageView bagImageView = roomView.findViewById(R.id.iv_bag);
bagImageView.setOnClickListener(view -> goRoom(noticeInfo.getRoomTitle(),noticeInfo.getRoomUid()));
ImageLoadUtilsV2.loadImage(bagImageView, noticeInfo.getLuckyBagGiftPic());
ImageView giftImageView = roomView.findViewById(R.id.iv_gift);
giftImageView.setOnClickListener(view -> goRoom(noticeInfo.getRoomTitle(),noticeInfo.getRoomUid()));
ImageLoadUtilsV2.loadImage(giftImageView, noticeInfo.getGiftPic());
TextView messageTextView = roomView.findViewById(R.id.tv_message);
SpannableBuilder text = new SpannableBuilder()
.append(
subAndReplaceDot(noticeInfo.getNick(), 6),
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.color_FFF45E))
)
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_027),
new ForegroundColorSpan(Color.WHITE)
)
.append(
noticeInfo.getLuckyBagName(),
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.color_FFF45E))
)
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_028),
new ForegroundColorSpan(Color.WHITE)
)
.append(
noticeInfo.getGoldPrice() + ResUtil.getString(R.string.diamond_name),
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.notice_nick))
)
.append(
ResUtil.getString(R.string.avroom_widget_roomeffectview_029),
new ForegroundColorSpan(Color.WHITE)
)
.append(
noticeInfo.getGiftName(),
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.notice_nick))
);
if (noticeInfo.getGiftNum() > 1) {
text.append(
"X" + noticeInfo.getGiftNum(),
new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.white))
);
}
messageTextView.setText(text.build());
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) binding.flSvgaNotify.getLayoutParams();
layoutParams.dimensionRatio = "375:71";
binding.flSvgaNotify.setLayoutParams(layoutParams);
binding.flSvgaNotify.addView(roomView,params);
Animation animation = AnimationUtils.loadAnimation(getContext(), R.anim.anim_box_notify);
roomView.startAnimation(animation);
disposable.add(Observable.timer(6500, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(aLong -> {
Animation animation1 = AnimationUtils.loadAnimation(getContext(), R.anim.anim_box_notify_close);
roomView.startAnimation(animation1);
}));
disposable.add(Observable.timer(7000, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(aLong -> closeSelf()));
}
private void showNotifyH5BySvga(NotifyH5Info info) {
SVGAImageView svgaImageView = new SVGAImageView(getContext());
svgaImageView.setLoops(1);
@@ -509,19 +601,208 @@ public class AllPlayEffectDialog extends BaseDialog {
}
}
private void showTemplateNotify(RoomTemplateNotifyMsgBean msgBean) {
if (msgBean == null) {
closeSelf();
return;
}
String resourceType = msgBean.getResourceType();
if (resourceType == null) {
closeSelf();
return;
}
if (resourceType.equals("IMAGE")) {
showTemplateImageNotify(msgBean);
} else if (resourceType.equals("SVGA")) {
showTemplateSvgaNotify(msgBean);
}
}
private void showTemplateImageNotify(@NonNull RoomTemplateNotifyMsgBean msgBean) {
if (msgBean.getResourceType() == null || !msgBean.getResourceType().equals("IMAGE")) {
closeSelf();
return;
}
String resourceContent = msgBean.getResourceContent();
if (resourceContent == null || resourceContent.isEmpty()) {
closeSelf();
return;
}
Runnable endAction = new Runnable() {
@Override
public void run() {
closeSelf();
}
};
View rootView = LayoutInflater.from(getContext())
.inflate(R.layout.layout_room_template_notify_image, null);
TemplateMessageAdapter adapter = new TemplateMessageAdapter(null);
TextView textView = rootView.findViewById(R.id.tv_text);
Integer textSize = msgBean.getFontSize();
if (textSize == null) {
textSize = 12;
}
textView.setTextSize(textSize);
Integer textColor = adapter.parseColor(msgBean.getTextColor());
if (textColor == null) {
textColor = Color.WHITE;
}
textView.setTextColor(textColor);
ImageView bgView = rootView.findViewById(R.id.iv_bg);
ConstraintLayout.LayoutParams params = new ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.WRAP_CONTENT);
binding.flTemplateNotify.addView(rootView, params);
GlideApp.with(bgView)
.load(resourceContent).into(new CustomTarget<Drawable>() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
adapter.convert(textView, msgBean);
bgView.setImageDrawable(resource);
Animation animation = AnimationUtils.loadAnimation(getContext(), R.anim.anim_box_notify);
rootView.startAnimation(animation);
View.OnClickListener clickAction = v -> {
Integer skipType = msgBean.getSkipType();
if (skipType == null) {
return;
}
CommonJumpHelper.bannerJump(getContext(), skipType, msgBean.getSkipContent());
};
rootView.setOnClickListener(clickAction);
textView.setOnClickListener(clickAction);
disposable.add(Observable.timer(6500, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(aLong -> {
Animation animation1 = AnimationUtils.loadAnimation(getContext(), R.anim.anim_box_notify_close);
rootView.startAnimation(animation1);
}));
disposable.add(Observable.timer(7000, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(aLong -> endAction.run()));
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
endAction.run();
}
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
super.onLoadFailed(errorDrawable);
endAction.run();
}
});
}
private void showTemplateSvgaNotify(@NonNull RoomTemplateNotifyMsgBean msgBean) {
if (msgBean.getResourceType() == null || !msgBean.getResourceType().equals("SVGA")) {
closeSelf();
return;
}
String resourceContent = msgBean.getResourceContent();
if (resourceContent == null || resourceContent.isEmpty()) {
closeSelf();
return;
}
Runnable endAction = new Runnable() {
@Override
public void run() {
closeSelf();
}
};
SVGAImageView svgaImageView = new SVGAImageView(getContext());
svgaImageView.setLoops(1);
svgaImageView.setClearsAfterDetached(true);
svgaImageView.setCallback(new SimpleSvgaCallback() {
@Override
public void onFinished() {
endAction.run();
}
});
ConstraintLayout.LayoutParams params = new ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, 0);
params.dimensionRatio = msgBean.getDimensionRatio();
if (params.dimensionRatio == null) {
params.dimensionRatio = "75:11";
}
binding.flTemplateNotify.addView(svgaImageView, params);
try {
SVGAParser.Companion.shareParser().decodeFromURL(new URL(resourceContent), new SVGAParser.ParseCompletion() {
@Override
public void onComplete(@NonNull SVGAVideoEntity svgaVideoEntity) {
TemplateMessageAdapter adapter = new TemplateMessageAdapter(null);
CharSequence text = adapter.parse(getContext(), msgBean);
if (text == null) {
text = "";
}
String textKey = msgBean.getSvgaTextKey();
int textSize = 24;
if (msgBean.getFontSize() != null) {
textSize = msgBean.getFontSize();
}
int textColor = Color.WHITE;
Integer color = adapter.parseColor(msgBean.getTextColor());
if (color != null) {
textColor = color;
}
SVGADynamicEntity dynamicEntity = new SVGADynamicEntity();
TextPaint textPaint = new TextPaint();
textPaint.setColor(textColor);//字体颜色
textPaint.setTextSize(textSize);//字体大小
dynamicEntity.setDynamicText(new StaticLayout(
text,
0,
text.length(),
textPaint,
0,
Layout.Alignment.ALIGN_CENTER,
1.0f,
0.0f,
false
), textKey);
svgaImageView.setOnClickListener(v -> {
Integer skipType = msgBean.getSkipType();
if (skipType == null) {
return;
}
CommonJumpHelper.bannerJump(getContext(), skipType, msgBean.getSkipContent());
});
SVGADrawable drawable = new SVGADrawable(svgaVideoEntity, dynamicEntity);
svgaImageView.setImageDrawable(drawable);
svgaImageView.stepToFrame(0, true);
}
@Override
public void onError() {
endAction.run();
}
}, null);
} catch (Exception e) {
e.printStackTrace();
endAction.run();
}
}
private String subAndReplaceDot(String nick, int maxLength) {
if(nick.length() > maxLength){
return nick.substring(0,maxLength)+"...";
}else {
if (nick.length() > maxLength) {
return nick.substring(0, maxLength) + "...";
} else {
return nick;
}
}
private void closeSelf() {
try {
if (disposable != null) {
disposable.dispose();
}
dismiss();
} catch (Exception e) {
e.printStackTrace();
}
}
private void goRoom(String roomTitle, long roomUid) {
if (roomUid <= 0L) {
return;
}
if (AllServiceGiftGoRoomTipsDialog.Companion.isNeedTips()) {
new AllServiceGiftGoRoomTipsDialog(getContext(), roomTitle, roomUid).show();
} else {
AVRoomActivity.start(getContext(), roomUid);
}
}
}

View File

@@ -16,6 +16,7 @@ import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import com.chuhai.utils.ServiceTime;
import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGADynamicEntity;
import com.opensource.svgaplayer.SVGAImageView;
@@ -41,6 +42,8 @@ public class AllServiceVipLevelUPDialog extends BaseDialog {
private final VipMessageInfo vipMessageInfo;
private DialogVipAllServiceLevelUpBinding binding;
private long startTime = 0;
private int frameCount = 0;
public AllServiceVipLevelUPDialog(Context context, @NonNull VipMessageInfo vipMessageInfo) {
super(context, R.style.FullScreenDialog);
@@ -77,7 +80,7 @@ public class AllServiceVipLevelUPDialog extends BaseDialog {
.append(ResUtil.getString(R.string.widget_dialog_allserviceviplevelupdialog_01), new ForegroundColorSpan(Color.WHITE))
.append("-", new CircleImageSpan(new ColorDrawable(Color.TRANSPARENT), vipMessageInfo.getAvatar(), 50, 50))
.append(" " + StringExtensionKt.sub(vipMessageInfo.getNick(), 6) + " ", new ForegroundColorSpan(getContext().getResources().getColor(R.color.notice_nick)))
.append(ResUtil.getString(R.string.widget_dialog_allserviceviplevelupdialog_02) + vipMessageInfo.getCurrVipName(), new ForegroundColorSpan(Color.WHITE)+"!");
.append(ResUtil.getString(R.string.widget_dialog_allserviceviplevelupdialog_02) + vipMessageInfo.getCurrVipName(), new ForegroundColorSpan(Color.WHITE) + "!");
SVGAImageView svgaImageView = new SVGAImageView(getContext());
svgaImageView.setLoops(1);
@@ -87,7 +90,19 @@ public class AllServiceVipLevelUPDialog extends BaseDialog {
svgaImageView.setCallback(new SimpleSvgaCallback() {
@Override
public void onFinished() {
closeSelf();
long offset = ServiceTime.INSTANCE.getTime() - startTime;
if (offset < 6000) {
int centerFrame = frameCount / 2;
if (centerFrame > 0) {
// 目前的SVGA资源最后一帧是半透明的这里强制跳到中间帧最大程度避免这种情况
svgaImageView.stepToFrame(centerFrame, false);
}
svgaImageView.postDelayed(() -> {
closeSelf();
}, 6000 - offset);
} else {
closeSelf();
}
}
});
binding.flSvgaVipNotify.addView(svgaImageView);
@@ -95,6 +110,8 @@ public class AllServiceVipLevelUPDialog extends BaseDialog {
SVGAParser.Companion.shareParser().decodeFromURL(new URL(vipMessageInfo.getFloatPic()), new SVGAParser.ParseCompletion() {
@Override
public void onComplete(@NonNull SVGAVideoEntity svgaVideoEntity) {
frameCount = svgaVideoEntity.getFrames();
startTime = ServiceTime.INSTANCE.getTime();
SVGADynamicEntity dynamicEntity = new SVGADynamicEntity();
TextPaint textPaint = new TextPaint();
textPaint.setColor(Color.WHITE);//字体颜色

View File

@@ -48,6 +48,11 @@ public class GiftIndicator extends LinearLayout {
/**背包礼物*/
public static final int TYPE_KNAP = 5;
/**个播人气礼物*/
public static final int TYPE_SING_ROOM = 6;
private Map<String, String> map = new HashMap<>();
public GiftIndicator(Context context, @Nullable AttributeSet attrs) {

View File

@@ -29,4 +29,6 @@ public interface IPagerNavigator {
* ViewPager内容改变时需要先调用此方法自定义的IPagerNavigator应当遵守此约定
*/
void notifyDataSetChanged();
int getCurrentIndex();
}

View File

@@ -303,6 +303,11 @@ public class CircleNavigator extends View implements IPagerNavigator {
mCircleClickListener = circleClickListener;
}
@Override
public int getCurrentIndex(){
return mCurrentIndex;
}
public interface OnCircleClickListener {
void onClick(int index);
}

View File

@@ -483,6 +483,11 @@ public class CommonNavigator extends FrameLayout implements IPagerNavigator, Nav
mScrollView.setFadingEdgeLength(fadingLength);
}
@Override
public int getCurrentIndex(){
return mNavigatorHelper.getCurrentIndex();
}
public interface NavigatorSelectedListener {
void navigatorSelected(int position);
}

View File

@@ -14,6 +14,7 @@ import com.yizhuan.erban.avroom.activity.AVRoomActivity;
import com.yizhuan.erban.ui.im.RouterHandler;
import com.yizhuan.erban.ui.webview.CommonWebViewActivity;
import com.yizhuan.xchat_android_core.home.bean.BannerInfo;
import com.yizhuan.xchat_android_core.home.bean.IRouterData;
import com.yizhuan.xchat_android_library.utils.JavaUtil;
/**
@@ -27,38 +28,48 @@ public class CommonJumpHelper {
*
* @param context
*/
public static void bannerJump(Context context, BannerInfo bannerInfo) {
public static void bannerJump(Context context, IRouterData bannerInfo) {
int skipType = bannerInfo.getSkipType();
if (skipType == SKIP_TYPE_ROUTER) {
bannerJump(context, JavaUtil.str2int(bannerInfo.getRouterType()), bannerInfo.getRouterValue());
} else {
bannerJump(context, skipType, bannerInfo.getSkipUri());
}
}
if (null == context || null == bannerInfo) {
/**
* 通用跳转
*
* @param context
*/
public static void bannerJump(Context context, int skipType, String skipContent) {
if (null == context) {
return;
}
int skipType = bannerInfo.getSkipType();
String url = bannerInfo.getSkipUri();
switch (skipType) {
case SKIP_TYP_APP:
if (TextUtils.isEmpty(url)) {
if (TextUtils.isEmpty(skipContent)) {
return;
}
RouterHandler.handle(context, JavaUtil.str2int(url), null);
RouterHandler.handle(context, JavaUtil.str2int(skipContent), null);
break;
case SKIP_TYP_CHAT_ROOM:
if (TextUtils.isEmpty(url)) {
if (TextUtils.isEmpty(skipContent)) {
return;
}
AVRoomActivity.start(context, JavaUtil.str2long(url));
AVRoomActivity.start(context, JavaUtil.str2long(skipContent));
break;
case SKIP_TYP_H5:
if (TextUtils.isEmpty(url)) {
if (TextUtils.isEmpty(skipContent)) {
return;
}
Intent intent = new Intent(context, CommonWebViewActivity.class);
intent.putExtra("url", url);
intent.putExtra("url", skipContent);
context.startActivity(intent);
break;
case SKIP_TYPE_ROUTER:
RouterHandler.handle(context, JavaUtil.str2int(bannerInfo.getRouterType()), bannerInfo.getRouterValue());
RouterHandler.handle(context, skipType, skipContent);
break;
default:
break;

View File

@@ -0,0 +1,78 @@
package com.yizhuan.erban.utils
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.core.view.isVisible
import com.yizhuan.erban.ui.utils.ImageLoadUtils
import com.yizhuan.xchat_android_core.user.bean.UserInfo
/**
* Created by Max on 2024/1/2 16:34
* Desc:铭牌助手
**/
object NamePlateHelper {
fun load(
viewGroup: View?,
textView: TextView,
imageView: ImageView, userInfo: UserInfo?
) {
load(
viewGroup,
textView,
imageView,
userInfo?.nameplateWord,
userInfo?.nameplatePic,
userInfo?.isCustomWord
)
}
/**
* 加载数据
* @param viewGroup 铭牌View-Layout
* @param textView 铭牌View-文本
* @param imageView 铭牌View-图片/背景
* @param word 铭牌文字
* @param pic 铭牌图片
* @param isCustom 是否自定义铭牌
*/
fun load(
viewGroup: View?,
textView: TextView,
imageView: ImageView,
word: String?,
pic: String?,
isCustom: Boolean?
) {
if (isCustom == true) {
// 自定义模式:不展示文字
load(viewGroup, textView, imageView, null, pic)
} else {
load(viewGroup, textView, imageView, word, pic)
}
}
private fun load(
viewGroup: View?,
textView: TextView,
imageView: ImageView,
word: String?,
pic: String?
) {
// 图片优先:无图片时都不展示
if (pic.isNullOrEmpty()) {
viewGroup?.isVisible = false
} else {
imageView.isVisible = true
ImageLoadUtils.loadImage(imageView, pic)
if (!word.isNullOrEmpty()) {
textView.text = word
textView.isVisible = true
} else {
textView.isVisible = false
}
viewGroup?.isVisible = true
}
}
}

View File

@@ -42,6 +42,27 @@ public class SpannableBuilder {
return this;
}
/**
* 支持多個spannable 對同一段文字修改
*
* @param text
* @param what
* @return
*/
public SpannableBuilder append(CharSequence text, Object... what) {
if (TextUtils.isEmpty(text)) return this;
int start = builder.length();
builder.append(text);
for (int i = 0; i < what.length; i++) {
Object o = what[i];
if (o == null) {
continue;
}
builder.setSpan(what[i], start, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}
return this;
}
public SpannableStringBuilder build() {
return builder;
}

View File

@@ -9,8 +9,10 @@ import android.widget.LinearLayout
import android.widget.TextView
import androidx.activity.viewModels
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.children
import androidx.core.view.isInvisible
import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager
import com.android.billingclient.api.BillingClient
import com.android.billingclient.api.BillingResult
@@ -25,6 +27,7 @@ import com.opensource.svgaplayer.SVGADrawable
import com.opensource.svgaplayer.SVGAImageView
import com.opensource.svgaplayer.SVGAParser
import com.opensource.svgaplayer.SVGAVideoEntity
import com.yizhuan.erban.BuildConfig
import com.yizhuan.erban.R
import com.yizhuan.erban.base.BaseViewBindingActivity
import com.yizhuan.erban.base.TitleBar
@@ -39,12 +42,12 @@ import com.yizhuan.erban.ui.webview.CommonWebViewActivity
import com.yizhuan.erban.ui.widget.magicindicator.buildins.commonnavigator.CommonNavigator
import com.yizhuan.erban.vip.adapter.VipAuthAdapter
import com.yizhuan.erban.vip.adapter.VipMagicIndicatorAdapter
import com.yizhuan.erban.vip.adapter.VipRebateAdapter
import com.yizhuan.erban.vip.dialog.SelectPayTypeDialog
import com.yizhuan.erban.vip.dialog.VipAuthDetailsDialog
import com.yizhuan.erban.vip.dialog.VipRemainTimeDialog
import com.yizhuan.xchat_android_core.Constants
import com.yizhuan.xchat_android_core.UriProvider
import com.yizhuan.xchat_android_core.auth.AuthModel
import com.yizhuan.xchat_android_core.pay.PayModel
import com.yizhuan.xchat_android_core.pay.bean.ChargeBean
import com.yizhuan.xchat_android_core.pay.bean.PayRecordId
@@ -56,6 +59,8 @@ import com.yizhuan.xchat_android_core.vip.VipOpenEvent
import com.yizhuan.xchat_android_library.common.util.DeviceUtil
import com.yizhuan.xchat_android_library.utils.AppMetaDataUtil
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
@@ -81,8 +86,9 @@ class VipMainActivity : BaseViewBindingActivity<ActivityVipMainBinding>(),
private lateinit var rvDelegate: RVDelegate<VipAuthInfo>
private val vipViewModel: VipViewModel by viewModels()
private var billingManager: BillingManager? = null
private var googleChargeBean: ChargeBean? = null//google
private var chargeInfo: ChargeBean? = null//official
private var currentChargeInfo: ChargeBean? = null
private var chargeList: List<ChargeBean>? = null
private val rebateAdapter = VipRebateAdapter()
@SuppressLint("SetTextI18n")
override fun init() {
@@ -93,7 +99,8 @@ class VipMainActivity : BaseViewBindingActivity<ActivityVipMainBinding>(),
CommonWebViewActivity.start(this@VipMainActivity, UriProvider.getVipHelpUrl())
}
})
initView()
initObserve()
binding.ivRankList.setOnClickListener {
CommonWebViewActivity.start(this@VipMainActivity, UriProvider.getRankListUrl())
}
@@ -142,8 +149,8 @@ class VipMainActivity : BaseViewBindingActivity<ActivityVipMainBinding>(),
vipViewModel.myVipInfoLiveData.observe(this) {
it?.let {
binding.llMyVipInfo.isVisible = true
binding.tvOpenVip.isVisible = false
binding.layoutLevelInfo.isVisible = true
binding.layoutLevelProgress.isVisible = true
binding.tvNotOpen.text =
"${getString(R.string.me_current_power_value)}${it.currScore}"
binding.tvCurrValue.text = "${getString(R.string.me_current)}${it.currScore}"
@@ -185,16 +192,10 @@ class VipMainActivity : BaseViewBindingActivity<ActivityVipMainBinding>(),
}
} ?: run {
binding.llMyVipInfo.isVisible = false
binding.tvOpenVip.isVisible = true
binding.layoutLevelInfo.isVisible = false
binding.layoutLevelProgress.isVisible = false
binding.slAuth.isVisible = true
binding.tvNotOpen.text = getString(R.string.me_no_aristocracy_yet)
val channel = AppMetaDataUtil.getChannelID()
if (channel.equals(Constants.GOOGLE)) {
initBilling()
} else {
loadData()
}
}
}
@@ -203,10 +204,12 @@ class VipMainActivity : BaseViewBindingActivity<ActivityVipMainBinding>(),
if (it.comingSoon == 2) {
binding.llNotOpen.isVisible = true
binding.slAuth.isVisible = false
binding.layoutBottomPanel.isVisible = false
loadSVGA(binding.ivNotOpenIcon, it.vipLogo)
} else {
binding.slAuth.isVisible = true
binding.llNotOpen.isVisible = false
binding.layoutBottomPanel.isVisible = true
val myVipInfo = vipViewModel.myVipInfoLiveData.value
binding.ivMyLevel.isInvisible = it.vipLevel != myVipInfo?.vipLevel
binding.tvNotOpen.isInvisible =
@@ -216,6 +219,8 @@ class VipMainActivity : BaseViewBindingActivity<ActivityVipMainBinding>(),
"${it.ownAuthTypes?.size ?: 0}/${vipViewModel.authInfosLiveData.value?.size ?: 0}"
authAdapter.setVipInfo(it)
authAdapter.notifyDataSetChanged()
loadRebateData(it)
refreshOpenVipState()
}
} ?: run {
getString(R.string.me_failed_to_get_aristocrat_data).toast()
@@ -232,78 +237,24 @@ class VipMainActivity : BaseViewBindingActivity<ActivityVipMainBinding>(),
}
binding.tvOpenVip.setOnClickListener {
if (AppMetaDataUtil.getChannelID().equals(Constants.GOOGLE)) {
if ((googleChargeBean?.productDetails?.oneTimePurchaseOfferDetails?.priceAmountMicros ?: "0") == "0") {
toast(getString(R.string.Recharge_failure))
return@setOnClickListener
}
SelectPayTypeDialog.newInstance(
googleChargeBean?.productDetails?.oneTimePurchaseOfferDetails?.formattedPrice ?: "0",
true,
googleChargeBean?.getMoney() ?: 0.0
)
.apply {
setOnDiamondChargeClick {
vipViewModel.openVipWithDiamond()
}
setOnGoogleChargeClick {
googleChargeBean?.let { charge ->
buyProduct(charge.productDetails)
}
}
setOnChargeClick {
if (AppMetaDataUtil.getChannelID().equals(Constants.GOOGLE)) {
ChargeActivity.start(this@VipMainActivity)
} else {
CommonWebViewActivity.start(
this@VipMainActivity, UriProvider.getOfficialPay(
4,
DeviceUtil.getDeviceId(this@VipMainActivity)
)
)
}
}
}
.show(context)
} else {
SelectPayTypeDialog.newInstance(
((chargeInfo?.getMoney() ?: 0.0) * 1000).toInt().toString(),
false,
chargeInfo?.getMoney() ?: 0.0
)
.apply {
setOnDiamondChargeClick {
vipViewModel.openVipWithDiamond()
}
setOnChargeClick {
if (AppMetaDataUtil.getChannelID().equals(Constants.GOOGLE)) {
ChargeActivity.start(this@VipMainActivity)
} else {
CommonWebViewActivity.start(
this@VipMainActivity, UriProvider.getOfficialPay(
4,
DeviceUtil.getDeviceId(this@VipMainActivity)
)
)
}
}
}
.show(context)
checkBuyVip {
buyVip()
}
}
if (isGoogleChannel()) {
initBilling()
} else {
loadData()
}
}
@SuppressLint("CheckResult", "SetTextI18n")
private fun loadData() {
PayModel.get().getChargeList(2, AuthModel.get().currentUid)
.compose(bindToLifecycle())
PayModel.get().vipList.compose(bindToLifecycle())
.subscribe(
{
chargeInfo = it.list.getOrNull(0)
chargeInfo?.let { chargeBean ->
binding.tvOpenVip.text =
"${chargeBean.getMoney()}${getString(R.string.me_immediately_become_a_Peko_nobleman)}"
}
loadChargeList(it)
}, {
it.printStackTrace()
}
@@ -330,17 +281,13 @@ class VipMainActivity : BaseViewBindingActivity<ActivityVipMainBinding>(),
* 初始化推荐和派对tab
*/
private fun initTitleTab(vipInfos: List<VipInfo>) {
val tagList: MutableList<String> = ArrayList()
vipInfos.forEach {
tagList.add(it.vipName)
}
val commonNavigator = CommonNavigator(context)
commonNavigator.isEnablePivotScroll = true
commonNavigator.isFollowTouch = false
val magicIndicatorAdapter =
VipMagicIndicatorAdapter(
context,
tagList
vipInfos
)
magicIndicatorAdapter.setOnItemSelectListener(this)
commonNavigator.adapter = magicIndicatorAdapter
@@ -388,39 +335,33 @@ class VipMainActivity : BaseViewBindingActivity<ActivityVipMainBinding>(),
@SuppressLint("CheckResult", "SetTextI18n")
override fun onBillingClientSetupFinished() {
Log.i(TAG, "onBillingClientSetupFinished")
PayModel.get().getChargeList(2, AuthModel.get().currentUid)
.compose(bindToLifecycle())
PayModel.get().vipList.compose(bindToLifecycle())
.subscribe(
{
val chargeInfo = it.list.getOrNull(0)
chargeInfo?.let { chargeBean ->
val productKeys: MutableList<String> = ArrayList()
productKeys.add(chargeBean.getChargeProdId())
billingManager?.querySkuDetailsAsync(productKeys) { billingResult: BillingResult, productDetails: List<ProductDetails> ->
if (billingResult.responseCode != BillingClient.BillingResponseCode.OK) {
Log.w(
TAG,
"Unsuccessful query for type: " + BillingClient.SkuType.INAPP
+ ". Error code: " + billingResult.responseCode
)
} else if (productDetails.isNotEmpty()) {
val showChargeList: MutableList<ChargeBean> = ArrayList()
val list = it
loadChargeList(list)
val productKeys = ArrayList<String>()
list.forEach {
productKeys.add(it.getChargeProdId())
}
billingManager?.querySkuDetailsAsync(productKeys) { billingResult: BillingResult, productDetails: List<ProductDetails> ->
if (billingResult.responseCode != BillingClient.BillingResponseCode.OK) {
Log.w(
TAG,
"Unsuccessful query for type: " + BillingClient.SkuType.INAPP
+ ". Error code: " + billingResult.responseCode
)
} else if (productDetails.isNotEmpty()) {
for (item in list) {
for (skuDetails in productDetails) {
if (skuDetails.productId == chargeBean.getChargeProdId()) {
chargeBean.productDetails = skuDetails
showChargeList.add(chargeBean)
if (skuDetails.productId == item.getChargeProdId()) {
item.productDetails = skuDetails
break
}
}
if (showChargeList.size > 0) {
googleChargeBean = showChargeList[0]
binding.tvOpenVip.text = "${
googleChargeBean?.getMoney()
}${getString(R.string.me_immediately_become_a_Peko_nobleman)}"
}
}
loadChargeList(list)
}
}
}, {
it.printStackTrace()
@@ -447,18 +388,20 @@ class VipMainActivity : BaseViewBindingActivity<ActivityVipMainBinding>(),
//L.i("token=" + token);
billingManager?.consumeAsync(token)
var skuDetails: ProductDetails? = null
if (googleChargeBean?.getChargeProdId() == purchase.products[0]) {
skuDetails = googleChargeBean?.productDetails
if (currentChargeInfo?.getChargeProdId() == purchase.products[0]) {
skuDetails = currentChargeInfo?.productDetails
}
if (skuDetails != null) {
val eventValue: MutableMap<String, Any> =
HashMap()
eventValue[AFInAppEventParameterName.CONTENT_TYPE] = "Gold"
eventValue[AFInAppEventParameterName.QUANTITY] = 1
eventValue[AFInAppEventParameterName.CONTENT_ID] = purchase.orderId!!
eventValue[AFInAppEventParameterName.CONTENT_ID] =
purchase.orderId!!
eventValue[AFInAppEventParameterName.REVENUE] =
skuDetails.oneTimePurchaseOfferDetails?.priceAmountMicros!! / 1000000f
eventValue["Price"] = skuDetails.oneTimePurchaseOfferDetails?.formattedPrice!!
eventValue["Price"] =
skuDetails.oneTimePurchaseOfferDetails?.formattedPrice!!
eventValue[AFInAppEventParameterName.CURRENCY] =
skuDetails.oneTimePurchaseOfferDetails?.priceCurrencyCode!!
AppsFlyerLib.getInstance().logEvent(
@@ -521,8 +464,7 @@ class VipMainActivity : BaseViewBindingActivity<ActivityVipMainBinding>(),
super.onDestroy()
EventBus.getDefault().unregister(this)
billingManager?.destroy()
googleChargeBean = null
chargeInfo = null
currentChargeInfo = null
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
@@ -536,5 +478,179 @@ class VipMainActivity : BaseViewBindingActivity<ActivityVipMainBinding>(),
}
}
private fun initView() {
binding.tvTabPrivilege.setOnClickListener {
showPrivilegeTab()
}
binding.tvTabRebate.setOnClickListener {
showRebateTab()
}
rebateAdapter.onGetListener = {
vipViewModel.getVipRebate(it)
}
binding.rvRebate.isNestedScrollingEnabled = false
binding.rvRebate.adapter = rebateAdapter
}
private fun initObserve(){
lifecycleScope.launch(Dispatchers.Main) {
vipViewModel.getVipRebateSuccessFlow.collect {
rebateAdapter.notifyItemRangeChanged(0, rebateAdapter.itemCount, true)
}
}
}
private fun showPrivilegeTab() {
binding.layoutRebate.isInvisible = true
binding.groupPrivilege.isInvisible = false
binding.tvTabPrivilege.setBackgroundResource(R.drawable.vip_bg_tab_selected)
binding.tvTabRebate.setBackgroundResource(R.drawable.vip_bg_tab_unselected)
}
private fun showRebateTab() {
binding.groupPrivilege.isInvisible = true
binding.layoutRebate.isInvisible = false
binding.tvTabPrivilege.setBackgroundResource(R.drawable.vip_bg_tab_unselected)
binding.tvTabRebate.setBackgroundResource(R.drawable.vip_bg_tab_selected)
}
private fun loadChargeList(list: List<ChargeBean>) {
this.chargeList = list
refreshOpenVipState()
}
private fun loadRebateData(info: VipInfo) {
binding.tvTableLevelName.text = info.vipName
binding.tvRebateTips1.text =
context.getString(R.string.vip_buy_tips_format).format(info.vipName)
rebateAdapter.setNewData(info.returnProfits)
val isNormalStatus = info.isRebate()
binding.layoutRebate.children.forEach {
if(it == binding.tvRebateDisableStatus){
it.isVisible = !isNormalStatus
}else{
it.isVisible = isNormalStatus
}
}
}
private fun refreshOpenVipState() {
val currentVipInfo = vipViewModel.currVipInfoLiveData.value
val myVipInfo = vipViewModel.myVipInfoLiveData.value
if (currentVipInfo != null) {
currentChargeInfo = chargeList?.firstOrNull {
it.prodDesc?.toIntOrNull() == currentVipInfo.vipLevel
}
if (currentChargeInfo != null && (myVipInfo == null || myVipInfo.vipLevel < currentVipInfo.vipLevel)) {
binding.tvOpenVip.text =
"${currentChargeInfo?.getMoney()} ${
getString(R.string.vip_buy_format).format(
currentVipInfo.vipName
)
}"
binding.tvOpenVip.isVisible = true
} else {
binding.tvOpenVip.isVisible = false
}
} else {
currentChargeInfo = null
binding.tvOpenVip.isVisible = false
}
if (binding.tvOpenVip.isVisible && binding.layoutLevelProgress.isVisible) {
binding.layoutBottomPanel.setBackgroundDrawable(binding.layoutLevelProgress.background)
} else {
binding.layoutBottomPanel.setBackgroundDrawable(null)
}
}
private fun checkBuyVip(block: () -> Unit) {
val myVipInfo = vipViewModel.myVipInfoLiveData.value
val currentVipInfo = vipViewModel.currVipInfoLiveData.value
if (currentVipInfo != null && myVipInfo != null && currentVipInfo.vipLevel > myVipInfo.vipLevel) {
val message = context.getString(R.string.vip_buy_tips).format(
myVipInfo.vipName,currentVipInfo.vipName
)
dialogManager.showOkCancelDialog(message,
context.getString(R.string.miniworld_activity_mwteamroommessageact_07),
context.getString(R.string.miniworld_activity_mwteamroommessageact_08),
true
) { block.invoke() }
} else {
block.invoke()
}
}
private fun buyVip(){
if (isGoogleChannel()) {
if ((currentChargeInfo?.productDetails?.oneTimePurchaseOfferDetails?.priceAmountMicros
?: "0") == "0"
) {
toast(getString(R.string.Recharge_failure))
return
}
SelectPayTypeDialog.newInstance(
currentChargeInfo?.productDetails?.oneTimePurchaseOfferDetails?.formattedPrice
?: "0",
true,
currentChargeInfo?.getMoney() ?: 0.0
)
.apply {
setOnDiamondChargeClick {
vipViewModel.openVipWithDiamond(
currentChargeInfo?.getProdDesc()?.toIntOrNull() ?: -1)
}
setOnGoogleChargeClick {
currentChargeInfo?.let { charge ->
buyProduct(charge.productDetails)
}
}
setOnChargeClick {
if (isGoogleChannel()) {
ChargeActivity.start(this@VipMainActivity)
} else {
CommonWebViewActivity.start(
this@VipMainActivity, UriProvider.getOfficialPay(
4,
DeviceUtil.getDeviceId(this@VipMainActivity)
)
)
}
}
}
.show(context)
} else {
SelectPayTypeDialog.newInstance(
((currentChargeInfo?.getMoney() ?: 0.0) * 1000).toInt().toString(),
false,
currentChargeInfo?.getMoney() ?: 0.0
)
.apply {
setOnDiamondChargeClick {
vipViewModel.openVipWithDiamond(
currentChargeInfo?.getProdDesc()?.toIntOrNull() ?: -1
)
}
setOnChargeClick {
if (isGoogleChannel()) {
ChargeActivity.start(this@VipMainActivity)
} else {
CommonWebViewActivity.start(
this@VipMainActivity, UriProvider.getOfficialPay(
4,
DeviceUtil.getDeviceId(this@VipMainActivity)
)
)
}
}
}
.show(context)
}
}
private fun isGoogleChannel(): Boolean {
if (BuildConfig.DEBUG) {
return false
}
return AppMetaDataUtil.getChannelID().equals(Constants.GOOGLE)
}
}

View File

@@ -5,8 +5,6 @@ import androidx.lifecycle.MutableLiveData
import com.yizhuan.erban.R
import com.yizhuan.erban.base.BaseViewModel
import com.yizhuan.xchat_android_core.bean.response.BeanResult
import com.yizhuan.xchat_android_core.home.model.HomeModel
import com.yizhuan.xchat_android_core.module_hall.hall.HallModel
import com.yizhuan.xchat_android_core.user.UserInfoUiMgr
import com.yizhuan.xchat_android_core.user.UserModel
import com.yizhuan.xchat_android_core.utils.toast
@@ -14,21 +12,23 @@ import com.yizhuan.xchat_android_core.vip.VipAuthInfo
import com.yizhuan.xchat_android_core.vip.VipBroadcastInfo
import com.yizhuan.xchat_android_core.vip.VipInfo
import com.yizhuan.xchat_android_core.vip.VipModel
import com.yizhuan.xchat_android_core.vip.VipRebateInfo
import com.yizhuan.xchat_android_library.utils.ResUtil
import kotlinx.coroutines.flow.MutableSharedFlow
class VipViewModel : BaseViewModel() {
val userId: Long by lazy {
UserInfoUiMgr.get().uid
}
private val _authInfosLiveData = MutableLiveData<List<VipAuthInfo>>()
val authInfosLiveData: LiveData<List<VipAuthInfo>> = _authInfosLiveData
private val _authInfosLiveData = MutableLiveData<List<VipAuthInfo>?>()
val authInfosLiveData: LiveData<List<VipAuthInfo>?> = _authInfosLiveData
private val _vipInfosLiveData = MutableLiveData<List<VipInfo>>()
val vipInfosLiveData: LiveData<List<VipInfo>> = _vipInfosLiveData
private val _vipInfosLiveData = MutableLiveData<List<VipInfo>?>()
val vipInfosLiveData: LiveData<List<VipInfo>?> = _vipInfosLiveData
private val _myVipInfoLiveData = MutableLiveData<VipInfo>()
val myVipInfoLiveData: LiveData<VipInfo> = _myVipInfoLiveData
private val _myVipInfoLiveData = MutableLiveData<VipInfo?>()
val myVipInfoLiveData: LiveData<VipInfo?> = _myVipInfoLiveData
private val _currVipInfoLiveData = MutableLiveData<VipInfo>()
val currVipInfoLiveData: LiveData<VipInfo> = _currVipInfoLiveData
@@ -48,6 +48,8 @@ class VipViewModel : BaseViewModel() {
private val _enterHideLiveData = MutableLiveData<Boolean>()
val enterHideLiveData: LiveData<Boolean> = _enterHideLiveData
val getVipRebateSuccessFlow = MutableSharedFlow<VipRebateInfo>()
// private val _sendBroadcastLiveData = MutableLiveData<Boolean>()
// val sendBroadcastLiveData: LiveData<Boolean> = _sendBroadcastLiveData
@@ -166,10 +168,17 @@ class VipViewModel : BaseViewModel() {
_pageLiveData.value = position
}
fun openVipWithDiamond() {
fun openVipWithDiamond(vipLevel: Int) {
safeLaunch(true) {
VipModel.openVipWithDiamond()
VipModel.openVipWithDiamond(vipLevel)
}
}
fun getVipRebate(rebateInfo: VipRebateInfo) {
safeLaunch(true) {
VipModel.getVipRebate(rebateInfo.returnProfitRecordId ?: 0L)
rebateInfo.isReceive = true
getVipRebateSuccessFlow.emit(rebateInfo)
}
}
}

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