|
@@ -10,6 +10,7 @@ import com.swago.baseswago.baseroom.IRoomActiveListener
|
|
import com.swago.baseswago.baseroom.IRoomInfo
|
|
import com.swago.baseswago.baseroom.IRoomInfo
|
|
import com.swago.baseswago.baseroom.SwagoRoomManager
|
|
import com.swago.baseswago.baseroom.SwagoRoomManager
|
|
import com.swago.baseswago.model.live.audio.AudioSendGiftModel
|
|
import com.swago.baseswago.model.live.audio.AudioSendGiftModel
|
|
|
|
+import com.swago.baseswago.util.DpPxUtil
|
|
import com.swago.room.R
|
|
import com.swago.room.R
|
|
import com.swago.room.databinding.ViewAudioContainGiftBinding
|
|
import com.swago.room.databinding.ViewAudioContainGiftBinding
|
|
|
|
|
|
@@ -73,42 +74,42 @@ class AudioContainGiftView : ConstraintLayout, IRoomActiveListener {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- audioSendGiftModel.receivers.forEachIndexed {position, positionBean ->
|
|
|
|
- //创建从屏幕中心弹出的动画view
|
|
|
|
- allAudioGiftViewList[position].setViewData(audioSendGiftModel.giftIcon, audioSendGiftModel.giftNum)
|
|
|
|
- clMultiAudio.addView(allAudioGiftViewList[position])
|
|
|
|
|
|
+ //如果receivers的size为0 那么就是送给用户的
|
|
|
|
+ if (audioSendGiftModel.receivers.isEmpty()){
|
|
|
|
+ allAudioGiftViewList[0].setViewData(audioSendGiftModel.giftIcon, audioSendGiftModel.giftNum)
|
|
|
|
+ clMultiAudio.addView(allAudioGiftViewList[0])
|
|
|
|
|
|
//从中间缩放出来
|
|
//从中间缩放出来
|
|
- val alphaAnim = ObjectAnimator.ofFloat(allAudioGiftViewList[position], "alpha", 1f, 1f)
|
|
|
|
- val scaleX = ObjectAnimator.ofFloat(allAudioGiftViewList[position], "scaleX", 0f, 1f)
|
|
|
|
- val scaleY = ObjectAnimator.ofFloat(allAudioGiftViewList[position], "scaleY", 0f, 1f)
|
|
|
|
|
|
+ val alphaAnim = ObjectAnimator.ofFloat(allAudioGiftViewList[0], "alpha", 1f, 1f)
|
|
|
|
+ val scaleX = ObjectAnimator.ofFloat(allAudioGiftViewList[0], "scaleX", 0f, 1f)
|
|
|
|
+ val scaleY = ObjectAnimator.ofFloat(allAudioGiftViewList[0], "scaleY", 0f, 1f)
|
|
val scaleFromCenter = AnimatorSet()
|
|
val scaleFromCenter = AnimatorSet()
|
|
scaleFromCenter.playTogether(scaleX,scaleY,alphaAnim)
|
|
scaleFromCenter.playTogether(scaleX,scaleY,alphaAnim)
|
|
- scaleFromCenter.setTarget(allAudioGiftViewList[position])
|
|
|
|
|
|
+ scaleFromCenter.setTarget(allAudioGiftViewList[0])
|
|
scaleX.duration = 300
|
|
scaleX.duration = 300
|
|
scaleY.duration = 300
|
|
scaleY.duration = 300
|
|
|
|
|
|
//从中间向其他地方位移缩放
|
|
//从中间向其他地方位移缩放
|
|
- val moveX = ObjectAnimator.ofFloat(allAudioGiftViewList[position],"translationX", positionBean.dx)
|
|
|
|
- val moveY = ObjectAnimator.ofFloat(allAudioGiftViewList[position],"translationY", positionBean.dy)
|
|
|
|
- val scaleXX = ObjectAnimator.ofFloat(allAudioGiftViewList[position],"scaleX",1f,0.2f)
|
|
|
|
- val scaleYY = ObjectAnimator.ofFloat(allAudioGiftViewList[position],"scaleY",1f,0.2f)
|
|
|
|
|
|
+ val moveX = ObjectAnimator.ofFloat(allAudioGiftViewList[0],"translationX", DpPxUtil.getScreenWidth()/2f - DpPxUtil.dip2px(100f))
|
|
|
|
+ val moveY = ObjectAnimator.ofFloat(allAudioGiftViewList[0],"translationY", -DpPxUtil.getScreenHeight()/2f + DpPxUtil.dip2px(40f))
|
|
|
|
+ val scaleXX = ObjectAnimator.ofFloat(allAudioGiftViewList[0],"scaleX",1f,0.2f)
|
|
|
|
+ val scaleYY = ObjectAnimator.ofFloat(allAudioGiftViewList[0],"scaleY",1f,0.2f)
|
|
val moveAndScale = AnimatorSet()
|
|
val moveAndScale = AnimatorSet()
|
|
moveAndScale.playTogether(moveX,moveY,scaleXX,scaleYY)
|
|
moveAndScale.playTogether(moveX,moveY,scaleXX,scaleYY)
|
|
moveAndScale.duration = 700
|
|
moveAndScale.duration = 700
|
|
|
|
|
|
- val alphaAnimX = ObjectAnimator.ofFloat(allAudioGiftViewList[position], "alpha", 1f, 0f)
|
|
|
|
|
|
+ val alphaAnimX = ObjectAnimator.ofFloat(allAudioGiftViewList[0], "alpha", 1f, 0f)
|
|
alphaAnimX.duration = 200
|
|
alphaAnimX.duration = 200
|
|
|
|
|
|
val moveAnimatorPlus = AnimatorSet()
|
|
val moveAnimatorPlus = AnimatorSet()
|
|
moveAnimatorPlus.play(alphaAnimX).after(moveAndScale)
|
|
moveAnimatorPlus.play(alphaAnimX).after(moveAndScale)
|
|
|
|
|
|
//在头像上方消失
|
|
//在头像上方消失
|
|
- val alphaAnimEnd = ObjectAnimator.ofFloat(allAudioGiftViewList[position],"alpha",1f,0f)
|
|
|
|
|
|
+ val alphaAnimEnd = ObjectAnimator.ofFloat(allAudioGiftViewList[0],"alpha",1f,0f)
|
|
alphaAnimEnd.duration = 800
|
|
alphaAnimEnd.duration = 800
|
|
//向头像上方移动
|
|
//向头像上方移动
|
|
- val upYAnima = ObjectAnimator.ofFloat(allAudioGiftViewList[position],"translationY",positionBean.offSetY)
|
|
|
|
- val alphaAnimUp = ObjectAnimator.ofFloat(allAudioGiftViewList[position], "alpha", 0f, 1f)
|
|
|
|
|
|
+ val upYAnima = ObjectAnimator.ofFloat(allAudioGiftViewList[0],"translationY",-DpPxUtil.getScreenHeight()/2f + DpPxUtil.dip2px(40f))
|
|
|
|
+ val alphaAnimUp = ObjectAnimator.ofFloat(allAudioGiftViewList[0], "alpha", 1f, 1f)
|
|
val upAnimatorSet = AnimatorSet()
|
|
val upAnimatorSet = AnimatorSet()
|
|
upAnimatorSet.playTogether(upYAnima,alphaAnimUp)
|
|
upAnimatorSet.playTogether(upYAnima,alphaAnimUp)
|
|
upAnimatorSet.duration = 200
|
|
upAnimatorSet.duration = 200
|
|
@@ -122,7 +123,7 @@ class AudioContainGiftView : ConstraintLayout, IRoomActiveListener {
|
|
animatorSet.play(upAnimatorSet)
|
|
animatorSet.play(upAnimatorSet)
|
|
.after(animationScaleAndMoveSet)
|
|
.after(animationScaleAndMoveSet)
|
|
.before(alphaAnimEnd)
|
|
.before(alphaAnimEnd)
|
|
- animatorSet.setTarget(allAudioGiftViewList[position])
|
|
|
|
|
|
+ animatorSet.setTarget(allAudioGiftViewList[0])
|
|
allAnimationSetList.add(animatorSet)
|
|
allAnimationSetList.add(animatorSet)
|
|
|
|
|
|
animatorSet.addListener(object: Animator.AnimatorListener{
|
|
animatorSet.addListener(object: Animator.AnimatorListener{
|
|
@@ -141,6 +142,76 @@ class AudioContainGiftView : ConstraintLayout, IRoomActiveListener {
|
|
override fun onAnimationRepeat(animation: Animator?) {}
|
|
override fun onAnimationRepeat(animation: Animator?) {}
|
|
|
|
|
|
})
|
|
})
|
|
|
|
+ }else{
|
|
|
|
+ audioSendGiftModel.receivers.forEachIndexed {position, positionBean ->
|
|
|
|
+ //创建从屏幕中心弹出的动画view
|
|
|
|
+ allAudioGiftViewList[position].setViewData(audioSendGiftModel.giftIcon, audioSendGiftModel.giftNum)
|
|
|
|
+ clMultiAudio.addView(allAudioGiftViewList[position])
|
|
|
|
+
|
|
|
|
+ //从中间缩放出来
|
|
|
|
+ val alphaAnim = ObjectAnimator.ofFloat(allAudioGiftViewList[position], "alpha", 1f, 1f)
|
|
|
|
+ val scaleX = ObjectAnimator.ofFloat(allAudioGiftViewList[position], "scaleX", 0f, 1f)
|
|
|
|
+ val scaleY = ObjectAnimator.ofFloat(allAudioGiftViewList[position], "scaleY", 0f, 1f)
|
|
|
|
+ val scaleFromCenter = AnimatorSet()
|
|
|
|
+ scaleFromCenter.playTogether(scaleX,scaleY,alphaAnim)
|
|
|
|
+ scaleFromCenter.setTarget(allAudioGiftViewList[position])
|
|
|
|
+ scaleX.duration = 300
|
|
|
|
+ scaleY.duration = 300
|
|
|
|
+
|
|
|
|
+ //从中间向其他地方位移缩放
|
|
|
|
+ val moveX = ObjectAnimator.ofFloat(allAudioGiftViewList[position],"translationX", positionBean.dx)
|
|
|
|
+ val moveY = ObjectAnimator.ofFloat(allAudioGiftViewList[position],"translationY", positionBean.dy)
|
|
|
|
+ val scaleXX = ObjectAnimator.ofFloat(allAudioGiftViewList[position],"scaleX",1f,0.2f)
|
|
|
|
+ val scaleYY = ObjectAnimator.ofFloat(allAudioGiftViewList[position],"scaleY",1f,0.2f)
|
|
|
|
+ val moveAndScale = AnimatorSet()
|
|
|
|
+ moveAndScale.playTogether(moveX,moveY,scaleXX,scaleYY)
|
|
|
|
+ moveAndScale.duration = 700
|
|
|
|
+
|
|
|
|
+ val alphaAnimX = ObjectAnimator.ofFloat(allAudioGiftViewList[position], "alpha", 1f, 0f)
|
|
|
|
+ alphaAnimX.duration = 200
|
|
|
|
+
|
|
|
|
+ val moveAnimatorPlus = AnimatorSet()
|
|
|
|
+ moveAnimatorPlus.play(alphaAnimX).after(moveAndScale)
|
|
|
|
+
|
|
|
|
+ //在头像上方消失
|
|
|
|
+ val alphaAnimEnd = ObjectAnimator.ofFloat(allAudioGiftViewList[position],"alpha",1f,0f)
|
|
|
|
+ alphaAnimEnd.duration = 800
|
|
|
|
+ //向头像上方移动
|
|
|
|
+ val upYAnima = ObjectAnimator.ofFloat(allAudioGiftViewList[position],"translationY",positionBean.offSetY)
|
|
|
|
+ val alphaAnimUp = ObjectAnimator.ofFloat(allAudioGiftViewList[position], "alpha", 0f, 1f)
|
|
|
|
+ val upAnimatorSet = AnimatorSet()
|
|
|
|
+ upAnimatorSet.playTogether(upYAnima,alphaAnimUp)
|
|
|
|
+ upAnimatorSet.duration = 200
|
|
|
|
+
|
|
|
|
+ val animationScaleAndMoveSet = AnimatorSet()
|
|
|
|
+ animationScaleAndMoveSet.play(moveAnimatorPlus)
|
|
|
|
+ .after(scaleFromCenter)
|
|
|
|
+ .after(2300)
|
|
|
|
+
|
|
|
|
+ val animatorSet = AnimatorSet()
|
|
|
|
+ animatorSet.play(upAnimatorSet)
|
|
|
|
+ .after(animationScaleAndMoveSet)
|
|
|
|
+ .before(alphaAnimEnd)
|
|
|
|
+ animatorSet.setTarget(allAudioGiftViewList[position])
|
|
|
|
+ allAnimationSetList.add(animatorSet)
|
|
|
|
+
|
|
|
|
+ animatorSet.addListener(object: Animator.AnimatorListener{
|
|
|
|
+ override fun onAnimationStart(animation: Animator?) {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onAnimationEnd(animation: Animator?) {
|
|
|
|
+ currentModel = null
|
|
|
|
+ isBusy = false
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onAnimationCancel(animation: Animator?) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onAnimationRepeat(animation: Animator?) {}
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ }
|
|
}
|
|
}
|
|
allAnimationSetList.forEach {
|
|
allAnimationSetList.forEach {
|
|
it.start()
|
|
it.start()
|