فهرست منبع

feat: 领取奖励倒计时结束上报

tongmengxiao 3 ماه پیش
والد
کامیت
5f9b47715e

+ 7 - 0
baseswago/src/main/java/com/swago/baseswago/inter/RoomApi.kt

@@ -748,4 +748,11 @@ interface RoomApi {
     @FormUrlEncoded
     @POST("v1/rtc/broadcast/receive/onlineduration")
     suspend fun receiveOnlineRewards(@Field("duration")duration:String):Any
+
+    /**
+     * 倒计时结束
+     */
+    @FormUrlEncoded
+    @POST("v1/rtc/broadcast/countdown/over")
+    suspend fun countdownOverRewards(@Field("time_key")time_key:String):Any
 }

+ 12 - 0
room/src/main/java/com/swago/room/base/BaseComFragment.kt

@@ -690,6 +690,18 @@ abstract class BaseComFragment<T : FragmentBaseComBinding> : BaseXFragment<T>(),
             }.show(childFragmentManager,"GetRewardsDialog")
         }
 
+        binding.ivRewards.countdownOverFun = {
+            SwagoRoomManager.iRoomInfo?.let{
+                roomVm.countdownOverRewards(it.getTimeKey())
+            }
+
+        }
+
+        roomVm.countdownOver.observe(this){
+            binding.ivRewards.countdownOverSuccess()
+        }
+
+
         pkVm.pkState = { pkState ->
             binding.bannerView.visibility = if (pkState) View.INVISIBLE else View.VISIBLE
             binding.videoPlayBannerView.visibility = if (pkState) View.INVISIBLE else View.VISIBLE

+ 12 - 1
room/src/main/java/com/swago/room/reward/RewardView.kt

@@ -31,11 +31,13 @@ class RewardView : FrameLayout, IRoomActiveListener, RoomTimer.TimeTickListener
     private var nextCoins: Int = 0
     private var nextTime: Int = 0
     private var showChangeRoom = false
+    private var countdownOver = false //倒计时是否结束
     private var rewardsModel: OnlineRewardsModel? = null
     private var scaleXAnimator: ObjectAnimator? = null
     private var scaleYAnimator: ObjectAnimator? = null
     var openGetCoins: ((duration: String, coins: Int, nextCoins: Int, nextTime: Int) -> Unit)? =
         null
+    var countdownOverFun: (() -> Unit)?= null
 
     private
     constructor(context: Context) : this(context, null)
@@ -63,7 +65,7 @@ class RewardView : FrameLayout, IRoomActiveListener, RoomTimer.TimeTickListener
                     ).show()
                     return
                 }
-                if (scaleXAnimator?.isRunning == true){
+                if (scaleXAnimator?.isRunning == true && countdownOver){
                     openGetCoins?.invoke(duration, coins, nextCoins, nextTime)
                 }
             }
@@ -117,6 +119,7 @@ class RewardView : FrameLayout, IRoomActiveListener, RoomTimer.TimeTickListener
         if (timeL == 0L){
             if (scaleXAnimator?.isRunning == false && rewardsModel != null){
                 startGetAnimation()
+                countdownOverFun?.invoke()
             }
         } else {
             totalTime ++
@@ -151,6 +154,7 @@ class RewardView : FrameLayout, IRoomActiveListener, RoomTimer.TimeTickListener
     }
 
     fun setRewardsSuccess(success:Boolean){
+        countdownOver = false
         if (success){
             scaleXAnimator?.cancel()
             scaleYAnimator?.cancel()
@@ -248,4 +252,11 @@ class RewardView : FrameLayout, IRoomActiveListener, RoomTimer.TimeTickListener
         }
 
     }
+
+    /**
+     * 倒计时结束成功
+     * */
+    fun countdownOverSuccess(){
+        countdownOver = true
+    }
 }

+ 12 - 0
room/src/main/java/com/swago/room/vm/RoomVm.kt

@@ -558,4 +558,16 @@ class RoomVm(application: Application) : AbsRoomVm(application) {
         }
     }
 
+    /**
+     *倒计时结束
+     * */
+    val countdownOver by lazy {
+        MutableLiveData<Boolean>()
+    }
+    fun countdownOverRewards(time_key:String){
+        requestData {
+            ApiManager.roomApi.countdownOverRewards(time_key)
+            countdownOver.value = true
+        }
+    }
 }