mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-22 10:46:50 +00:00
Show correct animation in boost fragment.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package org.thoughtcrime.securesms.components.settings.app.subscription.boost
|
||||
|
||||
import android.animation.Animator
|
||||
import android.view.View
|
||||
import com.airbnb.lottie.LottieAnimationView
|
||||
import com.airbnb.lottie.LottieDrawable
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.animation.AnimationCompleteListener
|
||||
import org.thoughtcrime.securesms.components.settings.PreferenceModel
|
||||
import org.thoughtcrime.securesms.util.MappingAdapter
|
||||
import org.thoughtcrime.securesms.util.MappingViewHolder
|
||||
|
||||
/**
|
||||
* A simple mapping model to show a boost animation.
|
||||
*/
|
||||
object BoostAnimation {
|
||||
|
||||
class Model : PreferenceModel<Model>(isEnabled = true) {
|
||||
override fun areItemsTheSame(newItem: Model): Boolean = true
|
||||
}
|
||||
|
||||
class ViewHolder(itemView: View) : MappingViewHolder<Model>(itemView) {
|
||||
|
||||
private val lottie: LottieAnimationView = findViewById(R.id.boost_animation_view)
|
||||
|
||||
override fun bind(model: Model) {
|
||||
lottie.playAnimation()
|
||||
lottie.addAnimatorListener(object : AnimationCompleteListener() {
|
||||
override fun onAnimationEnd(animation: Animator?) {
|
||||
lottie.removeAnimatorListener(this)
|
||||
lottie.setMinAndMaxFrame(30, 91)
|
||||
lottie.repeatMode = LottieDrawable.RESTART
|
||||
lottie.repeatCount = LottieDrawable.INFINITE
|
||||
lottie.frame = 30
|
||||
lottie.playAnimation()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fun register(adapter: MappingAdapter) {
|
||||
adapter.registerFactory(Model::class.java, MappingAdapter.LayoutFactory({ ViewHolder(it) }, R.layout.boost_animation_pref))
|
||||
}
|
||||
}
|
||||
@@ -82,6 +82,7 @@ class BoostFragment : DSLSettingsBottomSheetFragment(
|
||||
GooglePayButton.register(adapter)
|
||||
Progress.register(adapter)
|
||||
NetworkFailure.register(adapter)
|
||||
BoostAnimation.register(adapter)
|
||||
|
||||
processingDonationPaymentDialog = MaterialAlertDialogBuilder(requireContext())
|
||||
.setView(R.layout.processing_payment_dialog)
|
||||
@@ -143,7 +144,7 @@ class BoostFragment : DSLSettingsBottomSheetFragment(
|
||||
}
|
||||
|
||||
return configure {
|
||||
customPref(BadgePreview.SubscriptionModel(state.boostBadge))
|
||||
customPref(BoostAnimation.Model())
|
||||
|
||||
sectionHeaderPref(
|
||||
title = DSLSettingsText.from(
|
||||
|
||||
Reference in New Issue
Block a user