Created
December 2, 2019 16:53
-
-
Save nikhilpanju/a29369c15d90c0cdcd1c46eb21fd0ddc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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