@@ -18,7 +18,7 @@ class ViewPropertySpringAnimator<T : View>(
1818 }
1919
2020 private val pendingAnimations = mutableListOf<SpringAnimationHolder >()
21- private val runningAnimations = mutableMapOf<FloatPropertyCompat <View >, SpringAnimation > ()
21+ private val runningAnimations = mutableMapOf<FloatPropertyCompat <in T >, SpringAnimation > ()
2222 val isRunning: Boolean
2323 get() = runningAnimations.isNotEmpty()
2424
@@ -180,38 +180,38 @@ class ViewPropertySpringAnimator<T : View>(
180180
181181 fun animateProperty (
182182 finalValue : Float ,
183- setter : View .(Float ) -> Unit ,
184- getter : View .() -> Float ,
183+ setter : T .(Float ) -> Unit ,
184+ getter : T .() -> Float ,
185185 config : SpringAnimationConfig .() -> Unit = {}
186186 ): ViewPropertySpringAnimator <T > =
187187 animateProperty(createCustomProperty(setter, getter), finalValue, config)
188188
189189 fun animatePropertyBy (
190- setter : View .(Float ) -> Unit ,
191- getter : View .() -> Float ,
190+ setter : T .(Float ) -> Unit ,
191+ getter : T .() -> Float ,
192192 finalValue : Float ,
193193 config : SpringAnimationConfig .() -> Unit = {}
194194 ): ViewPropertySpringAnimator <T > =
195195 animatePropertyBy(createCustomProperty(setter, getter), finalValue, config)
196196
197197 fun animateProperty (
198- property : FloatPropertyCompat <View >,
198+ property : FloatPropertyCompat <in T >,
199199 finalValue : Float ,
200200 config : SpringAnimationConfig .() -> Unit = {}
201201 ) = apply {
202202 animateProperty(property, finalValue, 0f , config)
203203 }
204204
205205 fun animatePropertyBy (
206- property : FloatPropertyCompat <View >,
206+ property : FloatPropertyCompat <in T >,
207207 finalValue : Float ,
208208 config : SpringAnimationConfig .() -> Unit = {}
209209 ) = apply {
210210 animateProperty(property, finalValue, property.getValue(view), config)
211211 }
212212
213213 private fun animateProperty (
214- property : FloatPropertyCompat <View >,
214+ property : FloatPropertyCompat <in T >,
215215 finalValue : Float ,
216216 finalValueBias : Float ,
217217 configBuilder : SpringAnimationConfig .() -> Unit = {}
@@ -230,7 +230,7 @@ class ViewPropertySpringAnimator<T : View>(
230230 }
231231
232232 private fun SpringAnimation.createEndListener (
233- property : FloatPropertyCompat <View >
233+ property : FloatPropertyCompat <in T >
234234 ) {
235235 val listener = object : DynamicAnimation .OnAnimationEndListener {
236236 override fun onAnimationEnd (
@@ -310,14 +310,14 @@ class ViewPropertySpringAnimator<T : View>(
310310 }
311311
312312 private fun createCustomProperty (
313- setter : View .(Float ) -> Unit ,
314- getter : View .() -> Float
315- ) = object : FloatPropertyCompat <View >(" CustomProperty" ) {
316- override fun getValue (view : View ): Float {
313+ setter : T .(Float ) -> Unit ,
314+ getter : T .() -> Float
315+ ) = object : FloatPropertyCompat <T >(" CustomProperty" ) {
316+ override fun getValue (view : T ): Float {
317317 return getter.invoke(view)
318318 }
319319
320- override fun setValue (view : View , value : Float ) {
320+ override fun setValue (view : T , value : Float ) {
321321 setter.invoke(view, value)
322322 }
323323 }
0 commit comments