酒吧交友房 getGiftList 防止越界。
This commit is contained in:
@@ -198,14 +198,31 @@ class RoomPrivateFragment(var mRoomInfoResp: RoomInfoResp?) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getGiftList(list: List<RoonGiftModel>) {
|
override fun getGiftList(list: List<RoonGiftModel>) {
|
||||||
|
if (list.isEmpty())
|
||||||
|
return
|
||||||
if (giftList.isEmpty()) {
|
if (giftList.isEmpty()) {
|
||||||
giftList = list.toMutableList()
|
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) {
|
for (i in showList.indices) {
|
||||||
val itemImage = giftViewList[i]
|
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 {
|
val (width, height) = when {
|
||||||
price > 500 -> Pair(64, 64)
|
price > 500 -> Pair(64, 64)
|
||||||
|
|||||||
Reference in New Issue
Block a user