diff --git a/ExpandAnimationExample/src/com/udinic/expand_animation_example/ExpandAnimationDemo.java b/ExpandAnimationExample/src/com/udinic/expand_animation_example/ExpandAnimationDemo.java index 1e96e24..6eb0ddc 100644 --- a/ExpandAnimationExample/src/com/udinic/expand_animation_example/ExpandAnimationDemo.java +++ b/ExpandAnimationExample/src/com/udinic/expand_animation_example/ExpandAnimationDemo.java @@ -35,11 +35,16 @@ public void onItemClick(AdapterView parent, final View view, int position, lo View toolbar = view.findViewById(R.id.toolbar); - // Creating the expand animation for the item - ExpandAnimation expandAni = new ExpandAnimation(toolbar, 500); - - // Start the animation on the toolbar - toolbar.startAnimation(expandAni); + // Start expand/collapse animation, only if animation is not already running + if (!(toolbar.getAnimation() instanceof ExpandAnimation)) { + + // Creating the expand animation for the item + ExpandAnimation expandAni = new ExpandAnimation(toolbar, 500); + + // Start the animation on the toolbar + toolbar.startAnimation(expandAni); + + } } }); }