红包需求

This commit is contained in:
oujunhui
2020-07-08 19:11:08 +08:00
parent ddc4b11249
commit 0fd426436c
15 changed files with 103 additions and 37 deletions

View File

@@ -38,7 +38,7 @@ import com.opensource.svgaplayer.SVGAParser;
import com.opensource.svgaplayer.SVGAVideoEntity;
import com.orhanobut.logger.Logger;
import com.yinyuan.xchat_android_core.redpackage.RedPackageModel;
import com.yinyuan.xchat_android_core.redpackage.RedPackageNotifyInfo;
import com.yizhuan.xchat_android_core.redpackage.RedPackageNotifyInfo;
import com.yizhuan.erban.R;
import com.yizhuan.erban.avroom.fragment.AbsRoomFragment;
import com.yizhuan.erban.avroom.fragment.HomePartyFragment;
@@ -93,7 +93,6 @@ import com.yizhuan.xchat_android_core.patriarch.event.CloseMinRoomEvent;
import com.yizhuan.xchat_android_core.patriarch.event.ImPushMsgPmLimitTimeEvent;
import com.yizhuan.xchat_android_core.patriarch.event.PmDismissAllLimitDialogEvent;
import com.yizhuan.xchat_android_core.patriarch.exception.PmRoomLimitException;
import com.yizhuan.xchat_android_core.redPacket.bean.ActionDialogInfo;
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
import com.yizhuan.xchat_android_core.room.bean.SimplePartyRoomInfo;
import com.yizhuan.xchat_android_core.room.dragonball.DragonBallModel;
@@ -156,6 +155,9 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
public static final int FROM_TYPE_NORMAL_BROADCAST = 4;//通过普通广播进房
public static final int FROM_TYPE_ALL_RED = 5;//通过全服红包进房
private int fromType = FROM_TYPE_NORMAL;// 入口类型 0 其他 1 萌圈 2 个人主页或者广场
private String workAuthor = "";// 从萌圈进入时 需要传入作品发布者的昵称
private SVGAImageView svgaRoomBg;
private RelativeLayout finishLayout;
private ViewStub mVsRoomOffline;
@@ -263,6 +265,8 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
setIntent(intent);
// 如果是同一个房间,则只更新房间的信息
long newRoomUid = intent.getLongExtra(Constants.ROOM_UID, 0);
fromType = intent.getIntExtra("fromType", 0);
workAuthor = intent.getStringExtra("workAuthor");
boolean isParty = getIntent().getBooleanExtra(Constants.IS_PARTY, false);
//从嗨聊房进入
if (isParty) {
@@ -305,7 +309,11 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
if (roomUid != AuthModel.get().getCurrentUid()) {
StatisticManager.Instance().onEvent(StatisticsProtocol.Event.EVENT_ENTERROOM, "进入别人房间");
}
if (mCurrentFragment != null) {
getSupportFragmentManager().beginTransaction()
.remove(mCurrentFragment).commitAllowingStateLoss();
mCurrentFragment = null;
}
// 相同类型的房间,但是是不同人的房间
@@ -646,7 +654,7 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
mAdapter.setmFragmentList(fragmentList);
mAdapter.notifyDataSetChanged();
}
showRedPackage(roomInfo);
getMvpPresenter().getActionDialog(2);
}
@@ -878,7 +886,7 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
mPwdDialogFragment.setOnDialogBtnClickListener(new InputPwdDialogFragment.OnDialogBtnClickListener() {
@Override
public void onBtnConfirm() {
getMvpPresenter().enterRoom(roomInfo);
getMvpPresenter().enterRoom(roomInfo, fromType, workAuthor);
}
@Override
@@ -1105,7 +1113,7 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
// 超管绕过密码直接进房
if (SuperAdminUtil.isSuperAdmin()) {
getMvpPresenter().enterRoom(roomInfo);
getMvpPresenter().enterRoom(roomInfo, fromType, workAuthor);
return;
}
@@ -1129,11 +1137,11 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
// cp房切换嗨聊房不会先清屏防止用户点击取消按钮不进行切换房间操作但是公屏被清的情况
EventBus.getDefault().post(new RoomClearScreenEvent());
getMvpPresenter().enterRoom(roomInfo);
getMvpPresenter().enterRoom(roomInfo, fromType, workAuthor);
}
});
} else {
getMvpPresenter().enterRoom(roomInfo);
getMvpPresenter().enterRoom(roomInfo, fromType, workAuthor);
}
} else {
if (isFinishing()) {

View File

@@ -112,7 +112,7 @@ public class AvRoomPresenter extends BaseMvpPresenter<IAvRoomView> {
/**
* 进入云信聊天室回调
*/
public void enterRoom(RoomInfo roomInfo) {
public void enterRoom(RoomInfo roomInfo, int fromType, String workAuthor) {
if (roomInfo == null) {
if (getMvpView() != null)
getMvpView().showFinishRoomView();
@@ -146,7 +146,7 @@ public class AvRoomPresenter extends BaseMvpPresenter<IAvRoomView> {
StatisticManager.Instance().onEvent(StatisticsProtocol.Event.EVENT_ROOM_LIST_TYPE,
"区分房间类型:" + roomInfo.getRoomTypeLable());
Observable<EnterChatRoomResultData> enterRoomObservable = mAvRoomModel.enterRoom(roomInfo.getRoomId(), 3);
Observable<EnterChatRoomResultData> enterRoomObservable = mAvRoomModel.enterRoom(roomInfo.getRoomId(), 3, fromType, workAuthor);
Disposable subscribe = enterRoomObservable.flatMap(this::dealServerMicInfo)
.map(this::dealMicMemberFromIMNet)

View File

@@ -5,7 +5,7 @@ import android.view.LayoutInflater
import android.view.WindowManager
import android.view.animation.AnimationUtils
import com.yinyuan.xchat_android_core.redpackage.RedPackageNotifyInfo
import com.yizhuan.xchat_android_core.redpackage.RedPackageNotifyInfo
import com.yizhuan.erban.R
import com.yizhuan.erban.avroom.activity.AVRoomActivity

View File

@@ -24,13 +24,13 @@ import com.yizhuan.erban.R
import com.yizhuan.erban.avroom.widget.MessageView
import com.yizhuan.erban.base.BaseDialog
import com.yizhuan.erban.databinding.DialogGameResultBinding
import com.yizhuan.erban.databinding.DialogRedPackageOpenBinding
import com.yizhuan.erban.ui.utils.ImageLoadUtils
import com.yizhuan.erban.utils.UserUtils
import com.yizhuan.xchat_android_core.DemoCache
import com.yizhuan.xchat_android_core.redpackage.ALL_DIAMOND
import com.yizhuan.xchat_android_core.redpackage.ALL_GIFT
import com.yizhuan.xchat_android_core.redpackage.RedPackageNotifyInfo
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
class RedPackageOpenDialog : BaseDialog<DialogRedPackageOpenBinding>() {

View File

@@ -842,13 +842,13 @@ public class MessageView extends FrameLayout {
case ALL_DIAMOND:
case ROOM_DIAMOND:
text.append("的红包领取了", new ForegroundColorSpan(textColor))
.append(roomMsg.getAmount() + "水晶", new ForegroundColorSpan(roomTipColor));
.append(roomMsg.getAmount() + "钻石", new ForegroundColorSpan(roomTipColor));
tvContent.setText(text.build());
break;
case ALL_GIFT:
case ROOM_GIFT:
text.append("的红包领取了价值", new ForegroundColorSpan(textColor))
.append(roomMsg.getAmount() + "", new ForegroundColorSpan(roomTipColor))
.append(roomMsg.getAmount() + "", new ForegroundColorSpan(roomTipColor))
.append("的礼物", new ForegroundColorSpan(textColor));
tvContent.setText(text.build());
}
@@ -2004,29 +2004,30 @@ public class MessageView extends FrameLayout {
* @param tvContent -
*/
private void setMsgNotification(ChatRoomMessage chatRoomMessage, TextView tvContent, int position) {
int fromType = 0;
String workAuthor = "";
Map<String, Object> remoteExtension = chatRoomMessage.getRemoteExtension();
if (remoteExtension != null) {
fromType = (int) remoteExtension.get("fromType");
workAuthor = (String) remoteExtension.get("workAuthor");
}
ChatRoomNotificationAttachment attachment = (ChatRoomNotificationAttachment) chatRoomMessage.getAttachment();
String senderNick = "";
List<String> nicks = attachment.getTargetNicks();
if (nicks != null && nicks.size() > 0)
senderNick = RegexUtil.getPrintableString(attachment.getTargetNicks().get(0));
if (attachment.getType() != NotificationType.ChatRoomMemberIn) return;
// 勋章
//String userBadge = NobleUtil.getResource(NobleResourceType.KEY_BADGE, chatRoomMessage);
//String userLevel = NobleUtil.getLevel(UserLevelResourceType.EXPER_URL, chatRoomMessage);
boolean newUser = NobleUtil.getIsNewUser(UserInfo.IS_NEW_USER, chatRoomMessage);
boolean isOfficial = NobleUtil.getIsOfficial(UserInfo.IS_OFFICIAL, chatRoomMessage);
// 座驾
String carName = NobleUtil.getCarName(CarInfo.CAR_NAME, chatRoomMessage);
boolean newUser = NobleUtil.getIsNewUser(UserInfo.IS_NEW_USER, chatRoomMessage);
boolean isOfficial = NobleUtil.getIsOfficial(UserInfo.IS_OFFICIAL, chatRoomMessage);
carName = TextUtils.isEmpty(carName) ? "" : "\"" + carName + "\"";
SpannableBuilder text = new SpannableBuilder(tvContent)
.append(isOfficial ? ResourcesCompat.getDrawable(getResources(),
R.mipmap.ic_user_official_13dp, null) : null,
badgeWidth, badgeHeight)
.append(newUser ? Constants.NEW_USER_ICON : "", badgeWidth, badgeHeight);
//2018.12.24 @测试 陈陈琳,进房不显示贵族勋章
// .append(NobleUtil.getLocalResourcePath(userBadge), badgeWidth, badgeHeight)
// .append(userLevel, expLevelWidth, expLevelHeight)
String ivNamePlate = NobleUtil.getNamePlate(UserInfo.NAMEPLATE_PIC, chatRoomMessage);
String tvNamePlate = NobleUtil.getNamePlate(UserInfo.NAMEPLATE_WORD, chatRoomMessage);
@@ -2043,8 +2044,13 @@ public class MessageView extends FrameLayout {
.doOnSuccess(clickConsumer).subscribe();
}
}
})
.append(TextUtils.isEmpty(carName) ? "" : " 驾着 ", new ForegroundColorSpan(greyColor))
});
if (fromType == AVRoomActivity.FROM_TYPE_ALL_RED){
text.append("")
.append(workAuthor)
.append("的红包");
}
text.append(TextUtils.isEmpty(carName) ? "" : " 驾着 ", new ForegroundColorSpan(greyColor))
.append(carName, new ForegroundColorSpan(roomTipColor))
.append(" 进入了房间 ", new ForegroundColorSpan(greyColor));
@@ -2095,6 +2101,16 @@ public class MessageView extends FrameLayout {
tvContent.setMovementMethod(new LinkMovementMethod());
}
private SpannableBuilder getNotificationBuilder(TextView tvContent, String senderNick, String desc, String tagNick, String carName) {
return new SpannableBuilder(tvContent)
.append(senderNick, new ForegroundColorSpan(roomTipColor))
.append(desc, new ForegroundColorSpan(textColor))
.append(tagNick, new ForegroundColorSpan(roomTipColor))
.append((TextUtils.isEmpty(carName) ? "" : " 驾着 "))
.append(carName, new ForegroundColorSpan(roomTipColor))
.append("进入了房间", new ForegroundColorSpan(textColor));
}
/**
* 恭喜 xxx 在房间内 续费/开通 "皇帝"
*

View File

@@ -36,7 +36,7 @@ import com.readystatesoftware.systembartint.SystemBarTintManager;
import com.tbruyelle.rxpermissions2.RxPermissions;
import com.trello.rxlifecycle3.android.ActivityEvent;
import com.trello.rxlifecycle3.components.support.RxAppCompatActivity;
import com.yinyuan.xchat_android_core.redpackage.RedPackageNotifyInfo;
import com.yizhuan.xchat_android_core.redpackage.RedPackageNotifyInfo;
import com.yizhuan.erban.MiddleActivity;
import com.yizhuan.erban.NimMiddleActivity;
import com.yizhuan.erban.R;

View File

@@ -7,7 +7,7 @@ import com.coorchice.library.utils.LogUtils;
import com.netease.nim.uikit.business.session.viewholder.MsgViewHolderBase;
import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
import com.yinyuan.xchat_android_core.redpackage.RedPackageNotifyInfo;
import com.yizhuan.xchat_android_core.redpackage.RedPackageNotifyInfo;
import com.yizhuan.erban.R;
import com.yizhuan.erban.avroom.activity.AVRoomActivity;
import com.yizhuan.erban.common.widget.dialog.DialogManager;

View File

@@ -92,6 +92,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_IM_GAME;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_MODULE_HALL;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_PUBLIC_CHAT_HALL;
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_SHARE_FAMILY;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SHARE_ROOM;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SHARE_TEAM;
@@ -400,6 +401,8 @@ public class RecentListFragment extends BaseFragment {
return "[声音瓶子审核消息]";
} else if (WorldDynamicAttachment.isShareMsg(customAttachment)) {
return "[分享一条动态]";
}else if (customAttachment.getFirst() == CUSTOM_MSG_RED_PACKAGE){
return "[您收到一个全服红包]";
}
} else if (attachment instanceof AudioAttachment) {
return "[语音]";

View File

@@ -113,14 +113,14 @@
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.098" />
app:layout_constraintGuide_percent="0.0682" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/line1_opened"
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.1956" />
app:layout_constraintGuide_percent="0.1756" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/line2_opened"
@@ -169,6 +169,7 @@
tools:text="88"
android:textColor="#454545"
android:textSize="40sp"
android:includeFontPadding="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
@@ -256,13 +257,13 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="抢完了,下次来早点哦"
android:textColor="#ffffffff"
android:textSize="20sp"
android:textColor="@color/color_666666"
android:textSize="16sp"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/tv_red_num"
app:layout_constraintBottom_toBottomOf="@id/tv_diamond_num"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_content_opened" />
/>
<TextView
android:id="@+id/tv_red_num"

View File

@@ -654,7 +654,7 @@ public final class IMNetEaseManager {
if (ListUtils.isListEmpty(targets)) {
return;
}
chatRoomMemberIn(targets.get(0));
chatRoomMemberIn(targets.get(0),msg);
//如果是自己进房,立即刷新一次超管缓存
if (UserModel.get().isMyseft(targets.get(0))) {
SuperAdminDataMrg.get().firstInitList();
@@ -1336,7 +1336,7 @@ public final class IMNetEaseManager {
/**
* 成员进入房间
*/
private void chatRoomMemberIn(final String account) {
private void chatRoomMemberIn(final String account, ChatRoomMessage msg) {
List<String> list = new ArrayList<>(1);
list.add(account);
fetchRoomMembersByIds(list)
@@ -1349,6 +1349,43 @@ public final class IMNetEaseManager {
}
noticeRoomMemberChange(true, account);
});
ChatRoomMessageExtension messageExtension = msg.getChatRoomMessageExtension();
ChatRoomMember chatRoomMember = new ChatRoomMember();
Map<String, Object> extensionMap = null;
if (messageExtension != null) {
chatRoomMember.setNick(messageExtension.getSenderNick());
chatRoomMember.setAvatar(messageExtension.getSenderAvatar());
extensionMap = messageExtension.getSenderExtension();
}
chatRoomMember.setAccount(account);
if (extensionMap != null) {
Object extensionData = extensionMap.get(chatRoomMember.getAccount());
if (extensionData instanceof Map) {
Map<String, Object> extensionDataMap = (Map<String, Object>) extensionData;
int fromType = 0;
if (extensionDataMap.containsKey("fromType")) {
fromType = (int) extensionDataMap.get("fromType");
}
//扩展字段是自己服务器的,更新及时点
if (extensionDataMap.containsKey("avatar")) {
chatRoomMember.setAvatar((String) extensionDataMap.get("avatar"));
}
String workAuthor = "";
if (extensionDataMap.containsKey("workAuthor")) {
workAuthor = (String) extensionDataMap.get("workAuthor");
}
Map<String, Object> remoteExtension = msg.getRemoteExtension();
if (remoteExtension == null) {
remoteExtension = new HashMap<>();
}
remoteExtension.put("fromType", fromType);
remoteExtension.put("workAuthor", workAuthor);
msg.setRemoteExtension(remoteExtension);
}
}
AvRoomDataManager.get().mRoomAllMemberList.add(chatRoomMember);
addMessagesImmediately(!needToHideEnterMessage(msg) ? msg : null);
}
/**

View File

@@ -2,7 +2,7 @@ package com.yizhuan.xchat_android_core.im.custom.bean;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.yinyuan.xchat_android_core.redpackage.RedPackageNotifyInfo;
import com.yizhuan.xchat_android_core.redpackage.RedPackageNotifyInfo;
import lombok.Data;
import lombok.EqualsAndHashCode;

View File

@@ -3,6 +3,7 @@ package com.yinyuan.xchat_android_core.redpackage
import com.yizhuan.xchat_android_core.bean.response.ServiceResult
import com.yizhuan.xchat_android_core.redpackage.RedPackageNotifyInfo
import com.yizhuan.xchat_android_core.utils.net.handleBeanData
import com.yizhuan.xchat_android_core.utils.net.handleStringData
import com.yizhuan.xchat_android_core.utils.net.io2main

View File

@@ -1,4 +1,4 @@
package com.yinyuan.xchat_android_core.redpackage
package com.yizhuan.xchat_android_core.redpackage
import java.io.Serializable

View File

@@ -118,7 +118,7 @@ public class AvRoomModel extends RoomBaseModel implements IAvRoomModel {
* @return
*/
@Override
public Observable<EnterChatRoomResultData> enterRoom(final long roomId, final int retryCount) {
public Observable<EnterChatRoomResultData> enterRoom(final long roomId, final int retryCount, final int fromType, final String workAuthor) {
return Observable.create((ObservableOnSubscribe<EnterChatRoomResultData>) e -> {
EnterChatRoomData enterChatRoomData = new EnterChatRoomData(String.valueOf(roomId));
UserInfo userInfo = UserModel.get().getCacheLoginUserInfo();

View File

@@ -30,7 +30,7 @@ public interface IAvRoomModel extends IModel {
* @param retryCount 重试次数
* @return
*/
Observable<EnterChatRoomResultData> enterRoom(final long roomId, final int retryCount);
Observable<EnterChatRoomResultData> enterRoom(final long roomId, final int retryCount,final int fromType, final String workAuthor);
/** 离开聊天室(退出房间) */
void quitRoom(String roomId);