Skip to content

Commit

Permalink
Don't use PropertyValuesHolder when only animating one property.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbutcher committed Feb 6, 2019
1 parent a1c9ca6 commit 399a067
Showing 1 changed file with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import android.widget.ImageButton
import androidx.core.animation.doOnEnd
import androidx.core.animation.doOnStart
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.textfield.TextInputLayout
import io.plaidapp.core.designernews.domain.model.Comment
import io.plaidapp.core.util.AnimUtils.getFastOutSlowInInterpolator
import io.plaidapp.designernews.R
Expand All @@ -52,16 +51,16 @@ internal class CommentReplyViewHolder(itemView: View) : RecyclerView.ViewHolder(
val interpolator = getFastOutSlowInInterpolator(itemView.context)

val commentVotesAnimator = ObjectAnimator.ofPropertyValuesHolder(
commentVotes,
PropertyValuesHolder.ofFloat(View.TRANSLATION_X, -commentVotes.width.toFloat()),
PropertyValuesHolder.ofFloat(View.ALPHA, 0f)
commentVotes,
PropertyValuesHolder.ofFloat(View.TRANSLATION_X, -commentVotes.width.toFloat()),
PropertyValuesHolder.ofFloat(View.ALPHA, 0f)
).apply {
duration = 200L
this.interpolator = interpolator
}
val replyLabelAnimator = ObjectAnimator.ofPropertyValuesHolder(
replyLabel,
PropertyValuesHolder.ofFloat(View.TRANSLATION_X, -commentVotes.width.toFloat())
replyLabel,
PropertyValuesHolder.ofFloat(View.TRANSLATION_X, -commentVotes.width.toFloat())
).apply {
duration = 200L
this.interpolator = interpolator
Expand All @@ -71,8 +70,8 @@ internal class CommentReplyViewHolder(itemView: View) : RecyclerView.ViewHolder(
postReply.alpha = 0f

val postReplyAnimator = ObjectAnimator.ofPropertyValuesHolder(
postReply,
PropertyValuesHolder.ofFloat(View.ALPHA, 1f)
postReply,
PropertyValuesHolder.ofFloat(View.ALPHA, 1f)
).apply {
duration = 200L
this.interpolator = interpolator
Expand All @@ -93,24 +92,26 @@ internal class CommentReplyViewHolder(itemView: View) : RecyclerView.ViewHolder(
val interpolator = getFastOutSlowInInterpolator(itemView.context)

val commentVotesAnimator = ObjectAnimator.ofPropertyValuesHolder(
commentVotes,
PropertyValuesHolder.ofFloat(View.TRANSLATION_X, 0f),
PropertyValuesHolder.ofFloat(View.ALPHA, 1f)
commentVotes,
PropertyValuesHolder.ofFloat(View.TRANSLATION_X, 0f),
PropertyValuesHolder.ofFloat(View.ALPHA, 1f)
).apply {
duration = 200L
this.interpolator = interpolator
}
val replyLabelAnimator = ObjectAnimator.ofPropertyValuesHolder(
replyLabel,
PropertyValuesHolder.ofFloat(View.TRANSLATION_X, 0f)
val replyLabelAnimator = ObjectAnimator.ofFloat(
replyLabel,
View.TRANSLATION_X,
0f
).apply {
duration = 200L
this.interpolator = interpolator
}

val postReplyAnimator = ObjectAnimator.ofPropertyValuesHolder(
postReply,
PropertyValuesHolder.ofFloat(View.ALPHA, 0f)
val postReplyAnimator = ObjectAnimator.ofFloat(
postReply,
View.ALPHA,
0f
).apply {
duration = 200L
this.interpolator = interpolator
Expand Down

0 comments on commit 399a067

Please sign in to comment.