In my MainActivity I have a callback whose runs asynchronously on a background thread. I would like to show an Animation (rotation) over an Imageview while the thread is running , so my callback is:
pull.addChangeListener(new Replication.ChangeListener() {
@Override
public void changed(Replication.ChangeEvent event) {
if (REPLICATION_ACTIVE)) {
runOnUiThread(new Runnable() {
@Override
public void run() {
startAnimation();//I call here to the animation
} else {
runOnUiThread(new Runnable() {
@Override
public void run() {
stopAnimation()
}
});
}
The startAnimation() method
private void startAnimation(){
isAnimationDone = true;
imgSincronizacion.setImageResource(R.mipmap.btn_sync_on);
Animation rotation= AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotation);
rotacion.setRepeatMode(Animation.ABSOLUTE);
rotacion.setRepeatCount(Animation.INFINITE);
imgSincronizacion.startAnimation(rotation);
}
Im not facing errors but the animation does not not work. Any idea about how I can animate an ImageView from a background Thread ?