1:红包功能完成
This commit is contained in:
@@ -93,13 +93,14 @@ public class RedResultActivity extends BaseMvpActivity<RedEnvelopesPresenter, Fr
|
||||
@Override
|
||||
public void redPacketDetail(RedpacketDetail redpacketDetail) {
|
||||
if (redpacketDetail != null) {
|
||||
ImageUtils.loadHeadCC(redpacketDetail.getMy_record().getAvatar(), mBinding.userAvatar);
|
||||
mBinding.userName.setText(redpacketDetail.getMy_record().getNickname());
|
||||
mBinding.tvRedTitle.setText(redpacketDetail.getRedPacket_info().getRemark());
|
||||
mBinding.tvRedJb.setText(redpacketDetail.getMy_record().getAmount());
|
||||
mBinding.tvJb.setText(redpacketDetail.getRedPacket_info().getCoin_type() == 1 ? "金币" : "钻石");
|
||||
mBinding.tvLq.setText(redpacketDetail.getRecords().size() + "/" + redpacketDetail.getRedPacket_info().getTotal_count());
|
||||
|
||||
ImageUtils.loadHeadCC(redpacketDetail.getRedpacket_info().getAvatar(), mBinding.userAvatar);
|
||||
mBinding.userName.setText(redpacketDetail.getRedpacket_info().getNickname());
|
||||
mBinding.tvRedTitle.setText(redpacketDetail.getRedpacket_info().getRemark());
|
||||
mBinding.tvJb.setText(redpacketDetail.getRedpacket_info().getCoin_type() == 1 ? "金币" : "钻石");
|
||||
if (redpacketDetail.getMy_record() != null) {
|
||||
mBinding.tvRedJb.setText(redpacketDetail.getMy_record().getAmount());
|
||||
}
|
||||
mBinding.tvLq.setText(redpacketDetail.getRecords().size() + "/" + redpacketDetail.getRedpacket_info().getTotal_count());
|
||||
redAdapter.setNewData(redpacketDetail.getRecords());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ import java.util.stream.Collectors
|
||||
|
||||
@Route(path = ARouteConstants.ROOM_DETAILS)
|
||||
class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
RoomContacts.View, PermissionCallbacks, OnMessageReceivedListener {
|
||||
RoomContacts.View, PermissionCallbacks, OnMessageReceivedListener, QXRedPacketManager.QXRedPacketManagerDelegate {
|
||||
private var roomFragment: RoomFragment? = null
|
||||
var commonPageAdapter: CommonPageAdapter? = null
|
||||
private var mRoomBean: RoomBean? = null
|
||||
@@ -165,6 +165,9 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
private var isMinimized = false
|
||||
private var appStateListener: AppStateListener? = null
|
||||
|
||||
private var qxRedPacketManager: QXRedPacketManager? = null
|
||||
|
||||
|
||||
// 添加弹框到管理列表
|
||||
fun addActiveDialog(dialog: DialogInterface) {
|
||||
activeDialogs.add(dialog)
|
||||
@@ -206,37 +209,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
// }
|
||||
// }
|
||||
|
||||
private fun handleRestoreFromMinimize(intent: Intent) {
|
||||
// 如果是从桌面启动且之前有最小化的房间
|
||||
// if (Intent.ACTION_MAIN.equals(intent.getAction())
|
||||
// && intent.hasCategory(Intent.CATEGORY_LAUNCHER)) {
|
||||
//
|
||||
// SharedPreferences prefs = getSharedPreferences("room_minimize_state", Context.MODE_PRIVATE);
|
||||
// boolean isMinimized = prefs.getBoolean("is_minimized", false);
|
||||
//
|
||||
// if (isMinimized) {
|
||||
// // 恢复到最小化的房间
|
||||
// String minimizedRoomId = prefs.getString(PREF_MINIMIZED_ROOM, null);
|
||||
// if (minimizedRoomId != null && minimizedRoomId.equals(roomId)) {
|
||||
// // 当前就是最小化的房间,直接恢复
|
||||
// resumeRoomFromMinimize();
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// 其他情况按正常流程处理
|
||||
|
||||
val newRoomId = intent.getStringExtra("roomId")
|
||||
val newPassword = intent.getStringExtra("password")
|
||||
|
||||
if (!TextUtils.isEmpty(newRoomId) && newRoomId != roomId) {
|
||||
// switchToRoom(newRoomId, newPassword);
|
||||
releaseRoom()
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
private fun resumeRoomFromMinimize() {
|
||||
// 从最小化状态恢复房间
|
||||
@@ -417,7 +389,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
val bottomSheet = ExitRoomBottomSheet.newInstance(false, true, true);
|
||||
bottomSheet.setOnOptionSelectedListener(object : OnOptionSelectedListener {
|
||||
override fun onMinimize() {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun onExitRoom() {
|
||||
@@ -617,6 +588,12 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
|
||||
V2TIMManager.getInstance().addIMSDKListener(imSdkListener);
|
||||
// 在 RoomActivity 中获取单例实例
|
||||
// 在onCreate中初始化红包管理器实例,以便在整个Activity生命周期中使用
|
||||
qxRedPacketManager = QXRedPacketManager.getInstance()
|
||||
// 获取单例实例并设置委托
|
||||
qxRedPacketManager!!.setDelegate(this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -626,7 +603,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
override fun onConnectSuccess() { //重连成功
|
||||
if (CommonAppContext.getInstance().playId != null) {
|
||||
LogUtils.e("@@@", "重连成功")
|
||||
LogUtils.e("@@@", ""+CommonAppContext.getInstance().playId)
|
||||
LogUtils.e("@@@", "" + CommonAppContext.getInstance().playId)
|
||||
RetrofitClient.getInstance().roomUserReconnect(CommonAppContext.getInstance().playId)
|
||||
}
|
||||
}
|
||||
@@ -815,6 +792,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
if (mRoomInfoResp == null) {
|
||||
// 使用Handler确保在主线程中调用
|
||||
MvpPre!!.getRoomIn(roomId, password)
|
||||
|
||||
}
|
||||
MvpPre!!.getRoomOnline(roomId, "1", "10")
|
||||
}
|
||||
@@ -858,14 +836,14 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
|
||||
// TODO: 发红包
|
||||
fun redDialogView(){
|
||||
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).navigation();
|
||||
|
||||
RedBagSendDialog(this).show()
|
||||
// 在Activity中使用
|
||||
fun redDialogView() {
|
||||
RedBagSendDialog(this, roomId).show()
|
||||
}
|
||||
|
||||
var redEnvelopesFragment: RedEnvelopesFragment? = null
|
||||
var redListDialog: RedListDialog? = null
|
||||
var redPacketInfo: RedPacketInfo? = null
|
||||
|
||||
override fun initView() {
|
||||
super.initView()
|
||||
floatingMagnetView = findViewById(R.id.flaoat)
|
||||
@@ -910,9 +888,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
layoutParams.height = SystemUtils.getWidth(74) // 示例高度
|
||||
mBinding!!.roomTop.root.layoutParams = layoutParams
|
||||
|
||||
// MP4PlaybackCallback mp4PlaybackCallback=MP4PlaybackCallback.getInstance();
|
||||
// mp4PlaybackCallback.setAvatarFrameView(mBinding.svgaGift);
|
||||
// mBinding.svgaGift.setAnimListener(mp4PlaybackCallback);
|
||||
mBinding!!.xlhIm.setOnClickListener {
|
||||
val fm = supportFragmentManager
|
||||
if (fm != null && !fm.isDestroyed) {
|
||||
@@ -931,8 +906,24 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
|
||||
mBinding!!.drvRed.visibility = View.GONE
|
||||
mBinding!!.redBj.setOnClickListener {
|
||||
val redListDialog = RedListDialog(this)
|
||||
redListDialog.show()
|
||||
redListDialog = RedListDialog(this)
|
||||
redListDialog!!.setOnRedPacketClickListener(object : RedListDialog.OnRedPacketClickListener {
|
||||
|
||||
override fun onRedPacketClick(redPacketInfos: RedPacketInfo?, position: Int) {
|
||||
redPacketInfo = redPacketInfos
|
||||
if (redPacketInfos!=null && redPacketInfos.is_qiang==1){
|
||||
ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).withString("redpacketId", redPacketInfos.getRedpacket_id()).navigation();
|
||||
}else {
|
||||
redEnvelopesFragment = RedEnvelopesFragment(this@RoomActivity)
|
||||
redEnvelopesFragment!!.setIsCollectedRoom(mRoomUserBean!!.is_collect == 1)
|
||||
redEnvelopesFragment!!.setFromToComment(false)
|
||||
redEnvelopesFragment!!.setRedPacket(redPacketInfos)
|
||||
redEnvelopesFragment!!.show()
|
||||
redListDialog!!.dismiss()
|
||||
}
|
||||
}
|
||||
})
|
||||
redListDialog!!.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1087,8 +1078,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private fun enterLandscapeMode() {
|
||||
isFullScreen = true
|
||||
|
||||
@@ -1201,51 +1190,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
|
||||
// 隐藏退出按钮
|
||||
ivExitFullscreen!!.visibility = View.GONE
|
||||
// upHeight()
|
||||
// initPublicScreenFragment()
|
||||
// if (!isFinishing && !isDestroyed) {
|
||||
// resetFragment()
|
||||
// upHeight()
|
||||
// } else {
|
||||
// Log.e("Fragment", "Fragment transaction skipped due to state loss.")
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// isFullScreen = false;
|
||||
// // 恢复系统UI
|
||||
// View decorView = getWindow().getDecorView();
|
||||
//// decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
|
||||
// decorView.setSystemUiVisibility(
|
||||
// View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
||||
// );
|
||||
// // 设置回竖屏
|
||||
// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
||||
// // 找到 fl_screenshare 并移回原父容器
|
||||
// FrameLayout fl_screenshare = findViewById(R.id.fl_screenshare);
|
||||
// if (fl_screenshare != null) {
|
||||
// safelyMoveViewToParent(fl_screenshare, fullScreenContainer);
|
||||
//// ViewParent parent = fl_screenshare.getParent();
|
||||
//// if (parent instanceof ViewGroup) {
|
||||
//// ((ViewGroup) parent).removeView(fl_screenshare);
|
||||
//// }
|
||||
//// // 添加到全屏容器
|
||||
//// fullScreenContainer.addView(fl_screenshare);
|
||||
// // 找到原始父容器并重新添加
|
||||
//// FrameLayout originalParent = findViewById(R.id.fullscreen_container); // 或者你实际的容器
|
||||
//// if (originalParent != null) {
|
||||
//// originalParent.removeView(fl_screenshare); // 防止重复添加
|
||||
//// }
|
||||
//
|
||||
//// floatingMagnetView.addView(fl_screenshare);
|
||||
// }
|
||||
// // 恢复界面
|
||||
// fullScreenContainer.setVisibility(View.GONE);
|
||||
// floatingMagnetView.setVisibility(View.VISIBLE);
|
||||
// ivQuan.setVisibility(View.VISIBLE);
|
||||
// ivExitFullscreen.setVisibility(View.GONE); // 隐藏退出按钮
|
||||
}
|
||||
|
||||
override fun initData() {
|
||||
@@ -1595,18 +1539,12 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
xlhDjs(messageEvent.text.end_time)
|
||||
|
||||
// if (messageEvent.getText().getXlh_data() != null) {
|
||||
// if (messageEvent.getText().getXlh_data().getStatus() == 1) {
|
||||
// mBinding.xlhRk.setVisibility(View.VISIBLE);
|
||||
// xlhDjs(messageEvent.getText().getEnd_time());
|
||||
// } else {
|
||||
// mBinding.xlhRk.setVisibility(View.GONE);
|
||||
// releaseCountDownTimer1();
|
||||
// }
|
||||
// }
|
||||
} else if (msgType == 1060) {
|
||||
qxRedPacketManager!!.addRedPacket(messageEvent.text.redpacketInfo)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private var endTime: Long = 0
|
||||
|
||||
private fun xlhDjs(endTimeStr: String?) {
|
||||
@@ -1735,10 +1673,10 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
// ivSoundEffects(false)
|
||||
// }
|
||||
|
||||
if ("9" == toPitNumber && messageEvent.text.user_id .equals(SpUtil.getUserId().toString())) {
|
||||
if ("9" == toPitNumber && messageEvent.text.user_id.equals(SpUtil.getUserId().toString())) {
|
||||
mBinding!!.roomTop.rl.visibility = View.VISIBLE
|
||||
ivSoundEffects(true)
|
||||
}else{
|
||||
} else {
|
||||
if (customMusicFloatingView != null) {
|
||||
customMusicFloatingView!!.destroy()
|
||||
AgoraManager.getInstance(this@RoomActivity).desMusic()
|
||||
@@ -2141,31 +2079,21 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
|
||||
private fun handleMsgType1024(messageEvent: RoomMessageEvent, text: T?) {
|
||||
if (text == null || mRoomInfoResp == null || mRoomInfoResp!!.room_info == null) return
|
||||
|
||||
try {
|
||||
// 初始化 room_auction 如果为 null
|
||||
if (mRoomInfoResp!!.room_auction == null) {
|
||||
mRoomInfoResp!!.room_auction = RoomAuction()
|
||||
}
|
||||
|
||||
// 安全地处理 auction_list
|
||||
val auctionList = mRoomInfoResp!!.room_auction.auction_list ?: ArrayList()
|
||||
auctionList.clear()
|
||||
|
||||
// 安全地添加新数据
|
||||
text.auction_list?.let { auctionList.addAll(it) }
|
||||
|
||||
mRoomInfoResp!!.room_auction.auction_list = auctionList
|
||||
|
||||
roomFragment!!.upRoomInfoData(mRoomInfoResp)
|
||||
roomFragment!!.handleAuctionMessageEvent(messageEvent)
|
||||
} catch (e: Exception) {
|
||||
LogUtils.e("handleMsgType1024 error: " + e.message)
|
||||
if (text == null || mRoomInfoResp == null || mRoomInfoResp!!.room_auction == null) return
|
||||
if (mRoomInfoResp!!.room_auction.auction_list != null) {
|
||||
mRoomInfoResp!!.room_auction.auction_list.clear()
|
||||
}
|
||||
if (mRoomInfoResp!!.room_auction.auction_list != null) {
|
||||
mRoomInfoResp!!.room_auction.auction_list.addAll(text.auction_list)
|
||||
} else {
|
||||
mRoomInfoResp!!.room_auction.auction_list = ArrayList()
|
||||
// mRoomInfoResp.getRoom_auction().getAuction_list().addAll(text.getAuction_list());
|
||||
}
|
||||
roomFragment!!.upRoomInfoData(mRoomInfoResp)
|
||||
roomFragment!!.handleAuctionMessageEvent(messageEvent)
|
||||
// roomFragment.updateSeatViewExchangedWithPitArray(mRoomInfoResp);
|
||||
}
|
||||
|
||||
|
||||
private fun handleMsgType1020(messageEvent: RoomMessageEvent, text: T?) {
|
||||
if (text == null) return
|
||||
|
||||
@@ -2179,8 +2107,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
|
||||
if (text.fromUserInfo.user_id == SpUtil.getUserId()) {
|
||||
LogUtils.e("退出房间")
|
||||
// MvpPre!!.quitRoom(roomId, SpUtil.getUserId().toString() + "")
|
||||
performExitRoom(1)
|
||||
MvpPre!!.quitRoom(roomId, SpUtil.getUserId().toString() + "")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2596,6 +2523,10 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
mBinding!!.roomTop.tvNum.text = number.toString() + ""
|
||||
}
|
||||
|
||||
fun setUserInfo() {
|
||||
mRoomInfoResp!!.user_info.is_collect = 1
|
||||
}
|
||||
|
||||
/**
|
||||
* 特效设置
|
||||
*/
|
||||
@@ -3221,6 +3152,13 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
etContent.setText("")
|
||||
countDownTimer()
|
||||
if (redEnvelopesFragment != null) {
|
||||
redEnvelopesFragment = RedEnvelopesFragment(this@RoomActivity)
|
||||
redEnvelopesFragment!!.setIsCollectedRoom(mRoomUserBean!!.is_collect == 1)
|
||||
redEnvelopesFragment!!.setFromToComment(true)
|
||||
redEnvelopesFragment!!.setRedPacket(redPacketInfo)
|
||||
redEnvelopesFragment!!.show()
|
||||
}
|
||||
dialog.dismiss()
|
||||
})
|
||||
|
||||
@@ -3263,11 +3201,11 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun roomInfoEvent(messageEvent: UserInfo) {
|
||||
// mBinding.llInput.setVisibility(View.VISIBLE);
|
||||
// mBinding.inputMenu1.bringToFront(); // 强制将该 View 置于最上层
|
||||
// mBinding.inputMenu1.show();
|
||||
// mBinding.inputMenu1.setText("@" + messageEvent.getNickname());
|
||||
inputSting = "@" + messageEvent.nickname
|
||||
if (messageEvent != null && messageEvent.red_num != null) {
|
||||
inputSting = messageEvent.red_num
|
||||
} else {
|
||||
inputSting = "@" + messageEvent.nickname
|
||||
}
|
||||
dialogDismiss()
|
||||
}
|
||||
|
||||
@@ -3517,10 +3455,11 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
}
|
||||
mBinding!!.ivQuanC.setOnClickListener { v: View? ->
|
||||
if (mRoomInfoResp!!.room_info.head_line.room_id != null && mRoomInfoResp!!.room_info.head_line.room_id.isNotEmpty()){
|
||||
if (mRoomInfoResp!!.room_info.head_line.room_id != roomId){
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(applicationContext,mRoomInfoResp!!.room_info.head_line.room_id,"")
|
||||
}else{
|
||||
if (mRoomInfoResp!!.room_info.head_line.room_id != null && mRoomInfoResp!!.room_info.head_line.room_id.isNotEmpty()) {
|
||||
if (mRoomInfoResp!!.room_info.head_line.room_id != roomId) {
|
||||
RoomManager.getInstance()
|
||||
.fetchRoomDataAndEnter(applicationContext, mRoomInfoResp!!.room_info.head_line.room_id, "")
|
||||
} else {
|
||||
com.blankj.utilcode.util.ToastUtils.showLong("您就在当前房间")
|
||||
}
|
||||
}
|
||||
@@ -3737,6 +3676,8 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
// }
|
||||
// }
|
||||
|
||||
MvpPre!!.roomRedPackets(roomId);
|
||||
|
||||
if (isInBackground) {
|
||||
isInBackground = false
|
||||
MvpPre!!.postRoomInfo(CommonAppContext.getInstance().playId)
|
||||
@@ -3958,7 +3899,7 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
|
||||
|
||||
val roomBean = resp.room_info
|
||||
if (roomBean!!.type_id.equals("6")){
|
||||
if (roomBean!!.type_id.equals("6")) {
|
||||
|
||||
// upHeight()
|
||||
initPublicScreenFragment()
|
||||
@@ -4139,7 +4080,6 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
}
|
||||
|
||||
override fun quitRoom() {
|
||||
|
||||
}
|
||||
|
||||
//退出房间进行销毁
|
||||
@@ -4221,8 +4161,10 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
override fun findRoom() {
|
||||
}
|
||||
|
||||
override fun roomEit() {
|
||||
performExitRoom(1)
|
||||
override fun roomRedPackets(list: MutableList<RedPacketInfo>?) {
|
||||
if (list != null) {
|
||||
qxRedPacketManager!!.addRedPackets(list!!)
|
||||
}
|
||||
}
|
||||
|
||||
private fun queren1(nickname: String) {
|
||||
@@ -4264,6 +4206,9 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
clearMinimizeState()
|
||||
cleanupResources()
|
||||
}
|
||||
if (qxRedPacketManager != null) {
|
||||
qxRedPacketManager!!.endCheckTimer();
|
||||
}
|
||||
// 确保父类的 onDestroy 被调用
|
||||
super.onDestroy()
|
||||
}
|
||||
@@ -4582,5 +4527,96 @@ class RoomActivity : BaseMvpActivity<RoomPresenter?, ActivityRoomBinding?>(),
|
||||
private val AUDIO_PERMISSIONS = arrayOf(Manifest.permission.RECORD_AUDIO)
|
||||
}
|
||||
|
||||
override fun onRedPacketsAdded(redPackets: MutableList<RedPacketInfo>?, remainingCount: Int) {
|
||||
// 处理添加红包列表的逻辑
|
||||
if (redPackets!!.isNotEmpty()) {
|
||||
mBinding!!.drvRed.visibility = View.VISIBLE
|
||||
mBinding!!.redNum.visibility = View.VISIBLE
|
||||
mBinding!!.redNum.text = "x" + remainingCount.toString()
|
||||
} else {
|
||||
mBinding!!.drvRed.visibility = View.GONE
|
||||
mBinding!!.redNum.visibility = View.GONE
|
||||
qxRedPacketManager!!.removeAllRedPackets()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onRedPacketAdded(redPacket: RedPacketInfo?, remainingCount: Int) {
|
||||
// 处理添加单个红包的逻辑
|
||||
if (redPacket != null) {
|
||||
mBinding!!.drvRed.visibility = View.VISIBLE
|
||||
mBinding!!.redNum.visibility = View.VISIBLE
|
||||
mBinding!!.redNum.text = "x" + remainingCount.toString()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRedPacketRemoved(packetId: String?, remainingCount: Int) {
|
||||
// 处理移除红包的逻辑
|
||||
if (remainingCount == 0) {
|
||||
mBinding!!.drvRed.visibility = View.GONE
|
||||
} else {
|
||||
mBinding!!.drvRed.visibility = View.VISIBLE
|
||||
}
|
||||
mBinding!!.redNum.text = "x" + remainingCount.toString()
|
||||
}
|
||||
|
||||
override fun onRedPacketUpdated(packet: RedPacketInfo?, remainingCount: Int) {
|
||||
// 处理红包状态更新的逻辑
|
||||
if (redEnvelopesFragment != null && redEnvelopesFragment!!.mRedPacketInfo != null && redEnvelopesFragment!!.mRedPacketInfo!!.countdown > 0) {
|
||||
if (redEnvelopesFragment!!.mRedPacketInfo.type == 1) {
|
||||
redEnvelopesFragment!!.changeViewType(RedEnvelopeStatus.QXRedBagDrawTypeOpen)
|
||||
}else{
|
||||
if (redEnvelopesFragment!!.isFromToComment) {
|
||||
redEnvelopesFragment!!.changeViewType(RedEnvelopeStatus.QXRedBagDrawTypeOpen)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun didUpdateRedPacketTime(packet: RedPacketInfo?, packetTime: Long) {
|
||||
|
||||
if ((redEnvelopesFragment != null) && (redEnvelopesFragment!!.mRedPacketInfo != null) &&
|
||||
(redEnvelopesFragment!!.mRedPacketInfo!!.countdown > 0) && packetTime >= 0
|
||||
) {
|
||||
LogUtils.e("进入倒计时" + packetTime)
|
||||
if (redEnvelopesFragment!!.mRedPacketInfo.type == 1) {
|
||||
if (redEnvelopesFragment!!.mRedPacketInfo.conditions.contains("1")) {
|
||||
//有收藏房间条件
|
||||
if (mRoomInfoResp!!.user_info.is_collect == 1) {
|
||||
//需要满足收藏在倒计时
|
||||
redEnvelopesFragment!!.setNeedTime(packetTime)
|
||||
}
|
||||
} else {
|
||||
redEnvelopesFragment!!.setNeedTime(packetTime)
|
||||
}
|
||||
} else {
|
||||
if (redEnvelopesFragment!!.isFromToComment) {
|
||||
if (redEnvelopesFragment!!.mRedPacketInfo.conditions.contains("1")) {
|
||||
//有收藏房间条件
|
||||
if (mRoomInfoResp!!.user_info.is_collect == 1) {
|
||||
redEnvelopesFragment!!.setNeedTime(packetTime)
|
||||
}
|
||||
} else {
|
||||
redEnvelopesFragment!!.setNeedTime(packetTime)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (redListDialog != null) {
|
||||
if (redListDialog!!.isShowing && redListDialog!!.adapter != null) {
|
||||
val adapter = redListDialog!!.adapter
|
||||
val list = adapter.data
|
||||
for (i in list.indices) {
|
||||
val redPacketInfo = list[i]
|
||||
if (redPacketInfo.redpacket_id == packet!!.redpacket_id) {
|
||||
adapter.updateCountdown(i, packetTime)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class RedAdapter extends BaseQuickAdapter<RedpacketDetail.Records, BaseVi
|
||||
ImageUtils.loadHeadCC(redBean.getAvatar(), baseViewHolder.getView(R.id.red_user_avatar));
|
||||
baseViewHolder.setText(R.id.tv_user_name, redBean.getNickname());
|
||||
baseViewHolder.setText(R.id.tv_red_num, redBean.getAmount());
|
||||
baseViewHolder.setText(R.id.tv_time, formatTimestamp(Long.getLong(redBean.getCreatetime())));
|
||||
baseViewHolder.setText(R.id.tv_time, redBean.getCreatetime());
|
||||
}
|
||||
|
||||
private String formatTimestamp(long timestamp) {
|
||||
|
||||
@@ -1,20 +1,116 @@
|
||||
package com.example.moduleroom.adapter;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.example.moduleroom.R;
|
||||
import com.xscm.moduleutil.bean.RedPacketInfo;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 红包的列表适配器
|
||||
*/
|
||||
public class RedBagAdapter extends BaseQuickAdapter<RedPacketInfo, BaseViewHolder> {
|
||||
private Map<Integer,View> viewMap;
|
||||
public RedBagAdapter() {
|
||||
super(R.layout.item_red_bag);
|
||||
viewMap=new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, RedPacketInfo item) {
|
||||
viewMap.put(helper.getLayoutPosition(),helper.itemView);
|
||||
ImageView iv_red_bag= helper.getView(R.id.iv_red_bag);
|
||||
if (item.getIs_qiang()==1){
|
||||
iv_red_bag.setImageResource(com.xscm.moduleutil.R.mipmap.red_bj_h);
|
||||
helper.setVisible(R.id.tv_user_name,false);
|
||||
helper.setVisible(R.id.tv_djs,false);
|
||||
}else {
|
||||
iv_red_bag.setImageResource(com.xscm.moduleutil.R.mipmap.red);
|
||||
|
||||
if (item.getType()==2){
|
||||
helper.setVisible(R.id.im_list_bj,true);
|
||||
}else {
|
||||
helper.setVisible(R.id.im_list_bj,false);
|
||||
}
|
||||
|
||||
// 显示倒计时
|
||||
if (item.getCountdown() > 0) {
|
||||
helper.setVisible(R.id.tv_djs, true);
|
||||
long minutes = item.getCountdown() / 60;
|
||||
long seconds = item.getCountdown() % 60;
|
||||
String timeFormat = String.format("%02d:%02d", minutes, seconds);
|
||||
helper.setText(R.id.tv_djs, timeFormat);
|
||||
} else {
|
||||
helper.setVisible(R.id.tv_djs, false);
|
||||
}
|
||||
}
|
||||
|
||||
helper.setText(R.id.tv_user_name, item.getNickname());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新指定位置的倒计时显示,不刷新整个item
|
||||
* @param position 列表位置
|
||||
* @param countdown 倒计时时间(秒)
|
||||
*/
|
||||
public void updateCountdown(int position, long countdown) {
|
||||
if (position >= 0 && position < getData().size()) {
|
||||
// 获取对应位置的item view
|
||||
View view = viewMap.get(position);
|
||||
if (view != null) {
|
||||
// 直接更新倒计时文本,不刷新整个item
|
||||
TextView tvDjs = view.findViewById(R.id.tv_djs);
|
||||
if (tvDjs != null) {
|
||||
// 格式化倒计时显示
|
||||
long minutes = countdown / 60;
|
||||
long seconds = countdown % 60;
|
||||
String timeFormat = String.format("%02d:%02d", minutes, seconds);
|
||||
tvDjs.setText(timeFormat);
|
||||
|
||||
// 控制倒计时显示状态
|
||||
if (countdown > 0) {
|
||||
tvDjs.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
tvDjs.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据位置获取item view
|
||||
* @param position 位置
|
||||
* @return item对应的view
|
||||
*/
|
||||
private View getViewByPosition(int position) {
|
||||
RecyclerView recyclerView = getRecyclerView();
|
||||
if (recyclerView != null) {
|
||||
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
|
||||
if (layoutManager != null) {
|
||||
// 检查 position 是否在可见范围内
|
||||
if (layoutManager instanceof LinearLayoutManager) {
|
||||
LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager;
|
||||
int firstVisiblePosition = linearLayoutManager.findFirstVisibleItemPosition();
|
||||
int lastVisiblePosition = linearLayoutManager.findLastVisibleItemPosition();
|
||||
|
||||
// 确保 position 在可见范围内
|
||||
if (position >= firstVisiblePosition && position <= lastVisiblePosition) {
|
||||
return layoutManager.findViewByPosition(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -10,19 +10,14 @@ import android.view.WindowManager;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.example.moduleroom.R;
|
||||
import com.example.moduleroom.adapter.RedBagAdapter;
|
||||
import com.example.moduleroom.databinding.DialogRedListBinding;
|
||||
import com.example.moduleroom.fragment.RedEnvelopesFragment;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.bean.RedPacketInfo;
|
||||
import com.xscm.moduleutil.utils.QXRedPacketManager;
|
||||
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 这是红包列表
|
||||
*/
|
||||
@@ -34,7 +29,10 @@ public class RedListDialog extends BaseDialog<DialogRedListBinding> {
|
||||
public RedListDialog(@NonNull Context context) {
|
||||
super(context, com.xscm.moduleutil.R.style.BaseDialogStyleH);
|
||||
}
|
||||
|
||||
// 添加获取适配器的方法
|
||||
public RedBagAdapter getAdapter() {
|
||||
return redBagAdapter;
|
||||
}
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.dialog_red_list;
|
||||
@@ -121,27 +119,21 @@ public class RedListDialog extends BaseDialog<DialogRedListBinding> {
|
||||
|
||||
redBagAdapter.setNewData(qxRedPacketManager.getAllRedPackets()) ;
|
||||
redBagAdapter.setOnItemClickListener((adapter, view, position) -> {
|
||||
RedEnvelopesFragment redEnvelopesFragment = new RedEnvelopesFragment(getContext());
|
||||
redEnvelopesFragment.setRedPacket(qxRedPacketManager.getAllRedPackets().get(position));
|
||||
redEnvelopesFragment.show();
|
||||
|
||||
if (mListener != null) {
|
||||
mListener.onRedPacketClick(redBagAdapter.getData().get(position), position);
|
||||
}
|
||||
});
|
||||
|
||||
// List<String> list = new ArrayList<>();
|
||||
// list.add("1");
|
||||
// list.add("2");
|
||||
// list.add("3");
|
||||
// list.add("4");
|
||||
// list.add("5");
|
||||
// list.add("4");
|
||||
// list.add("5");
|
||||
// list.add("4");
|
||||
// list.add("5");
|
||||
// list.add("4");
|
||||
// list.add("5");
|
||||
// redBagAdapter.setNewData(list);
|
||||
}
|
||||
|
||||
public interface OnRedPacketClickListener {
|
||||
void onRedPacketClick(RedPacketInfo redPacketInfo,int position);
|
||||
}
|
||||
private OnRedPacketClickListener mListener;
|
||||
|
||||
public void setOnRedPacketClickListener(OnRedPacketClickListener listener) {
|
||||
this.mListener = listener;
|
||||
}
|
||||
|
||||
|
||||
private Resources getResources() {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.example.moduleroom.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.CountDownTimer;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
@@ -8,21 +9,29 @@ import android.view.WindowManager;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.blankj.utilcode.util.TimeUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.example.moduleroom.R;
|
||||
import com.example.moduleroom.activity.RoomActivity;
|
||||
import com.example.moduleroom.databinding.FragmentRedEnvelopesBinding;
|
||||
import com.xscm.moduleutil.bean.RedPackGrab;
|
||||
import com.xscm.moduleutil.bean.RedPacketInfo;
|
||||
import com.xscm.moduleutil.bean.UserInfo;
|
||||
import com.xscm.moduleutil.event.RedEnvelopeStatus;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.utils.QXRedPacketManager;
|
||||
import com.xscm.moduleutil.view.QXRedBagSendView;
|
||||
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||
import com.xscm.moduleutil.widget.floatingView.IFloatingView;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static com.xscm.moduleutil.event.RedEnvelopeStatus.*;
|
||||
|
||||
/**
|
||||
* @author xscm
|
||||
* @ClassName RedEnvelopesFragment
|
||||
@@ -31,12 +40,28 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding> {
|
||||
private RedEnvelopeStatus mCurrentStatus;
|
||||
private RedPacketInfo mRedPacketInfo;
|
||||
private RedEnvelopeStatus drawType;
|
||||
public RedPacketInfo mRedPacketInfo;
|
||||
public boolean isCollectedRoom;//是否收藏房间
|
||||
|
||||
public long needTime;// 倒计时
|
||||
public boolean isFromToComment;//是否是发送评论地方过来
|
||||
|
||||
private CountDownTimer countDownTimer;
|
||||
|
||||
public RedEnvelopesFragment(@NonNull @NotNull Context context) {
|
||||
super(context, com.xscm.moduleutil.R.style.BaseDialogStyleH);
|
||||
}
|
||||
|
||||
//是否收藏方法
|
||||
public void setIsCollectedRoom(boolean isCollectedRoom) {
|
||||
this.isCollectedRoom = isCollectedRoom;
|
||||
}
|
||||
|
||||
public void setFromToComment(boolean isFromToComment) {
|
||||
this.isFromToComment = isFromToComment;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
@@ -49,7 +74,8 @@ public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding
|
||||
setCanceledOnTouchOutside(false);
|
||||
Window window = getWindow();
|
||||
// window.setLayout(345, 454);
|
||||
window.setLayout((int) (ScreenUtils.getScreenWidth() * 345.f / 345),WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
// window.setLayout((int) (ScreenUtils.getScreenWidth() * 345.f / 345), WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
window.setLayout((int) (ScreenUtils.getScreenWidth() * 0.8), WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
mBinding.imRedClose.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@@ -73,15 +99,19 @@ public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull RedPackGrab redPackGrab) {
|
||||
if (redPackGrab!=null){
|
||||
if (redPackGrab.getCode()==1){
|
||||
if (redPackGrab != null) {
|
||||
if (redPackGrab.getCode() == 1) {
|
||||
mRedPacketInfo.setIs_qiang(1);
|
||||
ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).withString("redpacketId", mRedPacketInfo.getRedpacket_id()).navigation();
|
||||
}else if (redPackGrab.getCode()==2){
|
||||
dismiss();
|
||||
} else if (redPackGrab.getCode() == 2) {
|
||||
ToastUtils.showShort("您已经抢过红包了");
|
||||
ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).withString("redpacketId", mRedPacketInfo.getRedpacket_id()).navigation();
|
||||
}else {
|
||||
dismiss();
|
||||
} else {
|
||||
snatched();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -89,7 +119,7 @@ public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding
|
||||
|
||||
// QXRedBagSendView redBagView = new QXRedBagSendView(getContext());
|
||||
// redBagView.showInView((ViewGroup) getWindow().getDecorView());
|
||||
dismiss();
|
||||
|
||||
}
|
||||
});
|
||||
mBinding.tvCk.setOnClickListener(new View.OnClickListener() {
|
||||
@@ -98,9 +128,42 @@ public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding
|
||||
ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).withString("redpacketId", mRedPacketInfo.getRedpacket_id()).navigation();
|
||||
}
|
||||
});
|
||||
mBinding.textPl.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (drawType == RedEnvelopeStatus.QXRedBagDrawTypeCollect){
|
||||
RetrofitClient.getInstance().followRoom(mRedPacketInfo.getRoom_id()+"","1", new BaseObserver<String>() {
|
||||
@Override
|
||||
public void onSubscribe(@NotNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NotNull String s) {
|
||||
if (getContext() instanceof RoomActivity) {
|
||||
((RoomActivity) getContext()).setUserInfo();
|
||||
}
|
||||
|
||||
if (mRedPacketInfo.canOpenNow()){
|
||||
setType(QXRedBagDrawTypeOpen);
|
||||
}else {
|
||||
setType(QXRedBagDrawTypeTimeDown);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}else if (drawType == RedEnvelopeStatus.QXRedBagDrawTypePwdSend){
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setRed_num(mRedPacketInfo.getPassword());
|
||||
EventBus.getDefault().post(userInfo);
|
||||
dismiss();
|
||||
}
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_RED_RESULT).withString("redpacketId", mRedPacketInfo.getRedpacket_id()).navigation();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void snatched(){
|
||||
private void snatched() {
|
||||
mBinding.tvRedCount.setText("手慢,没有抢到");
|
||||
mBinding.imRedK.setVisibility(View.GONE);
|
||||
mBinding.textPl.setVisibility(View.GONE);
|
||||
@@ -109,7 +172,6 @@ public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding
|
||||
mBinding.tvKl.setVisibility(View.GONE);
|
||||
mBinding.tvCk.setVisibility(View.VISIBLE);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,30 +181,178 @@ public class RedEnvelopesFragment extends BaseDialog<FragmentRedEnvelopesBinding
|
||||
|
||||
public void setRedPacket(RedPacketInfo redPacketInfo) {
|
||||
this.mRedPacketInfo = redPacketInfo;
|
||||
ImageUtils.loadHeadCC(redPacketInfo.getAvatar(), mBinding.userAvatar);
|
||||
mBinding.tvUserName.setText(redPacketInfo.getNickname());
|
||||
mBinding.tvRedCount.setText(redPacketInfo.getRemark());
|
||||
// 根据红包信息确定当前状态
|
||||
// if (redPacketInfo.isHasCountdown() && redPacketInfo.isHasCondition()) {
|
||||
// mCurrentStatus = RedEnvelopeStatus.COUNTDOWN_AND_CONDITION;
|
||||
// handleCountdownAndCondition();
|
||||
// } else if (redPacketInfo.isHasCountdown()) {
|
||||
// mCurrentStatus = RedEnvelopeStatus.COUNTDOWN_TO_OPEN;
|
||||
// handleCountdown();
|
||||
// } else if (redPacketInfo.isHasCondition()) {
|
||||
// mCurrentStatus = RedEnvelopeStatus.CONDITION_TO_OPEN;
|
||||
// handleCondition();
|
||||
// } else {
|
||||
mCurrentStatus = RedEnvelopeStatus.READY_TO_OPEN;//红包可以直接抢的
|
||||
handleReadyToOpen();
|
||||
// }
|
||||
setType(getDrawTypeWithRedpacktModel(redPacketInfo));
|
||||
if (redPacketInfo.getType() == 2) {
|
||||
mBinding.imKlB.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mBinding.imKlB.setVisibility(View.GONE);
|
||||
}
|
||||
ImageUtils.loadHeadCC(redPacketInfo.getAvatar(), mBinding.userAvatar);
|
||||
mBinding.tvUserName.setText(redPacketInfo.getNickname() + "的红包");
|
||||
mBinding.tvRedCount.setText(redPacketInfo.getRemark());
|
||||
if (drawType == RedEnvelopeStatus.QXRedBagDrawTypeOpen) {
|
||||
mBinding.clPwd.setVisibility(View.GONE);
|
||||
mBinding.textShare.setVisibility(View.GONE);
|
||||
} else {
|
||||
mBinding.clPwd.setVisibility(View.VISIBLE);
|
||||
mBinding.textShare.setVisibility(View.VISIBLE);
|
||||
if (redPacketInfo.getType() == 2) {
|
||||
mBinding.tvKl.setVisibility(View.VISIBLE);
|
||||
mBinding.imKlB.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mBinding.tvKl.setVisibility(View.GONE);
|
||||
mBinding.imKlB.setVisibility(View.GONE);
|
||||
}
|
||||
if (redPacketInfo.getConditions() == null || redPacketInfo.getConditions().equals("0")) {
|
||||
mBinding.clPwd.setVisibility(View.GONE);
|
||||
} else {
|
||||
mBinding.clPwd.setVisibility(View.VISIBLE);
|
||||
mBinding.tvKl.setVisibility(View.VISIBLE);
|
||||
if (redPacketInfo.getConditions().equals("1")) {
|
||||
mBinding.tvKl.setText("收藏房间");
|
||||
} else if (redPacketInfo.getConditions().equals("2")) {
|
||||
mBinding.tvKl.setText("仅麦上用户");
|
||||
} else {
|
||||
mBinding.tvKl.setText("收藏房间,进麦上用户");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setNeedTime(long needTimes){
|
||||
this.needTime = needTimes;
|
||||
if (needTime > 0) {
|
||||
mBinding.textPl.setText(TimeUtils.millis2String(needTime*1000, "mm:ss")+"后开启红包");
|
||||
}
|
||||
}
|
||||
|
||||
private RedEnvelopeStatus getDrawTypeWithRedpacktModel(RedPacketInfo redPacketInfo) {
|
||||
drawType = QXRedBagDrawTypeOpen;
|
||||
if (redPacketInfo.getType() == 1) {//普通红包
|
||||
drawType = QXRedBagDrawTypeOpen;
|
||||
if (redPacketInfo.getCountdown() > 0) {
|
||||
if (redPacketInfo.remainingTime() > 0) {
|
||||
drawType = QXRedBagDrawTypeTimeDown;
|
||||
}
|
||||
}
|
||||
//收藏房间在先
|
||||
if (redPacketInfo.getConditions().contains("1") && !isCollectedRoom) {
|
||||
drawType = QXRedBagDrawTypeCollect;
|
||||
}
|
||||
} else {//口令红包
|
||||
drawType = QXRedBagDrawTypePwdSend;
|
||||
if (isFromToComment) {
|
||||
if (redPacketInfo.getConditions().contains("1") && !isCollectedRoom) {
|
||||
drawType = QXRedBagDrawTypeCollect;
|
||||
} else {
|
||||
if (redPacketInfo.canOpenNow()) {
|
||||
drawType = QXRedBagDrawTypeOpen;
|
||||
} else {
|
||||
drawType = QXRedBagDrawTypeTimeDown;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return drawType;
|
||||
}
|
||||
|
||||
private void setType(RedEnvelopeStatus type) {
|
||||
this.drawType = type;
|
||||
switch (type) {
|
||||
case QXRedBagDrawTypeOpen:
|
||||
handleReadyToOpen();
|
||||
break;
|
||||
case QXRedBagDrawTypeFinished:
|
||||
qXRedBagDrawTypeFinished();
|
||||
break;
|
||||
case QXRedBagDrawTypeCollect:
|
||||
qXRedBagDrawTypeCollect();
|
||||
break;
|
||||
case QXRedBagDrawTypeTimeDown:
|
||||
qXRedBagDrawTypeTimeDown();
|
||||
break;
|
||||
|
||||
case QXRedBagDrawTypePwdSend:
|
||||
qXRedBagDrawTypePwdSend();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void qXRedBagDrawTypePwdSend() {
|
||||
mBinding.imRedK.setVisibility(View.GONE);
|
||||
mBinding.tvRedCount.setText(mRedPacketInfo.getRemark());
|
||||
mBinding.tvCk.setVisibility(View.GONE);
|
||||
mBinding.textPl.setVisibility(View.VISIBLE);
|
||||
mBinding.textPl.setText(setValue(QXRedBagDrawTypePwdSend));
|
||||
|
||||
}
|
||||
|
||||
private void qXRedBagDrawTypeTimeDown() {
|
||||
mBinding.imRedK.setVisibility(View.GONE);
|
||||
mBinding.tvRedCount.setText(mRedPacketInfo.getRemark());
|
||||
mBinding.tvCk.setVisibility(View.GONE);
|
||||
mBinding.textPl.setVisibility(View.VISIBLE);
|
||||
mBinding.textPl.setText(setValue(QXRedBagDrawTypeTimeDown));
|
||||
}
|
||||
|
||||
private void qXRedBagDrawTypeCollect() {
|
||||
mBinding.imRedK.setVisibility(View.GONE);
|
||||
mBinding.tvRedCount.setText(mRedPacketInfo.getRemark());
|
||||
mBinding.tvCk.setVisibility(View.GONE);
|
||||
mBinding.textPl.setVisibility(View.VISIBLE);
|
||||
mBinding.textPl.setText(setValue(QXRedBagDrawTypeCollect));
|
||||
mBinding.textShare.setVisibility(View.VISIBLE);
|
||||
mBinding.clPwd.setVisibility(View.VISIBLE);
|
||||
mBinding.tvPinl.setVisibility(View.GONE);
|
||||
mBinding.tvKl.setVisibility(View.VISIBLE);
|
||||
mBinding.tvKl.setText("收藏房间");
|
||||
|
||||
}
|
||||
|
||||
private String setValue(RedEnvelopeStatus type) {
|
||||
switch (type) {
|
||||
|
||||
case QXRedBagDrawTypeCollect:
|
||||
return "收藏房间抢红包";
|
||||
case QXRedBagDrawTypeTimeDown:
|
||||
return "00:00后开启红包";
|
||||
case QXRedBagDrawTypePwdSend:
|
||||
return "发送评论抢红包";
|
||||
default:
|
||||
return "点击打开红包";
|
||||
}
|
||||
}
|
||||
|
||||
private void qXRedBagDrawTypeFinished() {
|
||||
mBinding.textPl.setVisibility(View.GONE);
|
||||
mBinding.tvTitle.setVisibility(View.GONE);
|
||||
mBinding.tvPinl.setVisibility(View.GONE);
|
||||
mBinding.tvKl.setVisibility(View.GONE);
|
||||
mBinding.tvCk.setVisibility(View.VISIBLE);
|
||||
mBinding.tvRedCount.setText("手慢了,红包被领完了");
|
||||
mBinding.imRedK.setVisibility(View.GONE);
|
||||
mBinding.clPwd.setVisibility(View.GONE);
|
||||
mBinding.textShare.setVisibility(View.GONE);
|
||||
}
|
||||
private void handleReadyToOpen() {
|
||||
mBinding.textPl.setVisibility(View.GONE);
|
||||
mBinding.tvTitle.setVisibility(View.GONE);
|
||||
mBinding.tvPinl.setVisibility(View.GONE);
|
||||
mBinding.tvKl.setVisibility(View.VISIBLE);
|
||||
mBinding.tvKl.setVisibility(View.GONE);
|
||||
mBinding.imRedK.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
// 取消倒计时,避免内存泄漏
|
||||
if (countDownTimer != null) {
|
||||
countDownTimer.cancel();
|
||||
countDownTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void changeViewType(RedEnvelopeStatus type) {
|
||||
setType(type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="@dimen/dp_25"
|
||||
android:layout_marginEnd="@dimen/dp_25"
|
||||
android:layout_marginTop="@dimen/dp_156"
|
||||
android:layout_marginTop="@dimen/dp_146"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/im_x"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#fff"
|
||||
android:textSize="@dimen/sp_13"
|
||||
tools:text="已存入金币,可直接提现"
|
||||
tools:text="已存入金币"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_red_jb"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:layout_marginStart="@dimen/dp_31"
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
android:layout_marginEnd="@dimen/dp_10"
|
||||
android:background="@color/color_transparent">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -22,6 +23,16 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/im_kl_b"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:src="@mipmap/red_kl_b"
|
||||
android:scaleType="fitCenter"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/im_red_close"
|
||||
android:layout_width="@dimen/dp_20"
|
||||
@@ -79,7 +90,7 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_red_count"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:layout_marginTop="@dimen/dp_30"
|
||||
android:src="@mipmap/red_k"
|
||||
tools:ignore="ContentDescription"
|
||||
android:visibility="gone"/>
|
||||
@@ -93,51 +104,62 @@
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:layout_marginBottom="@dimen/dp_88"
|
||||
android:layout_marginBottom="@dimen/dp_80"
|
||||
android:textColor="@color/color_FFFFFFE0"
|
||||
android:textSize="@dimen/sp_23"
|
||||
android:textStyle="bold"
|
||||
tools:text="发布评论抢红包"
|
||||
android:paddingTop="@dimen/dp_9"
|
||||
android:paddingTop="@dimen/dp_12"
|
||||
android:gravity="top|center"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_pwd"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="@+id/text_pl"
|
||||
app:layout_constraintTop_toBottomOf="@+id/text_pl"
|
||||
android:textColor="@color/color_FFFFFFE0"
|
||||
android:textSize="@dimen/sp_12"
|
||||
android:text="口令红包参与条件"
|
||||
android:gravity="center"
|
||||
/>
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/text_pl">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_pinl"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="@+id/tv_title"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_title"
|
||||
android:textColor="@color/color_FFFFFFE0"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:textStyle="bold"
|
||||
android:text="发送评论:"
|
||||
android:gravity="center"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_kl"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toEndOf="@+id/tv_pinl"
|
||||
app:layout_constraintTop_toTopOf="@+id/tv_pinl"
|
||||
android:textColor="#FFCE47"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:textStyle="bold"
|
||||
android:text="这是一个口令"
|
||||
android:gravity="center"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/color_FFFFFFE0"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:textSize="@dimen/sp_12"
|
||||
android:text="口令红包参与条件"
|
||||
android:gravity="center"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_pinl"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="@+id/tv_title"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_title"
|
||||
android:textColor="@color/color_FFFFFFE0"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:textStyle="bold"
|
||||
android:text="发送评论:"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_kl"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toEndOf="@+id/tv_pinl"
|
||||
app:layout_constraintTop_toTopOf="@+id/tv_pinl"
|
||||
android:textColor="#FFCE47"
|
||||
android:textSize="@dimen/sp_14"
|
||||
android:textStyle="bold"
|
||||
android:text="这是一个口令"
|
||||
android:gravity="center"
|
||||
/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_ck"
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
android:layout_marginBottom="@dimen/dp_7"
|
||||
android:paddingTop="@dimen/dp_2"
|
||||
android:paddingBottom="@dimen/dp_2"
|
||||
android:layout_marginStart="@dimen/dp_15"
|
||||
android:layout_marginEnd="@dimen/dp_15"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
|
||||
@@ -3,16 +3,58 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
>
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
>
|
||||
<ImageView
|
||||
android:id="@+id/iv_red_bag"
|
||||
android:layout_width="@dimen/dp_60"
|
||||
android:layout_height="@dimen/dp_60"
|
||||
android:src="@mipmap/red"
|
||||
android:scaleType="fitXY"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_djs"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/iv_red_bag"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:textSize="@dimen/sp_10"
|
||||
android:paddingStart="@dimen/dp_5"
|
||||
android:paddingEnd="@dimen/dp_5"
|
||||
android:textColor="#fff"
|
||||
android:background="@drawable/bg_r6_000000"
|
||||
android:gravity="center"
|
||||
tools:text="00:00" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_user_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dp_16"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/iv_red_bag"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:textSize="@dimen/sp_12"
|
||||
android:textColor="#D04248"
|
||||
android:layout_marginBottom="@dimen/dp_5"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="@dimen/dp_8"
|
||||
android:text="烟花易冷" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/im_list_bj"
|
||||
android:layout_width="@dimen/dp_34"
|
||||
android:layout_height="@dimen/dp_18"
|
||||
android:src="@mipmap/red_liet_bj"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/iv_red_bag"
|
||||
android:layout_marginTop="-4dp"
|
||||
android:layout_marginEnd="-5dp"
|
||||
|
||||
/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user