diff --git a/MainModule/src/main/java/com/xscm/modulemain/activity/room/activity/RoomActivity.kt b/MainModule/src/main/java/com/xscm/modulemain/activity/room/activity/RoomActivity.kt index 98c2fc2c..31bce6f1 100644 --- a/MainModule/src/main/java/com/xscm/modulemain/activity/room/activity/RoomActivity.kt +++ b/MainModule/src/main/java/com/xscm/modulemain/activity/room/activity/RoomActivity.kt @@ -198,6 +198,7 @@ import java.util.stream.Collectors class RoomActivity : BaseMvpActivity(), RoomContacts.View, PermissionCallbacks, OnMessageReceivedListener, QXRedPacketManager.QXRedPacketManagerDelegate { + private var roomFragment: RoomFragment? = null //房主信息 @@ -1579,7 +1580,7 @@ class RoomActivity : BaseMvpActivity(), }else if( msgType == EMMessageInfo.QXRoomMessageTypeFlirtatious){ //酒吧房撩ta推送的信息 roomFragment?.handleRoomMessage(messageEvent) }else if (msgType == EMMessageInfo.QXRoomMessageTypeFlirtatiousRoom) {//酒吧房约她进入小黑屋 - + MvpPre?.postRoomInfo(messageEvent.text.room_id) } } @@ -2888,6 +2889,23 @@ class RoomActivity : BaseMvpActivity(), } } + fun setPrivateRoomShowBottom(){ + mBinding!!.rlPk.visibility = + if (voive) View.GONE else View.GONE + mBinding!!.rlMisc.visibility = + if (voive) View.GONE else View.GONE + mBinding!!.rlSett.visibility = + if (voive) View.VISIBLE else View.GONE + mBinding!!.rlGift.visibility = + if (voive) View.VISIBLE else View.GONE + mBinding!!.ivSoundEffects.visibility = + if (voive) View.VISIBLE else View.GONE + mBinding!!.ivWheatFeeding.visibility = + if (voive) View.VISIBLE else View.GONE + mBinding!!.clFirstCharge.visibility = + if (voive) View.VISIBLE else View.GONE + } + /** 进入小黑屋将所有的底部隐藏 */ fun setviewyc(voive: Boolean) { mBinding!!.rlPk.visibility = @@ -3711,9 +3729,15 @@ class RoomActivity : BaseMvpActivity(), } RoomType.BLACK_ROOM -> { - changeBackground(com.xscm.moduleutil.R.mipmap.cabin_bj) - setvisibTop(false) - QXRoomSeatViewType.CABIN + if ("11" == labelId){ + changeBackground(R.mipmap.icon_pri_bg) + setvisibTop(false) + QXRoomSeatViewType.PRIVATE + }else{ + changeBackground(com.xscm.moduleutil.R.mipmap.cabin_bj) + setvisibTop(false) + QXRoomSeatViewType.CABIN + } } RoomType.JUKEBOX -> { diff --git a/MainModule/src/main/java/com/xscm/modulemain/activity/room/contacts/PrivateContacts.kt b/MainModule/src/main/java/com/xscm/modulemain/activity/room/contacts/PrivateContacts.kt index dac4ad52..ccb9832d 100644 --- a/MainModule/src/main/java/com/xscm/modulemain/activity/room/contacts/PrivateContacts.kt +++ b/MainModule/src/main/java/com/xscm/modulemain/activity/room/contacts/PrivateContacts.kt @@ -13,6 +13,8 @@ class PrivateContacts { fun wallet(list:List,walletBean: WalletBean?) + fun sendGiftResult(success:Boolean) + fun getGiftList(list: List) } @@ -21,6 +23,10 @@ class PrivateContacts { fun getGiftList(roomId: String) + fun sendGift(mRoomId:String,giftId: String,mUserId:String) + fun wallet(list:List) + + } } \ No newline at end of file diff --git a/MainModule/src/main/java/com/xscm/modulemain/activity/room/fragment/RoomCabinFragment.java b/MainModule/src/main/java/com/xscm/modulemain/activity/room/fragment/RoomCabinFragment.java index 92c5e0e7..a1311559 100644 --- a/MainModule/src/main/java/com/xscm/modulemain/activity/room/fragment/RoomCabinFragment.java +++ b/MainModule/src/main/java/com/xscm/modulemain/activity/room/fragment/RoomCabinFragment.java @@ -156,7 +156,7 @@ public class RoomCabinFragment extends BaseRoomFragment = arrayListOf() - private var giftViewList:MutableList = arrayListOf() + private var giftViewList: MutableList = arrayListOf() + private var mCountDownTimer: CountDownTimer? = null + + private val cpUserBean: RoomCpUserBean? = mRoomInfoResp?.cp_user + + private var currSendGiftImageView: ImageView? = null override fun initData() { MvpPre?.getGiftList(mRoomId) @@ -71,42 +75,75 @@ class RoomPrivateFragment(var mRoomInfoResp: RoomInfoResp?) : giftViewList.forEach { it -> it.setOnClickListener { - val showList = giftList.shuffled().take(1) - for (i in 0 until showList.size) { - val itemImage = it - val price = showList[i].gift_price.toInt() - // 根据价格设置不同的宽高 - val (width, height) = when { - price > 500 -> Pair(64, 64) - price > 100 -> Pair(52, 52) - else -> Pair(40, 40) + val sendGiftUserId = + if (mUserInfo?.user_id!!.toString() == mBinding.rpwv1.pitBean.user_id) { + mBinding.rpwv2.pitBean.user_id + } else { + mBinding.rpwv1.pitBean.user_id } - // 设置布局参数(假设itemImage是ImageView) - val layoutParams = itemImage.layoutParams - layoutParams.width = width.dpToPx() // 需要实现dp转px的扩展函数 - layoutParams.height = height.dpToPx() - itemImage.layoutParams = layoutParams - - // 假设 padding 值(单位:dp) - val paddingDp = 8 - val paddingPx = paddingDp.dpToPx() // 转换为 px - // 设置 padding(左、上、右、下) - itemImage.setPadding(paddingPx, paddingPx, paddingPx, paddingPx) - - Glide.with(it) - .load(showList[i].base_image) - .into(it as ImageView) - - } + MvpPre.sendGift(mRoomId, it.tag.toString(), sendGiftUserId) + it.visibility = View.INVISIBLE + currSendGiftImageView = it as? ImageView } } + mBinding?.tvHeartNum?.text = mRoomInfoResp?.room_info?.hot_value + mBinding?.tvBack?.setOnClickListener { //返回到上一个房间 } + + // 定义两个 RoomPitBean 对象,分别用于显示在 roomMakeWheat1 和 roomMakeWheat2 + val selfBean = RoomPitBean() // 自己的 bean + val otherBean = RoomPitBean() // 另一个用户的 bean + + + // 判断当前用户是 user_id 还是 user_id1 + if (cpUserBean != null) { + 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.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.pit_number = "000" + } 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.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.pit_number = "000" + } + mBinding?.rpwv1?.pitNumber = "000" + mBinding?.rpwv1?.setData(selfBean) + + mBinding?.rpwv2?.pitNumber = "000" + mBinding?.rpwv2?.setData(otherBean) + + countDownTime(cpUserBean.time_day.toLong()) + } + + } fun roomInfoUpdate(roomInfoResp: RoomInfoResp) { @@ -124,10 +161,45 @@ class RoomPrivateFragment(var mRoomInfoResp: RoomInfoResp?) : } + fun handleMsgType1028(messageEvent: RoomMessageEvent) { + mRoomInfoResp?.room_info?.hot_value = messageEvent.text.hot_value + mBinding?.tvHeartNum?.text = mRoomInfoResp?.room_info?.hot_value + } + + override fun wallet(list: List, walletBean: WalletBean?) { } + override fun sendGiftResult(success: Boolean) { + // 随机选择一个礼物 + val showList = giftList.shuffled().take(1) + val itemImage = currSendGiftImageView + val price = showList[0].gift_price.toInt() + // 根据价格设置不同的宽高 + val (width, height) = when { + price > 500 -> Pair(64, 64) + price > 100 -> Pair(52, 52) + else -> Pair(40, 40) + } + // 设置布局参数(假设itemImage是ImageView) + val layoutParams = itemImage?.layoutParams + layoutParams?.width = width.dpToPx() // 需要实现dp转px的扩展函数 + layoutParams?.height = height.dpToPx() + itemImage?.layoutParams = layoutParams + + // 假设 padding 值(单位:dp) + val paddingDp = 8 + val paddingPx = paddingDp.dpToPx() // 转换为 px + // 设置 padding(左、上、右、下) + itemImage?.setPadding(paddingPx, paddingPx, paddingPx, paddingPx) + currSendGiftImageView?.tag = showList[0].gift_id + Glide.with(itemImage!!) + .load(showList[0].base_image) + .into(itemImage) + currSendGiftImageView?.visibility = View.VISIBLE + } + override fun getGiftList(list: List) { if (giftList.isEmpty()) { giftList = list.toMutableList() @@ -136,6 +208,7 @@ class RoomPrivateFragment(var mRoomInfoResp: RoomInfoResp?) : for (i in 0 until showList.size) { val itemImage = giftViewList[i] val price = showList[i].gift_price.toInt() + itemImage.tag = showList[i].gift_id // 根据价格设置不同的宽高 val (width, height) = when { price > 500 -> Pair(64, 64) @@ -157,11 +230,12 @@ class RoomPrivateFragment(var mRoomInfoResp: RoomInfoResp?) : Glide.with(giftViewList[i]) .load(showList[i].base_image) .into(giftViewList[i]) - Observable.timer(delay,TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe { - startSmallFloatingAnimation(giftViewList[i]) // 延迟后执行动画 - } + Observable.timer(delay, TimeUnit.MILLISECONDS) + .observeOn(AndroidSchedulers.mainThread()).subscribe { + startSmallFloatingAnimation(giftViewList[i]) // 延迟后执行动画 + } } - }else{ + } else { giftList.clear() giftList = list.toMutableList() } @@ -202,4 +276,91 @@ class RoomPrivateFragment(var mRoomInfoResp: RoomInfoResp?) : return (this * Resources.getSystem().displayMetrics.density).toFloat() } + fun upCabinFragment(time: Long) { + countDownTime(time) + } + + + // TODO: 2025/3/12 倒计时 + private fun countDownTime(time: Long) { + try { + if (time <= 0) { + setTime(0) + releaseCountDownTimer() + return + } + releaseCountDownTimer() + // 获取当前时间的毫秒值 + val currentTime = System.currentTimeMillis() / 1000L + // 计算倒计时的总秒数 + val countDownTime = (time - currentTime) + Logger.d("小黑屋", "countDownTime = $countDownTime") + if (countDownTime <= 0) { + setTime(0) + releaseCountDownTimer() + return + } + mCountDownTimer = object : CountDownTimer(countDownTime * 1000L, 1000L) { + override fun onTick(millisUntilFinished: Long) { + val time1 = (millisUntilFinished / 1000).toInt() + // pitBean.setCount_down(time1); + setTime(time1) + } + + override fun onFinish() { + setTime(0) + } + } + mCountDownTimer?.start() + } catch (e: Exception) { + Logger.e("countDownTime", e) + } + } + + private fun formatTime(totalSeconds: Int): String { + val days = totalSeconds / (24 * 3600) + var remaining = totalSeconds % (24 * 3600) + + val hours = remaining / 3600 + remaining %= 3600 + + val minutes = remaining / 60 + val seconds = remaining % 60 + + val sb = StringBuilder() + + if (days > 0) { + sb.append(days).append("天") + } + + if (hours > 0 || days > 0) { + sb.append(hours).append("小时") + } + + if (minutes > 0 || hours > 0 || days > 0) { + sb.append(minutes).append("分") + } + + sb.append(seconds).append("秒") + + return sb.toString() + } + + + @SuppressLint("DefaultLocale") + fun setTime(time: Int) { + if (time == 0) { + mBinding.tvTopTime.text = "00:00:00" + } + val formattedTime = formatTime(time) + mBinding.tvTopTime.text = "倒计时:$formattedTime" + } + + private fun releaseCountDownTimer() { + if (mCountDownTimer != null) { + mCountDownTimer?.cancel() + mCountDownTimer = null + } + } + } \ No newline at end of file diff --git a/MainModule/src/main/java/com/xscm/modulemain/activity/room/presenter/PrivatePresenter.kt b/MainModule/src/main/java/com/xscm/modulemain/activity/room/presenter/PrivatePresenter.kt index 0256e018..2fb3a20e 100644 --- a/MainModule/src/main/java/com/xscm/modulemain/activity/room/presenter/PrivatePresenter.kt +++ b/MainModule/src/main/java/com/xscm/modulemain/activity/room/presenter/PrivatePresenter.kt @@ -4,6 +4,7 @@ import android.content.Context import com.xscm.modulemain.activity.room.contacts.MentorShipContacts import com.xscm.modulemain.activity.room.contacts.PrivateContacts import com.xscm.modulemain.activity.room.contacts.PubContacts +import com.xscm.moduleutil.bean.RoomGiftData import com.xscm.moduleutil.bean.RoonGiftModel import com.xscm.moduleutil.bean.WalletBean import com.xscm.moduleutil.http.BaseObserver @@ -28,6 +29,9 @@ class PrivatePresenter(context: Context, val view: PrivateContacts.View?) : }) } + + + override fun getGiftList(roomId: String) { RetrofitClient.getInstance().getGiftList(5,roomId, object : BaseObserver>() { override fun onSubscribe(d: Disposable) { @@ -44,6 +48,20 @@ class PrivatePresenter(context: Context, val view: PrivateContacts.View?) : }) } + override fun sendGift(mRoomId:String,giftId: String,mUserId:String) { + RetrofitClient.getInstance().roomGift(mRoomId,giftId,"1",mUserId,"1","","","",object : BaseObserver() { + override fun onSubscribe(d: Disposable) { + } + + override fun onNext(t: RoomGiftData) { + if (MvpRef == null) { + MvpRef = WeakReference(view) + } + MvpRef.get()?.sendGiftResult(true) + } + }) + } + override fun wallet(list:List) { RetrofitClient.getInstance().wallet(object : BaseObserver() { diff --git a/MainModule/src/main/res/layout/fragment_room_private.xml b/MainModule/src/main/res/layout/fragment_room_private.xml index dd879620..3b010286 100644 --- a/MainModule/src/main/res/layout/fragment_room_private.xml +++ b/MainModule/src/main/res/layout/fragment_room_private.xml @@ -10,7 +10,8 @@ + + + + + app:layout_constraintGuide_percent="0.15" /> + app:layout_constraintGuide_percent="0.26" /> + app:layout_constraintGuide_percent="0.435" />