酒吧交友房 getGiftList 防止越界。

This commit is contained in:
2026-01-09 14:35:44 +08:00
parent 5946cf97b9
commit 2589b97f29

View File

@@ -198,14 +198,31 @@ class RoomPrivateFragment(var mRoomInfoResp: RoomInfoResp?) :
}
override fun getGiftList(list: List<RoonGiftModel>) {
if (list.isEmpty())
return
if (giftList.isEmpty()) {
giftList = list.toMutableList()
val showList = list.shuffled().take(6)
val showList = if (giftList.size > 6) {
list.shuffled().take(6)
}else{
list.shuffled().take(giftList.size-1)
}
for (i in showList.indices) {
val itemImage = giftViewList[i]
val price = showList[i].gift_price.toInt()
itemImage.tag = showList[i].gift_id
val price = if (showList.size > i){
showList[i].gift_price.toInt()
}else{
showList[showList.size - 1].gift_price.toInt()
}
itemImage.tag = if (showList.size > i){
showList[i].gift_id
}else{
showList[showList.size - 1].gift_id
}
// 根据价格设置不同的宽高
val (width, height) = when {
price > 500 -> Pair(64, 64)