|
|
@@ -6,12 +6,12 @@ import android.view.ViewGroup
|
|
|
import android.widget.TextView
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
import com.airbnb.lottie.LottieAnimationView
|
|
|
-import com.airbnb.lottie.LottieDrawable
|
|
|
import com.atmob.keyboard_android.R
|
|
|
import com.atmob.keyboard_android.ext.click
|
|
|
import com.atmob.keyboard_android.ext.setGone
|
|
|
import com.atmob.keyboard_android.ext.setVisible
|
|
|
import com.atmob.keyboard_android.model.AiKeyboardKeyModel
|
|
|
+import com.atmob.keyboard_android.util.LottieAnimationUtil
|
|
|
import me.drakeet.multitype.ItemViewBinder
|
|
|
|
|
|
/**
|
|
|
@@ -36,7 +36,7 @@ class AiKeyboardKeyViewBinder(
|
|
|
if (item.isLoading) {
|
|
|
holder.vLoveFlyLoadingLottieView.setVisible()
|
|
|
holder.vKeyText.setGone()
|
|
|
- playLottieAnimation(holder.vLoveFlyLoadingLottieView)
|
|
|
+ LottieAnimationUtil.playLottieAnimation(holder.vLoveFlyLoadingLottieView, "lottie/anim_keyboard_love_fly.json")
|
|
|
} else {
|
|
|
// 隐藏Loading,显示文字
|
|
|
holder.vLoveFlyLoadingLottieView.setGone()
|
|
|
@@ -45,29 +45,13 @@ class AiKeyboardKeyViewBinder(
|
|
|
holder.vKeyText.apply {
|
|
|
text = item.text
|
|
|
}
|
|
|
- stopLottieAnimation(holder.vLoveFlyLoadingLottieView)
|
|
|
+ LottieAnimationUtil.stopLottieAnimation(holder.vLoveFlyLoadingLottieView)
|
|
|
}
|
|
|
holder.itemView.click {
|
|
|
onItemClick.invoke(item)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 播放Lottie动画
|
|
|
- */
|
|
|
- private fun playLottieAnimation(animationView: LottieAnimationView) {
|
|
|
- animationView.setAnimation("lottie/anim_keyboard_love_fly.json")
|
|
|
- animationView.repeatCount = LottieDrawable.INFINITE
|
|
|
- animationView.playAnimation()
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 停止Lottie动画
|
|
|
- */
|
|
|
- private fun stopLottieAnimation(animationView: LottieAnimationView) {
|
|
|
- animationView.cancelAnimation()
|
|
|
- }
|
|
|
-
|
|
|
inner class InnerViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
|
|
val vKeyText: TextView = itemView.findViewById(R.id.key_text)
|
|
|
val vLoveFlyLoadingLottieView: LottieAnimationView =
|