1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
ImageView refresh = (ImageView) findViewById (R.id.refresh);
// On crée une animation
RotateAnimation anim = new RotateAnimation (0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
anim.setInterpolator (new LinearInterpolator ());
anim.setDuration (1000);
anim.setFillEnabled (true);
anim.setRepeatCount (Animation.INFINITE);
anim.setFillAfter (true);
refresh.startAnimation (anim);
// On arrête l'annimation une fois que le traitement est fait
final Runnable finish = new Runnable ()
{
@Override
public void run ()
{
// TODO : Do something when finish....
refresh.clearAnimation ();
refresh.setImageDrawable (global.getResources ().getDrawable (R.drawable.btn_refresh));
}
};
// Permet d'appeler le Runnable dans le thread
final Handler uiThreadCallback = new Handler ();
// On exécute le traitement dans un Thread
new Thread ()
{
@Override
public void run ()
{
// TODO : Do something when ImageView turn...
uiThreadCallback.post (finish);
}
}.start (); |
Partager