酒吧交友房 数据更新。

This commit is contained in:
2026-01-09 11:03:12 +08:00
parent 97f30ce233
commit 36fbc88f21
4 changed files with 106 additions and 94 deletions

View File

@@ -1592,6 +1592,12 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
} else if (msgType == EMMessageInfo.QXRoomMessageTypeFlirtatious) { //酒吧房撩ta推送的信息
roomFragment?.handleRoomMessage(messageEvent)
} else if (msgType == EMMessageInfo.QXRoomMessageTypeFlirtatiousRoom) {//酒吧房约她进入小黑屋
LogUtils.e("QXRoomMessageTypeFlirtatiousRoom", "酒吧房约她进入小黑屋:"+messageEvent.text.room_id+"----------------"+mRoomInfoResp?.room_info?.room_id)
if (mRoomInfoResp?.room_info?.room_id.equals(messageEvent.text.room_id)){
return
}
if (mRoomInfoResp?.user_info?.user_id.toString() == messageEvent.text.user_id
|| mRoomInfoResp?.user_info?.user_id.toString() == messageEvent.text.meet_user_id
) {
@@ -2289,6 +2295,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
//酒吧房用
if (publicScreenFragment != null) {
publicScreenFragment?.mIsPriRoom = false
publicScreenFragment?.clearExMessageListener()
publicScreenFragment?.setIsPriRoom(false)
}
}

View File

@@ -195,6 +195,13 @@ public class ChatRoomFragment extends BaseMvpFragment<ChatRoomPresenter, RoomFra
MessageExListenerSingleton.getInstance().addPublicScreenMessageListener(messageExListener);
}
public void clearExMessageListener() {
if (messageExListener != null) {
MessageExListenerSingleton.getInstance().removePublicScreenMessageListener(messageExListener);
messageListener = null;
}
}
/**
* 检查并处理缓存的消息
*/

View File

@@ -182,6 +182,8 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
}
}
/**
* 安全释放所有子 Fragment
*/
@@ -192,7 +194,6 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
if (!fragments.isEmpty()) {
for (Fragment fragment : fragments) {
if (fragment == null) continue;
// 调用各子 Fragment 的释放方法
if (fragment instanceof SingSongFragment) {
((SingSongFragment) fragment).releaseResources();
@@ -215,6 +216,8 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
mentorShipFragment = null;
} else if (fragment instanceof RoomPubFragment) {
roomPubFragment = null;
}else if (fragment instanceof RoomPrivateFragment) {
roomPrivateFragment = null;
}
// 安全 remove
@@ -262,70 +265,6 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
}
public void updateChildFragmentViews() {
// 使用弱引用避免内存泄漏
if (getActivity() == null || !isAdded()) {
return;
}
if (mRoomInfoResp != null && mRoomInfoResp.getRoom_info() != null) {
String typeId = mRoomInfoResp.getRoom_info().getType_id();
String labelId = mRoomInfoResp.getRoom_info().getLabel_id();
RoomType roomType = RoomType.Companion.fromTypeId(typeId);
mRoomActivity.isInAuctionTopBtVisible(false);
if (roomType == RoomType.MUTUAL_ENTERTAINMENT) {
if (friendshipRoomFragment == currentFragment && friendshipRoomFragment.isAdded()) {
friendshipRoomFragment.roomInfoUpdate(mRoomInfoResp);
}
} else if (roomType == RoomType.AUCTION) {
mRoomActivity.isInAuctionTopBtVisible(true);
if (roomAuctionFragment == currentFragment && roomAuctionFragment.isAdded()) {
roomAuctionFragment.roomInfoUpdate(mRoomInfoResp);
}
} else if (roomType == RoomType.DATING && labelId.equals("2")) {
switch (labelId) {
case "2":
if (ktvFragment == currentFragment && ktvFragment.isAdded()) {
ktvFragment.roomInfoUpdate(mRoomInfoResp);
}
break;
case "1":
if (singSongFragment == currentFragment && singSongFragment.isAdded()) {
singSongFragment.roomInfoUpdate(mRoomInfoResp);
}
break;
}
} else if (roomType == RoomType.BLACK_ROOM) {
if (labelId.equals("11")){
if (roomPrivateFragment == currentFragment && roomPrivateFragment.isAdded()) {
roomPrivateFragment.roomInfoUpdate(mRoomInfoResp);
}
}else {
if (roomCabinFragment == currentFragment && roomCabinFragment.isAdded()) {
roomCabinFragment.roomInfoUpdate(mRoomInfoResp);
}
}
} else if (roomType == RoomType.JUKEBOX) {
if (roomJukeboxFragment == currentFragment && roomJukeboxFragment.isAdded()) {
roomJukeboxFragment.roomInfoUpdate(mRoomInfoResp);
}
} else if (roomType == RoomType.SIGN_CONTRACT) {
if (mentorShipFragment == currentFragment && mentorShipFragment.isAdded()) {
mentorShipFragment.roomInfoUpdate(mRoomInfoResp);
}
} else if (roomType == RoomType.PUB_ROOM) {
if (roomPubFragment == currentFragment && roomPubFragment.isAdded()) {
roomPubFragment.roomInfoUpdate(mRoomInfoResp);
}
}else if (roomType == RoomType.PRIVATE_ROOM) {
if (roomPrivateFragment == currentFragment && roomPrivateFragment.isAdded()) {
roomPrivateFragment.roomInfoUpdate(mRoomInfoResp);
}
}
}
}
/// 给子fragment传递参数
public void updateFriendshipState(int status, int friend_id, long end_time, FriendUserBean friendshipUserBean) {
if (friendshipRoomFragment == currentFragment && friendshipRoomFragment.isAdded()) {
@@ -469,8 +408,8 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
}
if (newFragment != null) {
// switchFragment(newFragment, mBinding.roomItem.getId(), false);
performFragmentReplacementReplace(newFragment);
performFragmentReplacement(newFragment);
} else {
LogUtils.e("newFragment==null");
}
@@ -501,6 +440,8 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
}
private Fragment currentFragment = null;
private Fragment oldFragment = null;
@SuppressLint("CheckResult")
private void performFragmentReplacementReplace(Fragment newFragment) {
if (getActivity() != null && getActivity() instanceof RoomActivity) {
@@ -516,7 +457,6 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
}
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
// 动画(可选,不想动画可以删掉)
transaction.setCustomAnimations(
com.xscm.moduleutil.R.anim.a_slide_right_in,
@@ -532,7 +472,12 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
transaction.commitAllowingStateLoss();
// 更新当前 fragment 引用
currentFragment = newFragment;
if (currentFragment == null) {
currentFragment = newFragment;
}else {
oldFragment = currentFragment;
currentFragment = newFragment;
}
// 延迟启动透明 Activity保持原逻辑
Observable.timer(1000, TimeUnit.MILLISECONDS)
@@ -541,9 +486,61 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
if (ActivityUtils.getTopActivity() instanceof RoomActivity)
startActivity(new Intent(ActivityUtils.getTopActivity(), TransparentActivity.class));
});
// releaseOldFragment();
}
@SuppressLint("CheckResult")
private void releaseOldFragment() {
if (oldFragment == null)
return;
if (oldFragment instanceof SingSongFragment) {
((SingSongFragment) oldFragment).releaseResources();
singSongFragment = null;
}
if (oldFragment instanceof RoomKtvFragment) {
((RoomKtvFragment) oldFragment).releaseResources();
ktvFragment = null;
}
if (oldFragment instanceof FriendshipRoomFragment) {
((FriendshipRoomFragment) oldFragment).releaseResources();
friendshipRoomFragment = null;
}
if (oldFragment instanceof RoomCabinFragment) {
((RoomCabinFragment) oldFragment).releaseResources();
roomCabinFragment = null;
}
if (oldFragment instanceof RoomAuctionFragment) {
((RoomAuctionFragment) oldFragment).releaseResources();
roomAuctionFragment = null;
}
if (oldFragment instanceof RoomJukeboxFragment) {
roomJukeboxFragment = null;
}
if (oldFragment instanceof RoomMentorShipFragment) {
mentorShipFragment = null;
}
if (oldFragment instanceof RoomPubFragment) {
roomPubFragment = null;
}
if (oldFragment instanceof RoomPrivateFragment) {
roomPrivateFragment = null;
}
try {
FragmentManager fm = getChildFragmentManager();
fm.beginTransaction().remove(oldFragment).commitNowAllowingStateLoss();
} catch (Exception e) {
LogUtils.e("releaseChildFragments error: " + e.getMessage());
}
}
@SuppressLint("CheckResult")
private void performFragmentReplacement(Fragment newFragment) {
if (getActivity() != null && getActivity() instanceof RoomActivity) {
if (newFragment instanceof RoomKtvFragment) {

View File

@@ -63,7 +63,7 @@ class RoomPrivateFragment(var mRoomInfoResp: RoomInfoResp?) :
private var mCountDownTimer: CountDownTimer? = null
private val cpUserBean: RoomCpUserBean? = mRoomInfoResp?.cp_user
private var cpUserBean: RoomCpUserBean? = mRoomInfoResp?.cp_user
override fun initView() {
@@ -95,38 +95,37 @@ class RoomPrivateFragment(var mRoomInfoResp: RoomInfoResp?) :
val selfBean = RoomPitBean() // 自己的 bean
val otherBean = RoomPitBean() // 另一个用户的 bean
// 判断当前用户是 user_id 还是 user_id1
if (cpUserBean != null) {
if (mUserInfo?.user_id.toString() == cpUserBean.user_id) {
if (mUserInfo?.user_id.toString() == cpUserBean?.user_id) {
// 当前用户是 user_id
selfBean.user_id = cpUserBean.user_id
selfBean.user_code = cpUserBean.user_code
selfBean.nickname = cpUserBean.nickname
selfBean.avatar = cpUserBean.avatar
selfBean.dress = cpUserBean.dress
selfBean.user_id = cpUserBean?.user_id
selfBean.user_code = cpUserBean?.user_code
selfBean.nickname = cpUserBean?.nickname
selfBean.avatar = cpUserBean?.avatar
selfBean.dress = cpUserBean?.dress
selfBean.pit_number = "000"
otherBean.user_id = cpUserBean.user_id1
otherBean.user_code = cpUserBean.user_code1
otherBean.nickname = cpUserBean.nickname1
otherBean.avatar = cpUserBean.avatar1
otherBean.dress = cpUserBean.dress1
otherBean.user_id = cpUserBean?.user_id1
otherBean.user_code = cpUserBean?.user_code1
otherBean.nickname = cpUserBean?.nickname1
otherBean.avatar = cpUserBean?.avatar1
otherBean.dress = cpUserBean?.dress1
otherBean.pit_number = "000"
} else if (mUserInfo?.user_id.toString() == cpUserBean.user_id1) {
} else if (mUserInfo?.user_id.toString() == cpUserBean?.user_id1) {
// 当前用户是 user_id1则交换位置
selfBean.user_id = cpUserBean.user_id1
selfBean.user_code = cpUserBean.user_code1
selfBean.nickname = cpUserBean.nickname1
selfBean.avatar = cpUserBean.avatar1
selfBean.dress = cpUserBean.dress1
selfBean.user_id = cpUserBean?.user_id1
selfBean.user_code = cpUserBean?.user_code1
selfBean.nickname = cpUserBean?.nickname1
selfBean.avatar = cpUserBean?.avatar1
selfBean.dress = cpUserBean?.dress1
selfBean.pit_number = "000"
otherBean.user_id = cpUserBean.user_id
otherBean.user_code = cpUserBean.user_code
otherBean.nickname = cpUserBean.nickname
otherBean.avatar = cpUserBean.avatar
otherBean.dress = cpUserBean.dress
otherBean.user_id = cpUserBean?.user_id
otherBean.user_code = cpUserBean?.user_code
otherBean.nickname = cpUserBean?.nickname
otherBean.avatar = cpUserBean?.avatar
otherBean.dress = cpUserBean?.dress
otherBean.pit_number = "000"
}
mBinding?.rpwv1?.pitNumber = "000"
@@ -135,7 +134,7 @@ class RoomPrivateFragment(var mRoomInfoResp: RoomInfoResp?) :
mBinding?.rpwv2?.pitNumber = "000"
mBinding?.rpwv2?.setData(otherBean)
countDownTime(cpUserBean.time_day.toLong())
countDownTime(cpUserBean?.time_day!!.toLong())
}
}
@@ -154,7 +153,9 @@ class RoomPrivateFragment(var mRoomInfoResp: RoomInfoResp?) :
mUserInfo = this.mRoomInfoResp?.user_info
mRoomId = this.mRoomInfoResp?.room_info?.room_id!!
cpUserBean = this.mRoomInfoResp?.cp_user
initView()
initData()
}