im trying CountDownTimer on android studio and it works fine, but after about 5 minutes passed apps seems to badly lag. how to prevent this?
*note : my logcat give this warning "Skipped 60 frames! The application may be doing too much work on its main thread."
and im using this CountDownTimer for a listview, so there is a CountDownTimer as listview item (if the item less or equal to 2 items there is no problem so far).
here is my code :
int milis = Integer.valueOf(timeinseconds[position]);
myTimer = new CountDownTimer(milis, 1000) {
public void onTick(long millisUntilFinished) {
tempminute = (int) Math.floor((millisUntilFinished/1000)/60);
minutes = tempminute%60;
seconds = (int) (millisUntilFinished/1000)%60;
hours = tempminute/60;
vouchercountdown.setText("00 day " + hours + " hr " + minutes + " min " + seconds + " sec");
}
public void onFinish() {
vouchercountdown.setText("00 day 00 hr 00 min 00 sec");
}
};
Runnable mHandlerTask = new Runnable() {
@Override
public void run() {
myTimer.start();
}
};
mHandlerTask.run();
Thanks