0

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!!

enter image description here

Rohit Deshmukh
  • 149
  • 1
  • 10

1 Answers1

0

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!!!

izakos
  • 265
  • 2
  • 6