带有以毫秒为单位的时间戳的 ProgressBar

ProgressBar with timestamp in millis

我需要进度条,其间隔为两个时间戳值(以毫秒为单位)。

例如,我的时间戳为 08:46:11 30.06.2019 和 10:46:11 30.06.2019。但是当前时间是 09:46:11 2019 年 6 月 30 日,所以现在进度条应该填充 50% 并上升到 100,直到 10:46:11 2019 年 6 月 30 日。

所以我尝试了下一个代码:

private void progressBar(){
            prBar.setProgress(i);
            mCountDownTimer=new CountDownTimer(ltimestampStop * 1000,ltimestampStart * 1000) {

                @Override
                public void onTick(long millisUntilFinished) {
                    Log.v("Log_tag", "Tick of Progress"+ i+ millisUntilFinished);
                    i++;
                    int Start = ltimestampStart.intValue();
                    int Stop = ltimestampStop.intValue();
                    prBar.setProgress((int)i*100/(Stop/Start));

                }

                @Override
                public void onFinish() {
                    //Do what you want
                    i++;
                    prBar.setProgress(100);
                }
            };
            mCountDownTimer.start();
        }

但问题是 int 无法处理我的毫秒时间戳,并且 setProgress() 不适用于 long 类型。

我可以尝试什么来完成我的任务?

更新: 根据我的任务,我认为 countdowntimer 不是我需要的。

像这样初始化你的进度条和 CountDownTimer -

 MyCountDownTimer myCountDownTimer;
`ProgressBar progressBar = (ProgressBar)findViewById(R.id.progressbar);`
 progressBar.setProgress(100);

像这样制作你的倒计时 -

public class MyCountDownTimer extends CountDownTimer {

   public MyCountDownTimer(long millisInFuture, long countDownInterval) {
    super(millisInFuture, countDownInterval);
  }

    @Override
    public void onTick(long millisUntilFinished) {
    Log.d("Time in millis", String.valueOf(millisUntilFinished));
    int progress = (int) (millisUntilFinished/100);
    progressBar.setProgress(progress);
   }

    @Override
    public void onFinish() {
    Log.d("Time in millis", "Timer finished");
    progressBar.setProgress(0);
   }
}

像这样调用你的 CountDownTimer-

myCountDownTimer = new MyCountDownTimer(50000, 1000);
myCountDownTimer.start();