|
@@ -0,0 +1,72 @@
|
|
|
+package com.swago.room.widget
|
|
|
+
|
|
|
+import android.content.Context
|
|
|
+import android.util.AttributeSet
|
|
|
+import android.view.LayoutInflater
|
|
|
+import android.view.View
|
|
|
+import android.widget.FrameLayout
|
|
|
+import androidx.lifecycle.findViewTreeLifecycleOwner
|
|
|
+import com.swago.baseswago.baseroom.IRoomActiveListener
|
|
|
+import com.swago.baseswago.baseroom.IRoomInfo
|
|
|
+import com.swago.baseswago.baseroom.SwagoRoomManager
|
|
|
+import com.swago.baseswago.model.live.RoomConfig
|
|
|
+import com.swago.baseswago.model.live.game.RecommendGameModel
|
|
|
+import com.swago.room.adapter.BannerViewAdapter
|
|
|
+import com.swago.room.adapter.RecommendBannerViewAdapter
|
|
|
+import com.swago.room.databinding.ViewBannerBinding
|
|
|
+import com.youth.banner.indicator.CircleIndicator
|
|
|
+
|
|
|
+class RecommendBannerView : FrameLayout,IRoomActiveListener {
|
|
|
+
|
|
|
+ private val mData by lazy {
|
|
|
+ ArrayList<RecommendGameModel>()
|
|
|
+ }
|
|
|
+
|
|
|
+ var jumpToWebFun:((RecommendGameModel)->Unit)? = null
|
|
|
+
|
|
|
+ private val bannerViewAdapter = RecommendBannerViewAdapter(mData)
|
|
|
+
|
|
|
+ private var binding:ViewBannerBinding? = null
|
|
|
+
|
|
|
+ constructor(context: Context) : super(context)
|
|
|
+ constructor(context: Context, mAttributeSet: AttributeSet?) : super(context, mAttributeSet){
|
|
|
+ initView(context)
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun initView(context: Context) {
|
|
|
+ SwagoRoomManager.addListener(this)
|
|
|
+ binding = ViewBannerBinding.inflate(LayoutInflater.from(context),this,true)
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun changeRoom(iRoomInfo: IRoomInfo) {
|
|
|
+ visibility = View.GONE
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun leaveRoom(iRoomInfo: IRoomInfo) {
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun joinedRoom(iRoomInfo: IRoomInfo) {
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun endRoom(iRoomInfo: IRoomInfo?) {
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun closeRoomed() {
|
|
|
+ SwagoRoomManager.removeListener(this)
|
|
|
+ }
|
|
|
+
|
|
|
+ fun setData(data:ArrayList<RecommendGameModel>){
|
|
|
+ binding?.let {
|
|
|
+ mData.addAll(data)
|
|
|
+ it.banner.setAdapter(bannerViewAdapter)
|
|
|
+ .setIndicator(CircleIndicator(context))
|
|
|
+ .addBannerLifecycleObserver(findViewTreeLifecycleOwner())
|
|
|
+ .setOnBannerListener { data, _ ->
|
|
|
+ val bannerData = data as RecommendGameModel
|
|
|
+ jumpToWebFun?.invoke(bannerData)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|