I am trying to add an animation when new items are added to my ListView (It's a messaging application). Using the following code in the getView()
method of my ArrayAdapter, this works perfectly fine:
if (!entry.isAnimationDone() && SharedPrefs.accessSettings(getContext()).getBoolean("ani_message_send", true)) {
Animation animation = AnimationUtils.loadAnimation(getContext(), R.anim.slide_in_bottom);
animation.setAnimationListener(new AnimationListenerAdapter() {
@Override
public void onAnimationEnd(Animation animation) {
entry.animationFinished();
}
});
convertView.startAnimation(animation);
}
But my message app also implements message states (small icons that indicate whether the other person has downloaded or read my message). When this state changes notifyDataSetChanged()
is called to make the UI represent this state.
The problem is, that if this happens while the animation is still going which occurs quite often, my animation will restart which results in a glitchy GUI.
I've been searching on the internet for a while now but I couldn't find a solution to my problem. Is there another way to implement adding animations, or is there a fix for this glitch?
Any help will be much appreciated.