|
@@ -1,13 +1,17 @@
|
|
package com.swago.room.base
|
|
package com.swago.room.base
|
|
|
|
|
|
|
|
+import android.Manifest
|
|
import android.graphics.Rect
|
|
import android.graphics.Rect
|
|
import android.text.TextUtils
|
|
import android.text.TextUtils
|
|
import android.view.View
|
|
import android.view.View
|
|
import android.view.ViewGroup
|
|
import android.view.ViewGroup
|
|
|
|
+import android.widget.ImageView
|
|
|
|
+import android.widget.TextView
|
|
import android.widget.Toast
|
|
import android.widget.Toast
|
|
import androidx.constraintlayout.widget.ConstraintLayout
|
|
import androidx.constraintlayout.widget.ConstraintLayout
|
|
import androidx.fragment.app.activityViewModels
|
|
import androidx.fragment.app.activityViewModels
|
|
import androidx.lifecycle.lifecycleScope
|
|
import androidx.lifecycle.lifecycleScope
|
|
|
|
+import androidx.recyclerview.widget.GridLayoutManager
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
import com.alibaba.android.arouter.launcher.ARouter
|
|
import com.alibaba.android.arouter.launcher.ARouter
|
|
@@ -17,26 +21,38 @@ import com.liulishuo.okdownload.DownloadTask
|
|
import com.liulishuo.okdownload.core.breakpoint.BreakpointInfo
|
|
import com.liulishuo.okdownload.core.breakpoint.BreakpointInfo
|
|
import com.liulishuo.okdownload.core.cause.EndCause
|
|
import com.liulishuo.okdownload.core.cause.EndCause
|
|
import com.liulishuo.okdownload.core.cause.ResumeFailedCause
|
|
import com.liulishuo.okdownload.core.cause.ResumeFailedCause
|
|
|
|
+import com.permissionx.guolindev.PermissionX
|
|
import com.swago.baseswago.PersonDataDFragment
|
|
import com.swago.baseswago.PersonDataDFragment
|
|
import com.swago.baseswago.UserVm
|
|
import com.swago.baseswago.UserVm
|
|
|
|
+import com.swago.baseswago.agora.AgoraManager
|
|
import com.swago.baseswago.baseroom.*
|
|
import com.swago.baseswago.baseroom.*
|
|
import com.swago.baseswago.constant.ARouteConstant
|
|
import com.swago.baseswago.constant.ARouteConstant
|
|
import com.swago.baseswago.constant.UrlConstant
|
|
import com.swago.baseswago.constant.UrlConstant
|
|
|
|
+import com.swago.baseswago.cusview.MediumTextView
|
|
|
|
+import com.swago.baseswago.cusview.SwagoImageView
|
|
|
|
+import com.swago.baseswago.dialog.ChoiceDialogFragment
|
|
import com.swago.baseswago.fragment.BaseXFragment
|
|
import com.swago.baseswago.fragment.BaseXFragment
|
|
import com.swago.baseswago.im.IRoomChat
|
|
import com.swago.baseswago.im.IRoomChat
|
|
import com.swago.baseswago.model.im.GamePrize
|
|
import com.swago.baseswago.model.im.GamePrize
|
|
import com.swago.baseswago.model.im.RoomSystemMsgBean
|
|
import com.swago.baseswago.model.im.RoomSystemMsgBean
|
|
import com.swago.baseswago.model.live.RoomConfig
|
|
import com.swago.baseswago.model.live.RoomConfig
|
|
import com.swago.baseswago.model.live.RoomUserModel
|
|
import com.swago.baseswago.model.live.RoomUserModel
|
|
|
|
+import com.swago.baseswago.model.live.audio.AudioSeatModel
|
|
|
|
+import com.swago.baseswago.model.live.audio.IMAudioModel
|
|
import com.swago.baseswago.model.live.game.GameModel
|
|
import com.swago.baseswago.model.live.game.GameModel
|
|
import com.swago.baseswago.util.*
|
|
import com.swago.baseswago.util.*
|
|
import com.swago.room.R
|
|
import com.swago.room.R
|
|
import com.swago.room.adapter.RoomChatAdapter
|
|
import com.swago.room.adapter.RoomChatAdapter
|
|
|
|
+import com.swago.room.audio.AudioActionDialog
|
|
|
|
+import com.swago.room.audio.AudioRoomManager
|
|
|
|
+import com.swago.room.audio.AudioSeatAdapter
|
|
|
|
+import com.swago.room.audio.IAudioRoomListener
|
|
import com.swago.room.bean.UserRoomModel
|
|
import com.swago.room.bean.UserRoomModel
|
|
import com.swago.room.databinding.FragmentBaseComBinding
|
|
import com.swago.room.databinding.FragmentBaseComBinding
|
|
import com.swago.room.dialog.AudienceListDialog
|
|
import com.swago.room.dialog.AudienceListDialog
|
|
import com.swago.room.dialog.MessageListDialog
|
|
import com.swago.room.dialog.MessageListDialog
|
|
import com.swago.room.dialog.SendMsgDialog
|
|
import com.swago.room.dialog.SendMsgDialog
|
|
|
|
+import com.swago.room.enum.RoomType
|
|
import com.swago.room.game.GamePlayDialog
|
|
import com.swago.room.game.GamePlayDialog
|
|
import com.swago.room.gift.GiftDialog
|
|
import com.swago.room.gift.GiftDialog
|
|
import com.swago.room.gift.GiftVm
|
|
import com.swago.room.gift.GiftVm
|
|
@@ -57,6 +73,7 @@ import com.swago.room.vm.RoomVm
|
|
import com.swago.room.widget.AnchorFooterView
|
|
import com.swago.room.widget.AnchorFooterView
|
|
import com.swago.room.widget.ComHeaderView
|
|
import com.swago.room.widget.ComHeaderView
|
|
import com.swago.room.widget.UserFooterView
|
|
import com.swago.room.widget.UserFooterView
|
|
|
|
+import io.agora.rtc.IRtcEngineEventHandler
|
|
import kotlinx.coroutines.Dispatchers
|
|
import kotlinx.coroutines.Dispatchers
|
|
import kotlinx.coroutines.GlobalScope
|
|
import kotlinx.coroutines.GlobalScope
|
|
import kotlinx.coroutines.delay
|
|
import kotlinx.coroutines.delay
|
|
@@ -70,8 +87,8 @@ import java.util.concurrent.CopyOnWriteArrayList
|
|
*description:
|
|
*description:
|
|
*/
|
|
*/
|
|
abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
- IRoomActiveListener,IPKListener,
|
|
|
|
- RoomTimer.TimeTickListener {
|
|
|
|
|
|
+ IRoomActiveListener, IPKListener,
|
|
|
|
+ RoomTimer.TimeTickListener, IAudioRoomListener {
|
|
|
|
|
|
val giftVm by activityViewModels<GiftVm>()
|
|
val giftVm by activityViewModels<GiftVm>()
|
|
val pkVm by activityViewModels<PkVm>()
|
|
val pkVm by activityViewModels<PkVm>()
|
|
@@ -94,13 +111,13 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
abstract val iHeader: IHeader
|
|
abstract val iHeader: IHeader
|
|
abstract val iFooter: IFooter
|
|
abstract val iFooter: IFooter
|
|
|
|
|
|
- var roomConfig:RoomConfig? = null
|
|
|
|
|
|
+ var roomConfig: RoomConfig? = null
|
|
|
|
|
|
var dialog: SendMsgDialog? = null
|
|
var dialog: SendMsgDialog? = null
|
|
var gameDialog: GamePlayDialog? = null
|
|
var gameDialog: GamePlayDialog? = null
|
|
var msgListDialog: MessageListDialog? = null
|
|
var msgListDialog: MessageListDialog? = null
|
|
|
|
|
|
- val gameList by lazy {
|
|
|
|
|
|
+ val gameList by lazy {
|
|
ArrayList<GameModel>()
|
|
ArrayList<GameModel>()
|
|
}
|
|
}
|
|
|
|
|
|
@@ -128,6 +145,7 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
RoomTimer.timeTickList.add(this)
|
|
RoomTimer.timeTickList.add(this)
|
|
PKStateManager.addPKListener(this)
|
|
PKStateManager.addPKListener(this)
|
|
SwagoRoomManager.addListener(this)
|
|
SwagoRoomManager.addListener(this)
|
|
|
|
+ AudioRoomManager.addListener(this)
|
|
binding.headFl.addView(iHeader.getHeaderView())
|
|
binding.headFl.addView(iHeader.getHeaderView())
|
|
binding.footerFl.addView(iFooter.getFooterView())
|
|
binding.footerFl.addView(iFooter.getFooterView())
|
|
setHeaderViewPosition()
|
|
setHeaderViewPosition()
|
|
@@ -135,6 +153,8 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
giftVm.getGiftList()
|
|
giftVm.getGiftList()
|
|
//获取直播间配置
|
|
//获取直播间配置
|
|
roomVm.getRoomConfig()
|
|
roomVm.getRoomConfig()
|
|
|
|
+ //初始话语音列表
|
|
|
|
+ initAudioRvList()
|
|
//飘条
|
|
//飘条
|
|
waftManager.init()
|
|
waftManager.init()
|
|
waftManager.waftViewList.add(binding.waftView)
|
|
waftManager.waftViewList.add(binding.waftView)
|
|
@@ -145,7 +165,7 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
danDaoManager.giftDanDaoViewList.add(binding.danDaoView2)
|
|
danDaoManager.giftDanDaoViewList.add(binding.danDaoView2)
|
|
danDaoManager.giftDanDaoViewList.add(binding.danDaoView3)
|
|
danDaoManager.giftDanDaoViewList.add(binding.danDaoView3)
|
|
//进场特效
|
|
//进场特效
|
|
- msgVm.joinRoomManager.initViewStub(binding.joinRoomViewStub,activity)
|
|
|
|
|
|
+ msgVm.joinRoomManager.initViewStub(binding.joinRoomViewStub, activity)
|
|
|
|
|
|
val layoutManager = LinearLayoutManager(context)
|
|
val layoutManager = LinearLayoutManager(context)
|
|
layoutManager.stackFromEnd = true
|
|
layoutManager.stackFromEnd = true
|
|
@@ -168,6 +188,98 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private fun initAudioRvList() {
|
|
|
|
+ activity?.let {
|
|
|
|
+ binding.rvAudio.addItemDecoration(GridItemDecoration())
|
|
|
|
+ binding.rvAudio.layoutManager = GridLayoutManager(it, 4)
|
|
|
|
+ binding.rvAudio.adapter = audioSeatAdapter
|
|
|
|
+ audioSeatAdapter.setOnItemClickListener { _, _, position ->
|
|
|
|
+ val audioSeatModel = audioSeatAdapter.data[position]
|
|
|
|
+ if (audioSeatModel.user_id == "0") {
|
|
|
|
+ //麦位没有人
|
|
|
|
+ if (SwagoRoomManager.roleType == RoleType.anchor) {
|
|
|
|
+ //主播点击麦位
|
|
|
|
+ AudioActionDialog.newInstance(audioSeatModel)
|
|
|
|
+ .show(childFragmentManager, "AudioActionDialog")
|
|
|
|
+ } else {
|
|
|
|
+ //用户点击了空位麦 如果是麦位被锁弹提示
|
|
|
|
+ //如果麦位没有被锁 先判断自己是否在麦位上 如果在弹提示 如果不在弹上麦弹窗
|
|
|
|
+ if (audioSeatModel.lock_status == 2) {
|
|
|
|
+ Toast.makeText(AppContext.getContext(), "当前麦位已被锁", Toast.LENGTH_SHORT)
|
|
|
|
+ .show()
|
|
|
|
+ }else{
|
|
|
|
+ if (AudioRoomManager.isOnMic){
|
|
|
|
+ Toast.makeText(AppContext.getContext(), "您已经在麦位上", Toast.LENGTH_SHORT)
|
|
|
|
+ .show()
|
|
|
|
+ }else{
|
|
|
|
+ ChoiceDialogFragment.newInstance("您想要上麦么?").apply {
|
|
|
|
+ this.sureFun = {
|
|
|
|
+ PermissionX.init(it)
|
|
|
|
+ .permissions(
|
|
|
|
+ Manifest.permission.RECORD_AUDIO,
|
|
|
|
+ Manifest.permission.CAMERA,
|
|
|
|
+ Manifest.permission.READ_EXTERNAL_STORAGE)
|
|
|
|
+ .request { allGranted, grantedList, deniedList ->
|
|
|
|
+ if (allGranted) {
|
|
|
|
+ roomVm.userApplyOnMic(audioSeatModel.maiIndex)
|
|
|
|
+ } else {
|
|
|
|
+ Toast.makeText(
|
|
|
|
+ AppContext.getContext(),
|
|
|
|
+ "These permissions are denied: $deniedList",
|
|
|
|
+ Toast.LENGTH_LONG
|
|
|
|
+ ).show()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }.show(childFragmentManager,"ChoiceDialogFragment")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ //麦位有人
|
|
|
|
+ if (SwagoRoomManager.roleType == RoleType.anchor) {
|
|
|
|
+ //主播点击麦位
|
|
|
|
+ AudioActionDialog.newInstance(audioSeatModel)
|
|
|
|
+ .show(childFragmentManager, "AudioActionDialog")
|
|
|
|
+ } else {
|
|
|
|
+ //用户点击了有人的麦位
|
|
|
|
+ //如果点击的麦位不是自己弹资料卡 如果是自己弹操作弹窗
|
|
|
|
+ SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
|
|
+ audioSeatModel.user_id?.let {
|
|
|
|
+ UserInfo.getUserInfo()?.let { userInfoModel ->
|
|
|
|
+ if (userInfoModel.id == it){
|
|
|
|
+ AudioActionDialog.newInstance(audioSeatModel)
|
|
|
|
+ .show(childFragmentManager, "AudioActionDialog")
|
|
|
|
+ }else{
|
|
|
|
+ PersonDataDFragment.newInstance(it,
|
|
|
|
+ SwagoRoomManager.roleType==RoleType.anchor,true,iRoomInfo.getRoomId()).apply {
|
|
|
|
+ this.openGiftDialog = { nickName, userId ->
|
|
|
|
+ openGiftDialog(nickName, userId)
|
|
|
|
+ }
|
|
|
|
+ this.sendMsgInRoom = {
|
|
|
|
+ if (isForbid) {
|
|
|
|
+ Toast.makeText(
|
|
|
|
+ AppContext.getContext(),
|
|
|
|
+ AppContext.getContext().resources.getString(
|
|
|
|
+ R.string.you_are_been_forbid
|
|
|
|
+ ),
|
|
|
|
+ Toast.LENGTH_SHORT
|
|
|
|
+ ).show()
|
|
|
|
+ } else {
|
|
|
|
+ openSendMessageDialog("@${it} ")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }.show(childFragmentManager,"PersonDataDFragment")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
var listener = KeyboardUtils.OnSoftInputChangedListener {
|
|
var listener = KeyboardUtils.OnSoftInputChangedListener {
|
|
if (it == 0) {
|
|
if (it == 0) {
|
|
setChatRvPop(false, it)
|
|
setChatRvPop(false, it)
|
|
@@ -188,14 +300,14 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
it?.let {
|
|
it?.let {
|
|
roomUserList.clear()
|
|
roomUserList.clear()
|
|
roomUserList.addAll(it.list)
|
|
roomUserList.addAll(it.list)
|
|
- (iHeader as ComHeaderView).updateRoomUser(roomUserList,it.count)
|
|
|
|
|
|
+ (iHeader as ComHeaderView).updateRoomUser(roomUserList, it.count)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- msgVm.updateUserRoom = { data,count ->
|
|
|
|
|
|
+ msgVm.updateUserRoom = { data, count ->
|
|
roomUserList.clear()
|
|
roomUserList.clear()
|
|
roomUserList.addAll(data)
|
|
roomUserList.addAll(data)
|
|
- (iHeader as ComHeaderView).updateRoomUser(roomUserList,count)
|
|
|
|
|
|
+ (iHeader as ComHeaderView).updateRoomUser(roomUserList, count)
|
|
}
|
|
}
|
|
|
|
|
|
chatAdapter.showUserInfoDialog = {
|
|
chatAdapter.showUserInfoDialog = {
|
|
@@ -203,7 +315,12 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
isAnchor = iRoomInfo.getAnchorId() == UserInfo.getUserInfo()?.id
|
|
isAnchor = iRoomInfo.getAnchorId() == UserInfo.getUserInfo()?.id
|
|
}
|
|
}
|
|
- PersonDataDFragment.newInstance(it.getSenderId(), isAnchor = isAnchor, inRoom = true,SwagoRoomManager.iRoomInfo?.getRoomId()?:"")
|
|
|
|
|
|
+ PersonDataDFragment.newInstance(
|
|
|
|
+ it.getSenderId(),
|
|
|
|
+ isAnchor = isAnchor,
|
|
|
|
+ inRoom = true,
|
|
|
|
+ SwagoRoomManager.iRoomInfo?.getRoomId() ?: ""
|
|
|
|
+ )
|
|
.apply {
|
|
.apply {
|
|
this.openGiftDialog = { nickName, userId ->
|
|
this.openGiftDialog = { nickName, userId ->
|
|
openGiftDialog(nickName, userId)
|
|
openGiftDialog(nickName, userId)
|
|
@@ -211,9 +328,11 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
this.sendMsgInRoom = {
|
|
this.sendMsgInRoom = {
|
|
if (isForbid) {
|
|
if (isForbid) {
|
|
Toast.makeText(
|
|
Toast.makeText(
|
|
- AppContext.getContext(), AppContext.getContext().resources.getString(
|
|
|
|
|
|
+ AppContext.getContext(),
|
|
|
|
+ AppContext.getContext().resources.getString(
|
|
R.string.you_are_been_forbid
|
|
R.string.you_are_been_forbid
|
|
- ), Toast.LENGTH_SHORT
|
|
|
|
|
|
+ ),
|
|
|
|
+ Toast.LENGTH_SHORT
|
|
).show()
|
|
).show()
|
|
} else {
|
|
} else {
|
|
openSendMessageDialog("@${it} ")
|
|
openSendMessageDialog("@${it} ")
|
|
@@ -233,11 +352,11 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
//飘条
|
|
//飘条
|
|
msgVm.waftFun = {
|
|
msgVm.waftFun = {
|
|
//如果是游戏飘条 要判断游戏列表是否有数据有则展示游戏飘条
|
|
//如果是游戏飘条 要判断游戏列表是否有数据有则展示游戏飘条
|
|
- if (it is GamePrize){
|
|
|
|
- if (gameList.isNotEmpty()){
|
|
|
|
|
|
+ if (it is GamePrize) {
|
|
|
|
+ if (gameList.isNotEmpty()) {
|
|
waftManager.addNewMessage(it)
|
|
waftManager.addNewMessage(it)
|
|
}
|
|
}
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
waftManager.addNewMessage(it)
|
|
waftManager.addNewMessage(it)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -255,16 +374,16 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
|
|
|
(iHeader as ComHeaderView).followFun = {
|
|
(iHeader as ComHeaderView).followFun = {
|
|
SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
- userVm.followUser(it, 0,iRoomInfo.getBroadcastId())
|
|
|
|
|
|
+ userVm.followUser(it, 0, iRoomInfo.getBroadcastId())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
(iHeader as ComHeaderView).openAudienceListDialog = {
|
|
(iHeader as ComHeaderView).openAudienceListDialog = {
|
|
- AudienceListDialog.newInstance().show(childFragmentManager,"AudienceListDialog")
|
|
|
|
|
|
+ AudienceListDialog.newInstance().show(childFragmentManager, "AudienceListDialog")
|
|
}
|
|
}
|
|
|
|
|
|
//游戏列表
|
|
//游戏列表
|
|
- roomVm.gameListModelLiveData.observe(this){
|
|
|
|
|
|
+ roomVm.gameListModelLiveData.observe(this) {
|
|
it.game?.let { gameData ->
|
|
it.game?.let { gameData ->
|
|
iFooter.setGameIcon(gameData.isNotEmpty())
|
|
iFooter.setGameIcon(gameData.isNotEmpty())
|
|
gameList.addAll(gameData)
|
|
gameList.addAll(gameData)
|
|
@@ -272,7 +391,7 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
}
|
|
}
|
|
|
|
|
|
//直播间配置
|
|
//直播间配置
|
|
- roomVm.roomConfigLiveData.observe(this){
|
|
|
|
|
|
+ roomVm.roomConfigLiveData.observe(this) {
|
|
this.roomConfig = it
|
|
this.roomConfig = it
|
|
//轮播图
|
|
//轮播图
|
|
binding.bannerView.setData(it.banners)
|
|
binding.bannerView.setData(it.banners)
|
|
@@ -283,8 +402,15 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //语音房麦位列表数据
|
|
|
|
+ roomVm.audioSeatListLiveData.observe(this) {
|
|
|
|
+ if (it != null) {
|
|
|
|
+ audioSeatAdapter.setNewData(it)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
//红包列表
|
|
//红包列表
|
|
- roomOtherVm.redEnvelopeListLiveData.observe(this){
|
|
|
|
|
|
+ roomOtherVm.redEnvelopeListLiveData.observe(this) {
|
|
binding.ivRedEnvelopeView.addRedEnvelopList(it)
|
|
binding.ivRedEnvelopeView.addRedEnvelopList(it)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -295,16 +421,16 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
|
|
|
//打开红包
|
|
//打开红包
|
|
binding.ivRedEnvelopeView.openRedEnvelope = {
|
|
binding.ivRedEnvelopeView.openRedEnvelope = {
|
|
- RedEnvelopResultDialog.newInstance(it.id,it.senderAvatar,it.senderName).apply {
|
|
|
|
|
|
+ RedEnvelopResultDialog.newInstance(it.id, it.senderAvatar, it.senderName).apply {
|
|
this.openGiftDialog = {
|
|
this.openGiftDialog = {
|
|
SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
- openGiftDialog( iRoomInfo.getAnchorName(), iRoomInfo.getAnchorId())
|
|
|
|
|
|
+ openGiftDialog(iRoomInfo.getAnchorName(), iRoomInfo.getAnchorId())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.addSenderMsgToRoomChatList = {
|
|
this.addSenderMsgToRoomChatList = {
|
|
addChatMsgToRv(it)
|
|
addChatMsgToRv(it)
|
|
}
|
|
}
|
|
- }.show(childFragmentManager,"RedEnvelopResultDialog")
|
|
|
|
|
|
+ }.show(childFragmentManager, "RedEnvelopResultDialog")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -372,10 +498,11 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
activity?.let {
|
|
activity?.let {
|
|
KeyboardUtils.unregisterSoftInputChangedListener(it.window)
|
|
KeyboardUtils.unregisterSoftInputChangedListener(it.window)
|
|
}
|
|
}
|
|
|
|
+ AudioRoomManager.removeListener(this)
|
|
SwagoRoomManager.removeListener(this)
|
|
SwagoRoomManager.removeListener(this)
|
|
}
|
|
}
|
|
|
|
|
|
- fun openSendMessageDialog(atName:String="") {
|
|
|
|
|
|
+ fun openSendMessageDialog(atName: String = "") {
|
|
dialog = SendMsgDialog.newInstance(atName)
|
|
dialog = SendMsgDialog.newInstance(atName)
|
|
dialog?.addSenderMsgToRoomChatList = {
|
|
dialog?.addSenderMsgToRoomChatList = {
|
|
addChatMsgToRv(it)
|
|
addChatMsgToRv(it)
|
|
@@ -408,6 +535,12 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
private var isFirst = true
|
|
private var isFirst = true
|
|
override fun joinedRoom(iRoomInfo: IRoomInfo) {
|
|
override fun joinedRoom(iRoomInfo: IRoomInfo) {
|
|
roomOtherVm.getRedEnvelopeList()
|
|
roomOtherVm.getRedEnvelopeList()
|
|
|
|
+ if (iRoomInfo.getRoomType() == RoomType.AUDIO.type) {
|
|
|
|
+ roomVm.getAudioList(iRoomInfo.getAnchorId(), 2)
|
|
|
|
+ binding.rvAudio.visibility = View.VISIBLE
|
|
|
|
+ }else{
|
|
|
|
+ binding.rvAudio.visibility = View.GONE
|
|
|
|
+ }
|
|
if (iRoomInfo.getRoomSystemMsg().isNotEmpty()) {
|
|
if (iRoomInfo.getRoomSystemMsg().isNotEmpty()) {
|
|
val roomSystemMsgBean = RoomSystemMsgBean()
|
|
val roomSystemMsgBean = RoomSystemMsgBean()
|
|
roomSystemMsgBean.broadcast_notice_content = iRoomInfo.getRoomSystemMsg()
|
|
roomSystemMsgBean.broadcast_notice_content = iRoomInfo.getRoomSystemMsg()
|
|
@@ -416,14 +549,14 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
}
|
|
}
|
|
|
|
|
|
//默认是否自动弹出游戏
|
|
//默认是否自动弹出游戏
|
|
- lifecycleScope.launch(Dispatchers.Main){
|
|
|
|
|
|
+ lifecycleScope.launch(Dispatchers.Main) {
|
|
delay(2000)
|
|
delay(2000)
|
|
roomConfig?.let {
|
|
roomConfig?.let {
|
|
- if (gameList.isNotEmpty()&&it.auto_show_game==1){
|
|
|
|
- if (it.is_repeat_game==1){
|
|
|
|
|
|
+ if (gameList.isNotEmpty() && it.auto_show_game == 1) {
|
|
|
|
+ if (it.is_repeat_game == 1) {
|
|
//多次弹出游戏
|
|
//多次弹出游戏
|
|
setGameDefaultData(0)
|
|
setGameDefaultData(0)
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
if (isFirst) {
|
|
if (isFirst) {
|
|
//只弹出一次
|
|
//只弹出一次
|
|
setGameDefaultData(0)
|
|
setGameDefaultData(0)
|
|
@@ -434,7 +567,7 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (SwagoRoomManager.roleType == RoleType.user){
|
|
|
|
|
|
+ if (SwagoRoomManager.roleType == RoleType.user) {
|
|
UserInfo.getUserInfo()?.let {
|
|
UserInfo.getUserInfo()?.let {
|
|
if (it.id.isNotEmpty()) {
|
|
if (it.id.isNotEmpty()) {
|
|
SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
@@ -451,9 +584,9 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- fun setGameDefaultData(index:Int) {
|
|
|
|
|
|
+ fun setGameDefaultData(index: Int) {
|
|
SwagoRoomManager.iRoomInfo?.let {
|
|
SwagoRoomManager.iRoomInfo?.let {
|
|
- if (it is UserRoomModel && gameList.size>index) {
|
|
|
|
|
|
+ if (it is UserRoomModel && gameList.size > index) {
|
|
it.roomModel?.game_api_url = gameList[index].game_api_url
|
|
it.roomModel?.game_api_url = gameList[index].game_api_url
|
|
it.roomModel?.game_down_url = gameList[index].game_down_url
|
|
it.roomModel?.game_down_url = gameList[index].game_down_url
|
|
it.roomModel?.game_type = gameList[index].game_type
|
|
it.roomModel?.game_type = gameList[index].game_type
|
|
@@ -464,9 +597,17 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ override fun changeRoom(iRoomInfo: IRoomInfo) {
|
|
|
|
+ binding?.rvAudio?.visibility = View.GONE
|
|
|
|
+ }
|
|
|
|
+
|
|
override fun leaveRoom(iRoomInfo: IRoomInfo) {
|
|
override fun leaveRoom(iRoomInfo: IRoomInfo) {
|
|
dataChatList.clear()
|
|
dataChatList.clear()
|
|
chatAdapter.notifyDataSetChanged()
|
|
chatAdapter.notifyDataSetChanged()
|
|
|
|
+ if (iRoomInfo.getRoomType() == RoomType.AUDIO.type){
|
|
|
|
+ val data = ArrayList<AudioSeatModel>()
|
|
|
|
+ audioSeatAdapter.setNewData(data)
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -605,4 +746,175 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private val audioSeatAdapter by lazy {
|
|
|
|
+ AudioSeatAdapter()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ fun setAudioRvState(isVisible: Boolean) {
|
|
|
|
+ binding.rvAudio.visibility = if (isVisible) View.VISIBLE else View.GONE
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ inner class GridItemDecoration : RecyclerView.ItemDecoration() {
|
|
|
|
+ override fun getItemOffsets(
|
|
|
|
+ outRect: Rect,
|
|
|
|
+ view: View,
|
|
|
|
+ parent: RecyclerView,
|
|
|
|
+ state: RecyclerView.State
|
|
|
|
+ ) {
|
|
|
|
+ val margin = DpPxUtil.dip2px(14f)
|
|
|
|
+ val middle = DpPxUtil.dip2px(10f)
|
|
|
|
+
|
|
|
|
+ val itemPosition = parent.getChildAdapterPosition(view)
|
|
|
|
+ when (itemPosition % 4) {
|
|
|
|
+ 0 -> {
|
|
|
|
+ outRect.set(margin, 0, middle, 0)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 1 -> {
|
|
|
|
+ outRect.set(middle, 0, middle, 0)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 2 -> {
|
|
|
|
+ outRect.set(middle, 0, middle, 0)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 3 -> {
|
|
|
|
+ outRect.set(middle, 0, margin, 0)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /***************语音房*******************/
|
|
|
|
+ override fun lockOrUnlockSeat(imAudioModel: IMAudioModel) {
|
|
|
|
+ if (audioSeatAdapter.data.size > imAudioModel.maiIndex - 1) {
|
|
|
|
+ //会偶现空指针
|
|
|
|
+ val view = audioSeatAdapter.getViewByPosition(
|
|
|
|
+ binding.rvAudio,
|
|
|
|
+ imAudioModel.maiIndex - 1,
|
|
|
|
+ R.id.ivImageView
|
|
|
|
+ )
|
|
|
|
+ if (view != null && view is SwagoImageView) {
|
|
|
|
+ if (imAudioModel.action == 1){
|
|
|
|
+ view.loadImage(R.mipmap.ic_audio_lock)
|
|
|
|
+ }else{
|
|
|
|
+ view.loadImage(R.mipmap.ic_audio_seat)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (imAudioModel.action == 1) {
|
|
|
|
+ audioSeatAdapter.data[imAudioModel.maiIndex - 1].lock_status = 2
|
|
|
|
+ } else {
|
|
|
|
+ audioSeatAdapter.data[imAudioModel.maiIndex - 1].lock_status = 1
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun openSeatMic() {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun muteSeatMic() {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onSeatMic() {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ override fun downSeatMic() {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ override fun changeJiFen(imAudioModel: IMAudioModel) {
|
|
|
|
+ if (audioSeatAdapter.data.size > imAudioModel.maiIndex - 1) {
|
|
|
|
+ audioSeatAdapter.data[imAudioModel.maiIndex-1].voice_jifen = imAudioModel.voice_jifen
|
|
|
|
+ val view = audioSeatAdapter.getViewByPosition(
|
|
|
|
+ binding.rvAudio,
|
|
|
|
+ imAudioModel.maiIndex - 1,
|
|
|
|
+ R.id.tvIntegration
|
|
|
|
+ )
|
|
|
|
+ if (view != null && view is MediumTextView) {
|
|
|
|
+ view.text = imAudioModel.voice_jifen
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ override fun clearJiFen() {
|
|
|
|
+ audioSeatAdapter.data.forEach {
|
|
|
|
+ it.voice_jifen = "0"
|
|
|
|
+ }
|
|
|
|
+ audioSeatAdapter.notifyDataSetChanged()
|
|
|
|
+ }
|
|
|
|
+ override fun updateData(audioSeatModel: AudioSeatModel) {
|
|
|
|
+ if (audioSeatAdapter.data.size > audioSeatModel.maiIndex - 1) {
|
|
|
|
+ audioSeatAdapter.data[audioSeatModel.maiIndex-1] = audioSeatModel
|
|
|
|
+ audioSeatAdapter.notifyItemChanged(audioSeatModel.maiIndex-1)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onAudioVolumeIndication(speakers: Array<out IRtcEngineEventHandler.AudioVolumeInfo>?) {
|
|
|
|
+ super.onAudioVolumeIndication(speakers)
|
|
|
|
+ speakers?.let { data ->
|
|
|
|
+ audioSeatAdapter.data.forEachIndexed { index, audioSeatModel ->
|
|
|
|
+ if (speakers.isEmpty()){
|
|
|
|
+ if (audioSeatModel.showVoice == 1){
|
|
|
|
+ audioSeatModel.showVoice = 0
|
|
|
|
+ val view = audioSeatAdapter.getViewByPosition(
|
|
|
|
+ binding.rvAudio,
|
|
|
|
+ audioSeatModel.maiIndex - 1,
|
|
|
|
+ R.id.ivAudioState
|
|
|
|
+ )
|
|
|
|
+ if (view != null) {
|
|
|
|
+ if (audioSeatModel.voice_status==1){
|
|
|
|
+ view.visibility = View.GONE
|
|
|
|
+ }else{
|
|
|
|
+ view.visibility = View.VISIBLE
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ speakers.forEach {
|
|
|
|
+ if (it.uid == 0){
|
|
|
|
+ UserInfo.getUserInfo()?.let { userInfo ->
|
|
|
|
+ if (userInfo.id == audioSeatModel.user_id && it.vad==1){
|
|
|
|
+ audioSeatModel.showVoice = 1
|
|
|
|
+ val view = audioSeatAdapter.getViewByPosition(
|
|
|
|
+ binding.rvAudio,
|
|
|
|
+ audioSeatModel.maiIndex - 1,
|
|
|
|
+ R.id.ivAudioState
|
|
|
|
+ )
|
|
|
|
+ if (view != null && view is ImageView) {
|
|
|
|
+ view.visibility = View.VISIBLE
|
|
|
|
+ view.setImageResource(R.mipmap.live_unmute)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ val view = audioSeatAdapter.getViewByPosition(
|
|
|
|
+ binding.rvAudio,
|
|
|
|
+ audioSeatModel.maiIndex - 1,
|
|
|
|
+ R.id.ivAudioState
|
|
|
|
+ )
|
|
|
|
+ if (it.uid.toString() == audioSeatModel.user_id){
|
|
|
|
+ audioSeatModel.showVoice = 1
|
|
|
|
+ if (view != null && view is ImageView) {
|
|
|
|
+ view.visibility = View.VISIBLE
|
|
|
|
+ view.setImageResource(R.mipmap.live_unmute)
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ audioSeatModel.showVoice = 0
|
|
|
|
+ if (view != null && view is ImageView ) {
|
|
|
|
+ if (audioSeatModel.voice_status==1){
|
|
|
|
+ view.visibility = View.GONE
|
|
|
|
+ }else{
|
|
|
|
+ view.visibility = View.VISIBLE
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|