|
@@ -0,0 +1,82 @@
|
|
|
|
+package com.swago.room.manager
|
|
|
|
+
|
|
|
|
+import android.content.Context
|
|
|
|
+import com.opensource.svgaplayer.SVGAParser
|
|
|
|
+import com.swago.baseswago.baseroom.IRoomActiveListener
|
|
|
|
+import com.swago.baseswago.baseroom.IRoomInfo
|
|
|
|
+import com.swago.baseswago.baseroom.SwagoRoomManager
|
|
|
|
+import com.swago.baseswago.model.im.UserJoinRoomBean
|
|
|
|
+import com.swago.baseswago.model.live.gift.IMGiftModel
|
|
|
|
+import com.swago.baseswago.util.LogUtil
|
|
|
|
+import com.swago.room.gift.control.XSvgPlayer
|
|
|
|
+import java.util.*
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ *@date 2021/12/11 16:42
|
|
|
|
+ *description:
|
|
|
|
+ */
|
|
|
|
+class JoinAnimalManager : IRoomActiveListener {
|
|
|
|
+
|
|
|
|
+ private val svgListQueue = LinkedList<UserJoinRoomBean>()
|
|
|
|
+ private var xSvgPlayer: XSvgPlayer? = null
|
|
|
|
+
|
|
|
|
+ fun init(context: Context, xSvgPlayer: XSvgPlayer) {
|
|
|
|
+ SVGAParser.shareParser().init(context)
|
|
|
|
+ this.xSvgPlayer = xSvgPlayer
|
|
|
|
+ SwagoRoomManager.addListener(this)
|
|
|
|
+
|
|
|
|
+ this.xSvgPlayer?.nextSvgPlay = {
|
|
|
|
+ svgListQueue.poll()
|
|
|
|
+ val uerJoinRoomBean = svgListQueue.peek()
|
|
|
|
+ LogUtil.d("SvgPlayerManager","${svgListQueue.size}")
|
|
|
|
+ if (uerJoinRoomBean==null){
|
|
|
|
+ LogUtil.d("SvgPlayerManager","clear svgListQueue")
|
|
|
|
+ svgListQueue.clear()
|
|
|
|
+ }else{
|
|
|
|
+ if (this.xSvgPlayer==null){
|
|
|
|
+ svgListQueue.clear()
|
|
|
|
+ LogUtil.d("SvgPlayerManager","xSvgPlayer 为空")
|
|
|
|
+ }else{
|
|
|
|
+ this.xSvgPlayer!!.playJoinRoomSvga(uerJoinRoomBean)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun changeRoom(iRoomInfo: IRoomInfo) {
|
|
|
|
+ svgListQueue.clear()
|
|
|
|
+ xSvgPlayer?.clear()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun leaveRoom(iRoomInfo: IRoomInfo) {
|
|
|
|
+ svgListQueue.clear()
|
|
|
|
+ xSvgPlayer?.clear()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun joinedRoom(iRoomInfo: IRoomInfo) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun endRoom(iRoomInfo: IRoomInfo?) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun closeRoomed() {
|
|
|
|
+ svgListQueue.clear()
|
|
|
|
+ xSvgPlayer?.clear()
|
|
|
|
+ SwagoRoomManager.removeListener(this)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ fun addSvgUrl(userJoinRoomBean: UserJoinRoomBean?) {
|
|
|
|
+ userJoinRoomBean?.let {
|
|
|
|
+ if (svgListQueue.isEmpty()) {
|
|
|
|
+ LogUtil.d("SvgPlayerManager","数据源没有数据 新增一条")
|
|
|
|
+ svgListQueue.add(it)
|
|
|
|
+ this.xSvgPlayer?.playJoinRoomSvga(it)
|
|
|
|
+ } else {
|
|
|
|
+ svgListQueue.add(it)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|