package com.betaseries.betaseries.controllers;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.util.Log;
import android.widget.ImageView;
/**
* Created by florentchampigny on 25/08/15.
*/
public class LoginViewController {
public static final String TAG = "LoginViewController";
public void animateSwitch(ImageView imageView, int delaySwitch) {
animateDisapear(imageView, delaySwitch);
}
private void animateDisapear(final ImageView imageView, final int delaySwitch) {
try {
ObjectAnimator disapear = ObjectAnimator.ofFloat(imageView, "alpha", 1, 0);
disapear.setStartDelay(delaySwitch);
disapear.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
animateAppear(imageView, delaySwitch);
}
});
disapear.start();
} catch (Exception e) {
Log.d(TAG, e.getLocalizedMessage(), e);
}
}
private void animateAppear(final ImageView imageView, final int delaySwitch) {
try {
ObjectAnimator appear = ObjectAnimator.ofFloat(imageView, "alpha", 0, 1);
appear.setStartDelay(delaySwitch);
appear.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
animateDisapear(imageView, delaySwitch);
}
});
appear.start();
} catch (Exception e) {
Log.d(TAG, e.getLocalizedMessage(), e);
}
}
}