Hello, guys, I'm having the following problem I need to manage an animation. Which changes over time, and for this I made the following code:
public void HandleAnimator(){
new Thread(new Runnable() {
boolean pass1 = true;
boolean pass2 = true;
boolean pass3 = true;
boolean pass4 = true;
boolean pass5 = true;
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
SetAnimator(1); //Animação inicial
while(mCountDonwTime.getmTime()!=0) {
if(mCountDonwTime.getmTime()<80000 && pass2){
SetAnimator(2);
pass3 = false;
}
if(mCountDonwTime.getmTime() < 60000 && pass3){
SetAnimator(3);
pass4 = false;
}
if(mCountDonwTime.getmTime() < 40000 && pass4){
SetAnimator(4);
pass4 = false;
}
if(mCountDonwTime.getmTime() < 20000 && pass5){
SetAnimator(5);
pass5 = false;
}
}
}
});
}
}).start();
}
public void SetAnimator(int animacao){
switch(animacao){
case 1:
im.setBackgroundResource(R.drawable.animation);
break;
case 2:
im.setBackgroundResource(R.drawable.animationb);
break;
case 3:
im.setBackgroundResource(R.drawable.animationc);
break;
case 4:
im.setBackgroundResource(R.drawable.animationd);
break;
case 5:
im.setBackgroundResource(R.drawable.animatione);
break;
}
AnimationDrawable Animation = (AnimationDrawable) im.getBackground();
Animation.start();
}
When I use this while within the structure of this thread, there is a type of overhead on the device's processor. So I do not know what else I could do to control these animations.