On Instagram, we have very cool action for liking feeds. I'm trying to implement that on my project.
After single-clicking on ImageView
, it should show the item with fade-in and zoom-in animate effect. I have written the following code:
if (!postLike) {
holder.like_instagram_post.animate().alpha(0)
.setDuration(5000).setInterpolator(new DecelerateInterpolator())
.withEndAction(new Runnable() {
@Override
public void run() {
holder.like_instagram_post.animate()
.alpha(1).setDuration(1000)
.setInterpolator(new AccelerateInterpolator()).start();
holder.like_instagram_post.animate()
.scaleX(5f).setDuration(1000)
.setInterpolator(new AccelerateInterpolator()).start();
holder.like_instagram_post.animate()
.scaleY(5f).setDuration(1000)
.setInterpolator(new AccelerateInterpolator()).start();
postLike = !postLike;
}
}).start();
} else {
holder.like_instagram_post.animate().alpha(1)
.setDuration(5000).setInterpolator(new DecelerateInterpolator())
.withEndAction(new Runnable() {
@Override
public void run() {
holder.like_instagram_post.animate()
.alpha(0).setDuration(1000)
.setInterpolator(new AccelerateInterpolator()).start();
holder.like_instagram_post.animate()
.scaleX(1f).setDuration(1000)
.setInterpolator(new AccelerateInterpolator()).start();
holder.like_instagram_post.animate()
.scaleY(1f).setDuration(1000)
.setInterpolator(new AccelerateInterpolator()).start();
postLike = !postLike;
}
}).start();
}
This code is not working correctly. How should I fix it?