|
@@ -5,7 +5,6 @@ import android.graphics.Rect
|
|
|
import android.text.TextUtils
|
|
|
import android.util.Log
|
|
|
import android.view.View
|
|
|
-import android.view.ViewGroup
|
|
|
import android.widget.ImageView
|
|
|
import android.widget.TextView
|
|
|
import android.widget.Toast
|
|
@@ -26,7 +25,6 @@ import com.liulishuo.okdownload.core.cause.ResumeFailedCause
|
|
|
import com.permissionx.guolindev.PermissionX
|
|
|
import com.swago.baseswago.PersonDataDFragment
|
|
|
import com.swago.baseswago.UserVm
|
|
|
-import com.swago.baseswago.agora.AgoraManager
|
|
|
import com.swago.baseswago.baseroom.*
|
|
|
import com.swago.baseswago.constant.ARouteConstant
|
|
|
import com.swago.baseswago.constant.UrlConstant
|
|
@@ -60,8 +58,6 @@ import com.swago.room.databinding.FragmentBaseComBinding
|
|
|
import com.swago.room.dialog.AudienceListDialog
|
|
|
import com.swago.room.dialog.FanClubAnchorDialog
|
|
|
import com.swago.room.dialog.FanClubForUserDialog
|
|
|
-import com.swago.room.dialog.FooterMoreDialog
|
|
|
-import com.swago.room.dialog.HouseGoLiveDialog
|
|
|
import com.swago.room.dialog.JoinFanClubDialog
|
|
|
import com.swago.room.dialog.LevelUpDialog
|
|
|
import com.swago.room.dialog.MessageListDialog
|
|
@@ -79,6 +75,7 @@ import com.swago.room.hongbao.RedEnvelopeDialog
|
|
|
import com.swago.room.inter.IFooter
|
|
|
import com.swago.room.inter.IHeader
|
|
|
import com.swago.room.lianmai.LianMaiVm
|
|
|
+import com.swago.room.manager.JoinAnimalManager
|
|
|
import com.swago.room.piaotiao.WaftManager
|
|
|
import com.swago.room.pk.IPKListener
|
|
|
import com.swago.room.pk.PKStateManager
|
|
@@ -91,9 +88,12 @@ import com.swago.room.widget.ComHeaderView
|
|
|
import com.swago.room.wishgift.SetWishGiftsDialog
|
|
|
import com.swago.room.wishgift.WishGiftOnUserDialog
|
|
|
import io.agora.rtc.IRtcEngineEventHandler
|
|
|
+import kotlinx.coroutines.CoroutineScope
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
import kotlinx.coroutines.GlobalScope
|
|
|
+import kotlinx.coroutines.Job
|
|
|
import kotlinx.coroutines.delay
|
|
|
+import kotlinx.coroutines.isActive
|
|
|
import kotlinx.coroutines.launch
|
|
|
import java.io.File
|
|
|
import java.lang.Exception
|
|
@@ -140,10 +140,10 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
abstract val iFooter: IFooter
|
|
|
|
|
|
var roomConfig: RoomConfig? = null
|
|
|
+ val job = Job()
|
|
|
+ val coroutineScope = CoroutineScope(Dispatchers.Main + job)
|
|
|
|
|
|
- var dialog: SendMsgDialog? = null
|
|
|
var gameDialog: GamePlayDialog? = null
|
|
|
- var msgListDialog: MessageListDialog? = null
|
|
|
|
|
|
val gameList by lazy {
|
|
|
ArrayList<GameModel>()
|
|
@@ -157,6 +157,10 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
SvgPlayerManager()
|
|
|
}
|
|
|
|
|
|
+ private val joinAnimalManager by lazy {
|
|
|
+ JoinAnimalManager()
|
|
|
+ }
|
|
|
+
|
|
|
private val waftManager by lazy {
|
|
|
WaftManager()
|
|
|
}
|
|
@@ -221,6 +225,7 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
chatAdapter.setNewData(dataChatList)
|
|
|
context?.let {
|
|
|
svgPlayerManager.init(it, binding.xSvgaPlayer, binding.svgDanDaoView)
|
|
|
+ joinAnimalManager.init(it, binding.xSvgaPlayer)
|
|
|
}
|
|
|
|
|
|
activity?.let {
|
|
@@ -237,6 +242,21 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
roomOtherVm.userDianZan()
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ coroutineScope.launch {
|
|
|
+ while (isActive){
|
|
|
+ SwagoRoomManager.iRoomInfo?.let {
|
|
|
+ if (it.getRoomType() == RoomType.AUDIO.type){
|
|
|
+ roomVm.getAudioList(it.getAnchorId(), 2)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (SwagoRoomManager.roleType == RoleType.anchor){
|
|
|
+ roomVm.loadRoomData()
|
|
|
+ }
|
|
|
+ delay(10000)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private fun initAudioRvList() {
|
|
@@ -452,9 +472,26 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
(iHeader as ComHeaderView).openAudienceListDialog = {
|
|
|
AudienceListDialog.newInstance().apply {
|
|
|
this.showUserInfo = {userid ->
|
|
|
- PersonDataDFragment.newInstance(userid,
|
|
|
- isAnchor = false,
|
|
|
- inRoom = true).show(this@BaseComFragment.childFragmentManager,"PersonDataDFragment")
|
|
|
+ PersonDataDFragment.newInstance(userid,
|
|
|
+ isAnchor = false,
|
|
|
+ inRoom = true).apply {
|
|
|
+ this.openGiftIconDialog = { nickName, userId ,nickIcon->
|
|
|
+ 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(this@BaseComFragment.childFragmentManager,"PersonDataDFragment")
|
|
|
}
|
|
|
}.show(childFragmentManager, "AudienceListDialog")
|
|
|
}
|
|
@@ -484,16 +521,16 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
}
|
|
|
//推荐游戏列表
|
|
|
roomVm.recommendGameListModelLiveData.observe(this){
|
|
|
- binding.playBannerView.setData(it.list)
|
|
|
- binding.playBannerView.jumpToWebFun = { game ->
|
|
|
- setRecommendGame(game)
|
|
|
+ binding.playBannerView.setData(it.list)
|
|
|
+ binding.playBannerView.jumpToWebFun = { game ->
|
|
|
+ setRecommendGame(game)
|
|
|
|
|
|
- }
|
|
|
- binding.videoPlayBannerView.setData(it.list)
|
|
|
- binding.videoPlayBannerView.jumpToWebFun = { game ->
|
|
|
- setRecommendGame(game)
|
|
|
+ }
|
|
|
+ binding.videoPlayBannerView.setData(it.list)
|
|
|
+ binding.videoPlayBannerView.jumpToWebFun = { game ->
|
|
|
+ setRecommendGame(game)
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//直播间配置
|
|
@@ -527,8 +564,11 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
//语音房麦位列表数据
|
|
|
roomVm.audioSeatListLiveData.observe(this) {
|
|
|
if (it != null) {
|
|
|
- audioSeatAdapter.setNewData(it)
|
|
|
- initMaiPosition()
|
|
|
+ if (audioSeatAdapter.data != it){
|
|
|
+ audioSeatAdapter.setNewData(it)
|
|
|
+ initMaiPosition()
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -600,6 +640,14 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
userVm.getUserInfo()
|
|
|
}
|
|
|
|
|
|
+ msgVm.joinRoomFun = {
|
|
|
+ //svg播放
|
|
|
+ if (!it.androidJoinSpecial.isNullOrEmpty()){
|
|
|
+ joinAnimalManager.addSvgUrl(it)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
userVm.userInfoLiveData.observe(this) {
|
|
|
UserInfo.setUserInfo(it)
|
|
|
SpUtil.putString("user_info", Gson().toJson(it))
|
|
@@ -717,9 +765,8 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
|
|
|
override fun onDestroyView() {
|
|
|
super.onDestroyView()
|
|
|
- dialog = null
|
|
|
gameDialog = null
|
|
|
- msgListDialog = null
|
|
|
+ job.cancel()
|
|
|
PKStateManager.removePKListener(this)
|
|
|
activity?.let {
|
|
|
KeyboardUtils.unregisterSoftInputChangedListener(it.window)
|
|
@@ -729,11 +776,11 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
}
|
|
|
|
|
|
fun openSendMessageDialog(atName: String = "") {
|
|
|
- dialog = SendMsgDialog.newInstance(atName)
|
|
|
- dialog?.addSenderMsgToRoomChatList = {
|
|
|
- addChatMsgToRv(it)
|
|
|
- }
|
|
|
- dialog?.show(childFragmentManager, "SendMsgDialog")
|
|
|
+ SendMsgDialog.newInstance(atName).apply {
|
|
|
+ this.addSenderMsgToRoomChatList = {
|
|
|
+ addChatMsgToRv(it)
|
|
|
+ }
|
|
|
+ }.show(childFragmentManager, "SendMsgDialog")
|
|
|
}
|
|
|
|
|
|
fun openMoreDialog(){
|
|
@@ -748,8 +795,7 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
}
|
|
|
|
|
|
fun openMessageListDialog() {
|
|
|
- msgListDialog = MessageListDialog.newInstance()
|
|
|
- msgListDialog?.show(childFragmentManager, "MessageListDialog")
|
|
|
+ MessageListDialog.newInstance().show(childFragmentManager, "MessageListDialog")
|
|
|
}
|
|
|
|
|
|
private var gameIsOpen = false
|
|
@@ -763,9 +809,9 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
)
|
|
|
if (download) {
|
|
|
gameDialog =
|
|
|
- GamePlayDialog.newInstance("file://" + UrlConstant.appGameRootPath + File.separator + it.getGameType() + File.separator + "index.html",it.getIsFullGame())
|
|
|
+ GamePlayDialog.newInstance("file://" + UrlConstant.appGameRootPath + File.separator + it.getGameType() + File.separator + "index.html",it.getIsFullGame(),it.getGameType().toString())
|
|
|
} else {
|
|
|
- gameDialog = GamePlayDialog.newInstance(it.getGameUrl(),it.getIsFullGame())
|
|
|
+ gameDialog = GamePlayDialog.newInstance(it.getGameUrl(),it.getIsFullGame(),it.getGameType().toString())
|
|
|
}
|
|
|
gameDialog?.dialogDisFun = {
|
|
|
gameIsOpen = false
|
|
@@ -880,9 +926,7 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
|
|
|
override fun leaveRoom(iRoomInfo: IRoomInfo) {
|
|
|
dataChatList.clear()
|
|
|
- dialog = null
|
|
|
gameDialog = null
|
|
|
- msgListDialog = null
|
|
|
chatAdapter.notifyDataSetChanged()
|
|
|
if (iRoomInfo.getRoomType() == RoomType.AUDIO.type){
|
|
|
val data = ArrayList<AudioSeatModel>()
|
|
@@ -893,6 +937,7 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
|
|
|
override fun closeRoomed() {
|
|
|
binding.likeLayout.clear()
|
|
|
+ gameDialog = null
|
|
|
RoomTimer.timeTickList.remove(this)
|
|
|
}
|
|
|
|