Skip to content

Instantly share code, notes, and snippets.

@nikhilpanju
Created December 2, 2019 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikhilpanju/a29369c15d90c0cdcd1c46eb21fd0ddc to your computer and use it in GitHub Desktop.
Save nikhilpanju/a29369c15d90c0cdcd1c46eb21fd0ddc to your computer and use it in GitHub Desktop.
private fun expandItem(holder: ListViewHolder, expand: Boolean, animate: Boolean) {
if (animate) {
val animator = getValueAnimator(
expand, listItemExpandDuration, AccelerateDecelerateInterpolator()
) { progress ->
holder.cardContainer.layoutParams.height =
(originalHeight + (expandedHeight - originalHeight) * progress).toInt()
holder.cardContainer.layoutParams.width =
(originalWidth + (expandedWidth - originalWidth) * progress).toInt()
holder.cardContainer.setBackgroundColor(blendColors(originalBg, expandedBg, progress))
holder.cardContainer.requestLayout()
holder.chevron.rotation = 90 * progress
}
if (expand) animator.doOnStart { holder.expandView.isVisible = true }
else animator.doOnEnd { holder.expandView.isVisible = false }
animator.start()
} else {
// ... Left out for brevity
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment