feat : 红包界面修改

This commit is contained in:
eggmanQQQ
2025-02-25 17:33:54 +08:00
parent 3cbbd6fb42
commit d3f866dc88

View File

@@ -1,5 +1,6 @@
package com.chwl.app.avroom.dialog
import android.annotation.SuppressLint
import android.view.Gravity
import android.view.MotionEvent
import android.view.View
@@ -104,32 +105,66 @@ class RoomLuckyBagDialog : BaseDialogFragment<DialogRoomLuckyBagBinding>() {
) {
view?.let {
when (it.id) {
R.id.etNum -> {
mGiftSelect = position
showInputLayout()
}
R.id.up -> {
if (position.isVerify(mGiftData)) {
val data = mGiftData[position]
data.count = data.count.plus(1)
mGiftAdapter.notifyItemChanged(position,1)
mGiftDataSelectPos[position] = data
}
showGiftCoin()
}
R.id.down -> {
if (position.isVerify(mGiftData)) {
val data = mGiftData[position]
data.count = data.count.minus(1).coerceAtLeast(0)
mGiftAdapter.notifyItemChanged(position,1)
if (mIsGiftReview) {
if (position.isVerify(mGiftDataSelect)) {
val data = mGiftDataSelect[position]
data.count = data.count.plus(1)
mGiftAdapter.notifyItemChanged(position,1)
mGiftDataSelectPos.forEach { (t, u) ->
if (u.giftId == data.giftId) {
u.count = data.count
mGiftData.getOrNull(t)?.count = data.count
}
}
}
if (data.count <= 0) {
mGiftDataSelectPos.remove(position)
}else{
if (position.isVerify(mGiftData)) {
val data = mGiftData[position]
data.count = data.count.plus(1)
mGiftAdapter.notifyItemChanged(position,1)
mGiftDataSelectPos[position] = data
}
}
showGiftCoin()
}
R.id.down -> {
if (mIsGiftReview) {
if (position.isVerify(mGiftDataSelect)) {
val data = mGiftDataSelect[position]
data.count = data.count.minus(1).coerceAtLeast(0)
mGiftAdapter.notifyItemChanged(position,1)
mGiftDataSelectPos.forEach { (t, u) ->
if (u.giftId == data.giftId) {
u.count = data.count
mGiftData.getOrNull(t)?.count = data.count
}
}
}
} else {
if (position.isVerify(mGiftData)) {
val data = mGiftData[position]
data.count = data.count.minus(1).coerceAtLeast(0)
mGiftAdapter.notifyItemChanged(position,1)
if (data.count <= 0) {
mGiftDataSelectPos.remove(position)
}
}
}
showGiftCoin()
}
else -> {}
}
}
@@ -340,6 +375,22 @@ class RoomLuckyBagDialog : BaseDialogFragment<DialogRoomLuckyBagBinding>() {
binding.inputEdit.clearFocus()
binding.inputLayout.visibility = View.GONE
KeyBoardUtils.hideKeyBoard(activity, binding.inputEdit)
if (mIsGiftReview) {
if (mGiftSelect.isVerify(mGiftDataSelect)) {
val data = mGiftDataSelect[mGiftSelect]
data.isSelect = false
mGiftAdapter.notifyItemChanged(mGiftSelect,1)
}
}else{
if (mGiftSelect.isVerify(mGiftData)) {
val data = mGiftData[mGiftSelect]
data.isSelect = false
mGiftAdapter.notifyItemChanged(mGiftSelect,1)
}
}
mGiftSelect = -1
false
}
@@ -349,21 +400,41 @@ class RoomLuckyBagDialog : BaseDialogFragment<DialogRoomLuckyBagBinding>() {
if (text.isVerify()) {
count = text.toInt()
}
if (mGiftSelect.isVerify(mGiftData)) {
val data = mGiftData[mGiftSelect]
data.count = count
data.isSelect = false
mGiftAdapter.notifyItemChanged(mGiftSelect,1)
if (count > 0) {
mGiftDataSelectPos[mGiftSelect] = data
} else {
mGiftDataSelectPos.remove(mGiftSelect)
if (mIsGiftReview) {
if (mGiftSelect.isVerify(mGiftDataSelect)) {
val data = mGiftDataSelect[mGiftSelect]
data.count = count
data.isSelect = false
mGiftAdapter.notifyItemChanged(mGiftSelect,1)
mGiftDataSelectPos.forEach { (t, u) ->
if (u.giftId == data.giftId) {
u.count = data.count
mGiftData.getOrNull(t)?.count = data.count
}
}
}
}else{
if (mGiftSelect.isVerify(mGiftData)) {
val data = mGiftData[mGiftSelect]
data.count = count
data.isSelect = false
mGiftAdapter.notifyItemChanged(mGiftSelect,1)
if (count > 0) {
mGiftDataSelectPos[mGiftSelect] = data
} else {
mGiftDataSelectPos.remove(mGiftSelect)
}
}
}
binding.inputEdit.clearFocus()
binding.inputLayout.visibility = View.GONE
KeyBoardUtils.hideKeyBoard(activity, binding.inputEdit)
@@ -429,9 +500,6 @@ class RoomLuckyBagDialog : BaseDialogFragment<DialogRoomLuckyBagBinding>() {
binding.redBagDesc.setPadding2(bottom = 0.toDP())
mGiftDataSelectPos.forEach { (t, u) ->
u.isReView = false
}
mGiftAdapter.setNewData(mGiftData)
binding.rvListGiftType.postSafe {
mPageManager?.scrollToPagerIndex(0)
@@ -447,7 +515,7 @@ class RoomLuckyBagDialog : BaseDialogFragment<DialogRoomLuckyBagBinding>() {
binding.groupReViewGift.setVis(true)
binding.groupGiftSelect.setVis(false)
binding.flListGiftTypeLayout.setMargin(top = 83, bottom = 100)
binding.flListGiftTypeLayout.setMargin(top = 37, bottom = 90)
// binding.flListGiftTypeLayout.setViewWH(height = 300)
binding.bottomSpace.setVis(false)
@@ -456,10 +524,17 @@ class RoomLuckyBagDialog : BaseDialogFragment<DialogRoomLuckyBagBinding>() {
binding.redBagDesc.setPadding2(bottom = 0.toDP())
mGiftDataSelect.clear()
mGiftDataSelectPos.forEach { (t, u) ->
u.isReView = true
mGiftDataSelect.add(u)
val iterator = mGiftDataSelectPos.iterator()
while (iterator.hasNext()) {
val next = iterator.next().value
if (next.count > 0) {
mGiftDataSelect.add(next)
} else {
iterator.remove()
}
}
mGiftAdapter.setNewData(mGiftDataSelect)
binding.rvListGiftType.postSafe {
mPageManager?.scrollToPagerIndex(0)
@@ -499,8 +574,10 @@ class RoomLuckyBagDialog : BaseDialogFragment<DialogRoomLuckyBagBinding>() {
var giftCount = 0
var giftCoin = 0
mGiftDataSelectPos.forEach { (t, u) ->
giftCount += u.count
giftCoin += u.count * u.giftPrice
if (u.count > 0) {
giftCount += u.count
giftCoin += u.count * u.giftPrice
}
}
val redBagDesc = R.string._ver_24_sendHint.getString(giftCount, giftCoin)
@@ -577,10 +654,12 @@ class RoomLuckyBagDialog : BaseDialogFragment<DialogRoomLuckyBagBinding>() {
isSenting = true
val items = mutableListOf<LuckyBagGiftItemBody>()
mGiftDataSelectPos.keys.forEach{ key->
items.add(LuckyBagGiftItemBody().apply {
giftId = mGiftDataSelectPos[key]?.giftId ?: -1
giftNum = mGiftDataSelectPos[key]?.count ?: -1
})
if ((mGiftDataSelectPos[key]?.count ?: 0) > 0) {
items.add(LuckyBagGiftItemBody().apply {
giftId = mGiftDataSelectPos[key]?.giftId ?: -1
giftNum = mGiftDataSelectPos[key]?.count ?: -1
})
}
}
sentGiftBag(LuckyBagGiftBody().apply {
roomUid = AvRoomDataManager.get().roomUid
@@ -638,13 +717,13 @@ class RoomLuckyBagDialog : BaseDialogFragment<DialogRoomLuckyBagBinding>() {
helper.addOnClickListener(R.id.down)
helper.addOnClickListener(R.id.etNum)
if (item.isReView) {
it.selectViews.setVis(false)
it.giftCount.setVis(true)
} else {
it.selectViews.setVis(true)
it.giftCount.setVis(false)
}
// if (item.isReView) {
// it.selectViews.setVis(false)
// it.giftCount.setVis(true)
// } else {
// it.selectViews.setVis(true)
// it.giftCount.setVis(false)
// }
}
}