|
@@ -10,6 +10,7 @@ import android.view.View
|
|
import android.widget.Toast
|
|
import android.widget.Toast
|
|
import androidx.fragment.app.activityViewModels
|
|
import androidx.fragment.app.activityViewModels
|
|
import androidx.fragment.app.viewModels
|
|
import androidx.fragment.app.viewModels
|
|
|
|
+import androidx.recyclerview.widget.LinearLayoutManager
|
|
import androidx.viewpager.widget.ViewPager
|
|
import androidx.viewpager.widget.ViewPager
|
|
import com.facebook.internal.AppCall
|
|
import com.facebook.internal.AppCall
|
|
import com.google.gson.Gson
|
|
import com.google.gson.Gson
|
|
@@ -28,6 +29,7 @@ import com.swago.room.databinding.DialogGiftBinding
|
|
import com.swago.room.dialog.ReachLevelServiceDialog
|
|
import com.swago.room.dialog.ReachLevelServiceDialog
|
|
import com.swago.room.dialog.UnReachLevelDialog
|
|
import com.swago.room.dialog.UnReachLevelDialog
|
|
import com.swago.room.gift.GiftConfig.giftSelectedWhichType
|
|
import com.swago.room.gift.GiftConfig.giftSelectedWhichType
|
|
|
|
+import com.swago.room.gift.audio.MaiUserAdapter
|
|
import com.swago.room.vm.MsgVm
|
|
import com.swago.room.vm.MsgVm
|
|
import net.lucode.hackware.magicindicator.ViewPagerHelper
|
|
import net.lucode.hackware.magicindicator.ViewPagerHelper
|
|
import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator
|
|
import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator
|
|
@@ -50,7 +52,7 @@ class GiftDialog : BaseXDFragment<DialogGiftBinding>() {
|
|
private var receiveId = ""
|
|
private var receiveId = ""
|
|
private var receiveName = ""
|
|
private var receiveName = ""
|
|
|
|
|
|
- var openSendRedEnvelopeFun:(()->Unit)? = null
|
|
|
|
|
|
+ var openSendRedEnvelopeFun: (() -> Unit)? = null
|
|
|
|
|
|
private val gson by lazy {
|
|
private val gson by lazy {
|
|
Gson()
|
|
Gson()
|
|
@@ -67,7 +69,7 @@ class GiftDialog : BaseXDFragment<DialogGiftBinding>() {
|
|
private var luckyFragment: GiftFragment? = null
|
|
private var luckyFragment: GiftFragment? = null
|
|
private var hotFragment: GiftFragment? = null
|
|
private var hotFragment: GiftFragment? = null
|
|
private var luxuryFragment: GiftFragment? = null
|
|
private var luxuryFragment: GiftFragment? = null
|
|
- private var specialFragment:GiftFragment? = null
|
|
|
|
|
|
+ private var specialFragment: GiftFragment? = null
|
|
|
|
|
|
private var luckyData = ArrayList<GiftModel>()
|
|
private var luckyData = ArrayList<GiftModel>()
|
|
private var hotData = ArrayList<GiftModel>()
|
|
private var hotData = ArrayList<GiftModel>()
|
|
@@ -79,6 +81,11 @@ class GiftDialog : BaseXDFragment<DialogGiftBinding>() {
|
|
|
|
|
|
private var json: String? = ""
|
|
private var json: String? = ""
|
|
|
|
|
|
|
|
+ private val selectedUserList = ArrayList<String>()
|
|
|
|
+ private val adapter by lazy {
|
|
|
|
+ MaiUserAdapter()
|
|
|
|
+ }
|
|
|
|
+
|
|
init {
|
|
init {
|
|
setGravity(Gravity.BOTTOM)
|
|
setGravity(Gravity.BOTTOM)
|
|
setDimAmount(0f)
|
|
setDimAmount(0f)
|
|
@@ -101,10 +108,23 @@ class GiftDialog : BaseXDFragment<DialogGiftBinding>() {
|
|
override fun initOther() {
|
|
override fun initOther() {
|
|
arguments?.let {
|
|
arguments?.let {
|
|
payVm.getCoins()
|
|
payVm.getCoins()
|
|
|
|
+ SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
|
|
+ if (iRoomInfo.getRoomType() == 1) {
|
|
|
|
+ binding.tvSender.visibility = View.VISIBLE
|
|
|
|
+ binding.rvAudioUser.visibility = View.INVISIBLE
|
|
|
|
+ //先走缓存
|
|
|
|
+ json = SpUtil.readString("giftList")
|
|
|
|
+ } else if (iRoomInfo.getRoomType() == 2) {
|
|
|
|
+ //获取语音房麦位用户列表
|
|
|
|
+ binding.tvSender.visibility = View.GONE
|
|
|
|
+ binding.rvAudioUser.visibility = View.VISIBLE
|
|
|
|
+ getAudioMaiList()
|
|
|
|
+ json = SpUtil.readString("audioGiftList")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
receiveId = it.getString("receiveId", "")
|
|
receiveId = it.getString("receiveId", "")
|
|
receiveName = it.getString("receiveName", "")
|
|
receiveName = it.getString("receiveName", "")
|
|
- //先走缓存
|
|
|
|
- json = SpUtil.readString("giftList")
|
|
|
|
|
|
+
|
|
if (json.isNullOrEmpty()) {
|
|
if (json.isNullOrEmpty()) {
|
|
|
|
|
|
} else {
|
|
} else {
|
|
@@ -287,9 +307,13 @@ class GiftDialog : BaseXDFragment<DialogGiftBinding>() {
|
|
when (type) {
|
|
when (type) {
|
|
1 -> {
|
|
1 -> {
|
|
//幸运
|
|
//幸运
|
|
- binding.combo.visibility = View.VISIBLE
|
|
|
|
- binding.tvToSend.visibility = View.GONE
|
|
|
|
- binding.combo.start()
|
|
|
|
|
|
+ SwagoRoomManager.iRoomInfo?.let {
|
|
|
|
+ if (it.getRoomType() == 1){
|
|
|
|
+ binding.combo.visibility = View.VISIBLE
|
|
|
|
+ binding.combo.start()
|
|
|
|
+ binding.tvToSend.visibility = View.GONE
|
|
|
|
+ }
|
|
|
|
+ }
|
|
val gifModel =
|
|
val gifModel =
|
|
luckyData[GiftConfig.giftSelectedPageIndex * 8 + GiftConfig.giftSelectedPageSelectedPosition]
|
|
luckyData[GiftConfig.giftSelectedPageIndex * 8 + GiftConfig.giftSelectedPageSelectedPosition]
|
|
LogUtil.d("礼物id", "${gifModel.gift_name}")
|
|
LogUtil.d("礼物id", "${gifModel.gift_name}")
|
|
@@ -318,7 +342,7 @@ class GiftDialog : BaseXDFragment<DialogGiftBinding>() {
|
|
val gifModel =
|
|
val gifModel =
|
|
specialData[GiftConfig.giftSelectedPageIndex * 8 + GiftConfig.giftSelectedPageSelectedPosition]
|
|
specialData[GiftConfig.giftSelectedPageIndex * 8 + GiftConfig.giftSelectedPageSelectedPosition]
|
|
LogUtil.d("礼物id", "${gifModel.gift_name}")
|
|
LogUtil.d("礼物id", "${gifModel.gift_name}")
|
|
- when(gifModel.gift_mode){
|
|
|
|
|
|
+ when (gifModel.gift_mode) {
|
|
1 -> {
|
|
1 -> {
|
|
openSendRedEnvelopeFun?.invoke()
|
|
openSendRedEnvelopeFun?.invoke()
|
|
dismissAllowingStateLoss()
|
|
dismissAllowingStateLoss()
|
|
@@ -335,6 +359,14 @@ class GiftDialog : BaseXDFragment<DialogGiftBinding>() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private fun getAudioMaiList() {
|
|
|
|
+ SwagoRoomManager.iRoomInfo?.let {
|
|
|
|
+ if (it.getRoomType() == 2) {
|
|
|
|
+ giftVm.getMaiUserList()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private fun resetSendState() {
|
|
private fun resetSendState() {
|
|
binding.combo.cancel()
|
|
binding.combo.cancel()
|
|
binding.combo.visibility = View.GONE
|
|
binding.combo.visibility = View.GONE
|
|
@@ -343,17 +375,30 @@ class GiftDialog : BaseXDFragment<DialogGiftBinding>() {
|
|
|
|
|
|
|
|
|
|
private fun sendGift(giftModel: GiftModel, isCombo: Int = 0, giftNum: Int = 1) {
|
|
private fun sendGift(giftModel: GiftModel, isCombo: Int = 0, giftNum: Int = 1) {
|
|
- giftBatch++
|
|
|
|
- if (receiveId.isNotEmpty()) {
|
|
|
|
- SwagoRoomManager.iRoomInfo?.let {
|
|
|
|
- giftVm.sendGift(
|
|
|
|
- it.getRoomId(),
|
|
|
|
- giftModel.id,
|
|
|
|
- giftBatch,
|
|
|
|
- receiveId,
|
|
|
|
- isCombo,
|
|
|
|
- giftNum
|
|
|
|
- )
|
|
|
|
|
|
+ SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
|
|
+ giftBatch++
|
|
|
|
+ if (iRoomInfo.getRoomType() == 1) {
|
|
|
|
+ if (receiveId.isNotEmpty()) {
|
|
|
|
+ giftVm.sendGift(
|
|
|
|
+ iRoomInfo.getRoomId(),
|
|
|
|
+ giftModel.id,
|
|
|
|
+ giftBatch,
|
|
|
|
+ receiveId,
|
|
|
|
+ isCombo,
|
|
|
|
+ giftNum
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+ } else if (iRoomInfo.getRoomType() == 2) {
|
|
|
|
+ //语音房送礼
|
|
|
|
+ if (selectedUserList.isNotEmpty()) {
|
|
|
|
+ giftVm.sendAudioGift(
|
|
|
|
+ iRoomInfo.getRoomId(),
|
|
|
|
+ giftModel.id,
|
|
|
|
+ giftBatch,
|
|
|
|
+ selectedUserList,
|
|
|
|
+ giftNum
|
|
|
|
+ )
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -362,7 +407,13 @@ class GiftDialog : BaseXDFragment<DialogGiftBinding>() {
|
|
giftVm.allGiftLiveData.observe(this) {
|
|
giftVm.allGiftLiveData.observe(this) {
|
|
val netJson = gson.toJson(it)
|
|
val netJson = gson.toJson(it)
|
|
if (json != netJson || json.isNullOrEmpty()) {
|
|
if (json != netJson || json.isNullOrEmpty()) {
|
|
- SpUtil.putString("giftList", netJson)
|
|
|
|
|
|
+ SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
|
|
+ if (iRoomInfo.getRoomType() == 1) {
|
|
|
|
+ SpUtil.putString("giftList", netJson)
|
|
|
|
+ } else if (iRoomInfo.getRoomType() == 2) {
|
|
|
|
+ SpUtil.putString("audioGiftList", netJson)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
it.forEach { giftAllModel ->
|
|
it.forEach { giftAllModel ->
|
|
when (giftAllModel.gift_type) {
|
|
when (giftAllModel.gift_type) {
|
|
@@ -400,7 +451,7 @@ class GiftDialog : BaseXDFragment<DialogGiftBinding>() {
|
|
|
|
|
|
giftVm.sendResultLiveData.observe(this) {
|
|
giftVm.sendResultLiveData.observe(this) {
|
|
if (it != null) {
|
|
if (it != null) {
|
|
- if (it.im_data!=null){
|
|
|
|
|
|
+ if (it.im_data != null) {
|
|
msgVm.showGiftDanDao?.invoke(it.im_data)
|
|
msgVm.showGiftDanDao?.invoke(it.im_data)
|
|
msgVm.inComeChange?.invoke(it.im_data.incomeCount)
|
|
msgVm.inComeChange?.invoke(it.im_data.incomeCount)
|
|
if (it.im_data.multiple >= 500) {
|
|
if (it.im_data.multiple >= 500) {
|
|
@@ -408,31 +459,91 @@ class GiftDialog : BaseXDFragment<DialogGiftBinding>() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (returnGiftBatch < it.gift_batch){
|
|
|
|
|
|
+ if (returnGiftBatch < it.gift_batch) {
|
|
UserInfo.getUserInfo()?.user_coins = it.user_coins
|
|
UserInfo.getUserInfo()?.user_coins = it.user_coins
|
|
binding.tvCoins.text = it.user_coins ?: "0"
|
|
binding.tvCoins.text = it.user_coins ?: "0"
|
|
returnGiftBatch = it.gift_batch
|
|
returnGiftBatch = it.gift_batch
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (type==2||type==3){
|
|
|
|
|
|
+ if (type == 2 || type == 3) {
|
|
dismissAllowingStateLoss()
|
|
dismissAllowingStateLoss()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
giftVm.sendGiftCodeLiveData.observe(this) {
|
|
giftVm.sendGiftCodeLiveData.observe(this) {
|
|
- when(it.code){
|
|
|
|
|
|
+ when (it.code) {
|
|
|
|
+ 517 -> {
|
|
|
|
+ val payDialog = PayDialog.newInstance()
|
|
|
|
+ payDialog.show(parentFragmentManager, "PayDialog")
|
|
|
|
+ dismissAllowingStateLoss()
|
|
|
|
+ Toast.makeText(AppContext.getContext(), it.msg, Toast.LENGTH_SHORT).show()
|
|
|
|
+ }
|
|
|
|
+ 542, 543 -> {
|
|
|
|
+ UnReachLevelDialog.newInstance(it.msg)
|
|
|
|
+ .show(parentFragmentManager, "UnReachLevelDialog")
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 544 -> {
|
|
|
|
+ ReachLevelServiceDialog.newInstance(it.msg)
|
|
|
|
+ .show(parentFragmentManager, "ReachLevelServiceDialog")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ giftVm.maiUserListLiveData.observe(this) { data ->
|
|
|
|
+ activity?.let {
|
|
|
|
+ data.forEach {
|
|
|
|
+ it.selected = true
|
|
|
|
+ selectedUserList.add(it.user_id)
|
|
|
|
+ }
|
|
|
|
+ binding.rvAudioUser.layoutManager = LinearLayoutManager(it)
|
|
|
|
+ binding.rvAudioUser.adapter = adapter
|
|
|
|
+ adapter.setNewData(data)
|
|
|
|
+ adapter.setOnItemClickListener { _, view, position ->
|
|
|
|
+ adapter.data[position].selected = !adapter.data[position].selected
|
|
|
|
+ if (adapter.data[position].selected){
|
|
|
|
+ selectedUserList.add(adapter.data[position].user_id)
|
|
|
|
+ }else{
|
|
|
|
+ selectedUserList.remove(adapter.data[position].user_id)
|
|
|
|
+ }
|
|
|
|
+ adapter.notifyItemChanged(position)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ giftVm.sendResultAudioLiveData.observe(this){
|
|
|
|
+ if (it != null) {
|
|
|
|
+ msgVm.inComeChange?.invoke(it.incomeCount)
|
|
|
|
+// if (it.multiple >= 500) {
|
|
|
|
+// msgVm.waftFun?.invoke(it.im_data)
|
|
|
|
+// }
|
|
|
|
+ if (returnGiftBatch < it.giftBatch) {
|
|
|
|
+ UserInfo.getUserInfo()?.user_coins = it.userCoins
|
|
|
|
+ binding.tvCoins.text = it.userCoins
|
|
|
|
+ returnGiftBatch = it.giftBatch
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (type == 2 || type == 3) {
|
|
|
|
+ dismissAllowingStateLoss()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ giftVm.sendGiftAudioCodeLiveData.observe(this){
|
|
|
|
+ when (it.code) {
|
|
517 -> {
|
|
517 -> {
|
|
val payDialog = PayDialog.newInstance()
|
|
val payDialog = PayDialog.newInstance()
|
|
payDialog.show(parentFragmentManager, "PayDialog")
|
|
payDialog.show(parentFragmentManager, "PayDialog")
|
|
dismissAllowingStateLoss()
|
|
dismissAllowingStateLoss()
|
|
Toast.makeText(AppContext.getContext(), it.msg, Toast.LENGTH_SHORT).show()
|
|
Toast.makeText(AppContext.getContext(), it.msg, Toast.LENGTH_SHORT).show()
|
|
}
|
|
}
|
|
- 542,543 -> {
|
|
|
|
- UnReachLevelDialog.newInstance(it.msg).show(parentFragmentManager,"UnReachLevelDialog")
|
|
|
|
|
|
+ 542, 543 -> {
|
|
|
|
+ UnReachLevelDialog.newInstance(it.msg)
|
|
|
|
+ .show(parentFragmentManager, "UnReachLevelDialog")
|
|
}
|
|
}
|
|
|
|
|
|
544 -> {
|
|
544 -> {
|
|
- ReachLevelServiceDialog.newInstance(it.msg).show(parentFragmentManager,"ReachLevelServiceDialog")
|
|
|
|
|
|
+ ReachLevelServiceDialog.newInstance(it.msg)
|
|
|
|
+ .show(parentFragmentManager, "ReachLevelServiceDialog")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|