I want to create recycle view with a counter in each row. Each row has a separate timer. This time should run separately. I able to create a timer but each time app gets restarted, the timer is getting reset.
Thank you in advance for your help!!
I want to create recycle view with a counter in each row. Each row has a separate timer. This time should run separately. I able to create a timer but each time app gets restarted, the timer is getting reset.
Thank you in advance for your help!!
try this:
public CountDownTimer timer;
in onBindViewHolder(...)
if (holder.timer != null) {
holder.timer.cancel();
}
holder.timer = new CountDownTimer(timeEnd - System.currentTimeMillis(), 1000) {
@Override
public void onTick(long millisUntilFinished) {
// update text..
}
@Override
public void onFinish() {
// update text..
}
};
that worked for me!!!