|
@@ -25,6 +25,7 @@ import com.swago.baseswago.fragment.BaseXFragment
|
|
|
import com.swago.baseswago.im.IRoomChat
|
|
|
import com.swago.baseswago.model.im.RoomSystemMsgBean
|
|
|
import com.swago.baseswago.model.im.UserJoinRoomBean
|
|
|
+import com.swago.baseswago.model.live.RoomUserModel
|
|
|
import com.swago.baseswago.model.live.gift.GiftModel
|
|
|
import com.swago.baseswago.util.*
|
|
|
import com.swago.room.R
|
|
@@ -59,6 +60,7 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
RoomTimer.TimeTickListener {
|
|
|
|
|
|
val giftVm by activityViewModels<GiftVm>()
|
|
|
+
|
|
|
//热门礼物列表
|
|
|
val hotList = ArrayList<GiftModel>()
|
|
|
|
|
@@ -71,6 +73,9 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
val roomVm by activityViewModels<RoomVm>()
|
|
|
val msgVm by activityViewModels<MsgVm>()
|
|
|
|
|
|
+ //直播间观众列表
|
|
|
+ var roomUserList = CopyOnWriteArrayList<RoomUserModel.ListBean>()
|
|
|
+
|
|
|
abstract val iHeader: IHeader
|
|
|
abstract val iFooter: IFooter
|
|
|
|
|
@@ -125,7 +130,7 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
binding.rv.adapter = chatAdapter
|
|
|
chatAdapter.setNewData(dataChatList)
|
|
|
context?.let {
|
|
|
- svgPlayerManager.init(it, binding.xSvgaPlayer,binding.svgDanDaoView)
|
|
|
+ svgPlayerManager.init(it, binding.xSvgaPlayer, binding.svgDanDaoView)
|
|
|
}
|
|
|
|
|
|
activity?.let {
|
|
@@ -149,29 +154,52 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
}
|
|
|
|
|
|
|
|
|
- abstract fun updateUserJoinRoom(userJoinRoomBean: UserJoinRoomBean)
|
|
|
+ private fun updateUserJoinRoom(userJoinRoomBean: UserJoinRoomBean){
|
|
|
+ val data = RoomUserModel.ListBean()
|
|
|
+ data.user_account = userJoinRoomBean.senderCode
|
|
|
+ data.user_head_img_url = userJoinRoomBean.userAvatar
|
|
|
+ data.user_id = userJoinRoomBean.senderId
|
|
|
+ data.user_name = userJoinRoomBean.senderName
|
|
|
+ roomUserList.add(0,data)
|
|
|
+ }
|
|
|
|
|
|
override fun initLiveData() {
|
|
|
- msgVm.updateUserRoom = {
|
|
|
- updateUserJoinRoom(it)
|
|
|
+ msgVm.updateUserRoom = { userJoinRoomBean, isJoinOrExit ->
|
|
|
+ var isInit = false
|
|
|
+ roomUserList.forEach {
|
|
|
+ if (it!=null&&it.user_account==userJoinRoomBean.senderCode){
|
|
|
+ isInit = true
|
|
|
+ if (!isJoinOrExit){
|
|
|
+ roomUserList.remove(it)
|
|
|
+ }
|
|
|
+ return@forEach
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isJoinOrExit){
|
|
|
+ if (!isInit){
|
|
|
+ updateUserJoinRoom(userJoinRoomBean)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ iHeader.updateRoomUser(roomUserList)
|
|
|
}
|
|
|
|
|
|
chatAdapter.showUserInfoDialog = {
|
|
|
- var isAnchor = false
|
|
|
+ var isAnchor = false
|
|
|
SwagoRoomManager.iRoomInfo?.let { iRoomInfo ->
|
|
|
isAnchor = iRoomInfo.getAnchorId() == it.getSenderId()
|
|
|
}
|
|
|
- PersonDataDFragment.newInstance(it.getSenderId(),isAnchor = isAnchor,inRoom = true).apply {
|
|
|
- this.openGiftDialog = {nickName, userId ->
|
|
|
- GiftDialog.newInstance(
|
|
|
- nickName,
|
|
|
- userId,
|
|
|
- hotList,
|
|
|
- luxuryList,
|
|
|
- luckyData
|
|
|
- ).show(childFragmentManager, "GiftDialog")
|
|
|
- }
|
|
|
- }.show(childFragmentManager, "PersonDataDFragment")
|
|
|
+ PersonDataDFragment.newInstance(it.getSenderId(), isAnchor = isAnchor, inRoom = true)
|
|
|
+ .apply {
|
|
|
+ this.openGiftDialog = { nickName, userId ->
|
|
|
+ GiftDialog.newInstance(
|
|
|
+ nickName,
|
|
|
+ userId,
|
|
|
+ hotList,
|
|
|
+ luxuryList,
|
|
|
+ luckyData
|
|
|
+ ).show(childFragmentManager, "GiftDialog")
|
|
|
+ }
|
|
|
+ }.show(childFragmentManager, "PersonDataDFragment")
|
|
|
}
|
|
|
|
|
|
msgVm.newChatMsgFun = {
|
|
@@ -222,9 +250,7 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
dataChatList.add(it)
|
|
|
}
|
|
|
chatAdapter.notifyDataSetChanged()
|
|
|
- binding.rv.post {
|
|
|
- binding.rv.scrollToPosition(dataChatList.size - 1)
|
|
|
- }
|
|
|
+ binding.rv.smoothScrollToPosition(dataChatList.size-1)
|
|
|
}
|
|
|
|
|
|
|
|
@@ -286,10 +312,15 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
fun openGameDialog() {
|
|
|
|
|
|
SwagoRoomManager.iRoomInfo?.let {
|
|
|
- val download = checkGameVersion(it.getGameType().toString(),it.getGameDownLoadUrl(),it.getGameVersion().toString())
|
|
|
- if (download){
|
|
|
- gameDialog = GamePlayDialog.newInstance("file://" + UrlConstant.appGameRootPath + File.separator + it.getGameType() + File.separator + "index.html")
|
|
|
- }else{
|
|
|
+ val download = checkGameVersion(
|
|
|
+ it.getGameType().toString(),
|
|
|
+ it.getGameDownLoadUrl(),
|
|
|
+ it.getGameVersion().toString()
|
|
|
+ )
|
|
|
+ if (download) {
|
|
|
+ gameDialog =
|
|
|
+ GamePlayDialog.newInstance("file://" + UrlConstant.appGameRootPath + File.separator + it.getGameType() + File.separator + "index.html")
|
|
|
+ } else {
|
|
|
gameDialog = GamePlayDialog.newInstance(it.getGameUrl())
|
|
|
}
|
|
|
gameDialog?.show(childFragmentManager, "GamePlayDialog")
|
|
@@ -297,7 +328,7 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
}
|
|
|
|
|
|
override fun joinedRoom(iRoomInfo: IRoomInfo) {
|
|
|
- if (iRoomInfo.getRoomSystemMsg().isNotEmpty()){
|
|
|
+ if (iRoomInfo.getRoomSystemMsg().isNotEmpty()) {
|
|
|
val roomSystemMsgBean = RoomSystemMsgBean()
|
|
|
roomSystemMsgBean.broadcast_notice_content = iRoomInfo.getRoomSystemMsg()
|
|
|
dataChatList.add(roomSystemMsgBean)
|
|
@@ -307,6 +338,12 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
|
|
|
}
|
|
|
|
|
|
+ override fun leaveRoom(iRoomInfo: IRoomInfo) {
|
|
|
+ dataChatList.clear()
|
|
|
+ chatAdapter.notifyDataSetChanged()
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
override fun closeRoomed() {
|
|
|
RoomTimer.timeTickList.remove(this)
|
|
|
}
|
|
@@ -335,7 +372,7 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
}
|
|
|
|
|
|
override fun onTimeCount(time: Int) {
|
|
|
- if (time % 30 == 0) {
|
|
|
+ if (time!=0 && time % 30 == 0) {
|
|
|
SwagoRoomManager.iRoomInfo?.let {
|
|
|
roomVm.loadRoomData(it.getRoomId())
|
|
|
}
|
|
@@ -344,7 +381,11 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
}
|
|
|
|
|
|
|
|
|
- private fun checkGameVersion(gameId: String, gamePackageUrl: String, gameVersionCode: String): Boolean {
|
|
|
+ private fun checkGameVersion(
|
|
|
+ gameId: String,
|
|
|
+ gamePackageUrl: String,
|
|
|
+ gameVersionCode: String
|
|
|
+ ): Boolean {
|
|
|
if (gamePackageUrl.isEmpty() || gameVersionCode.isEmpty()) {
|
|
|
return false
|
|
|
}
|
|
@@ -384,26 +425,29 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
}
|
|
|
file.mkdirs()
|
|
|
|
|
|
- val task = DownloadTask.Builder(gamePackageUrl,path,name).build()
|
|
|
- task.enqueue(object:DownloadListener{
|
|
|
+ val task = DownloadTask.Builder(gamePackageUrl, path, name).build()
|
|
|
+ task.enqueue(object : DownloadListener {
|
|
|
override fun taskStart(task: DownloadTask) {}
|
|
|
|
|
|
override fun connectTrialStart(
|
|
|
task: DownloadTask,
|
|
|
requestHeaderFields: MutableMap<String, MutableList<String>>
|
|
|
- ) {}
|
|
|
+ ) {
|
|
|
+ }
|
|
|
|
|
|
override fun connectTrialEnd(
|
|
|
task: DownloadTask,
|
|
|
responseCode: Int,
|
|
|
responseHeaderFields: MutableMap<String, MutableList<String>>
|
|
|
- ) {}
|
|
|
+ ) {
|
|
|
+ }
|
|
|
|
|
|
override fun downloadFromBeginning(
|
|
|
task: DownloadTask,
|
|
|
info: BreakpointInfo,
|
|
|
cause: ResumeFailedCause
|
|
|
- ) {}
|
|
|
+ ) {
|
|
|
+ }
|
|
|
|
|
|
override fun downloadFromBreakpoint(task: DownloadTask, info: BreakpointInfo) {}
|
|
|
|
|
@@ -411,14 +455,16 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
task: DownloadTask,
|
|
|
blockIndex: Int,
|
|
|
requestHeaderFields: MutableMap<String, MutableList<String>>
|
|
|
- ) {}
|
|
|
+ ) {
|
|
|
+ }
|
|
|
|
|
|
override fun connectEnd(
|
|
|
task: DownloadTask,
|
|
|
blockIndex: Int,
|
|
|
responseCode: Int,
|
|
|
responseHeaderFields: MutableMap<String, MutableList<String>>
|
|
|
- ) {}
|
|
|
+ ) {
|
|
|
+ }
|
|
|
|
|
|
override fun fetchStart(task: DownloadTask, blockIndex: Int, contentLength: Long) {}
|
|
|
|
|
@@ -429,7 +475,7 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
|
|
|
override fun taskEnd(task: DownloadTask, cause: EndCause, realCause: Exception?) {
|
|
|
GlobalScope.launch(Dispatchers.IO) {
|
|
|
val packagePath = path + File.separator + name
|
|
|
- FileUtil.upZipFile(packagePath,path + File.separator)
|
|
|
+ FileUtil.upZipFile(packagePath, path + File.separator)
|
|
|
SpUtil.putInt(gameId, gameVersionCode.toInt())
|
|
|
}
|
|
|
}
|