Skip to content

Commit

Permalink
优化大数值的进度异常
Browse files Browse the repository at this point in the history
  • Loading branch information
VeiZhang committed Sep 26, 2022
1 parent 1a7fd0d commit a0001ab
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions Demo/src/main/java/com/zv/downloader/bean/Task.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package com.zv.downloader.bean;

import android.widget.Button;
import android.widget.ProgressBar;

import com.excellence.downloader.FileDownloader.DownloadTask;
import com.zv.downloader.R;

import static com.excellence.downloader.entity.TaskEntity.STATUS_DISCARD;
import static com.excellence.downloader.entity.TaskEntity.STATUS_DOWNLOADING;
import static com.excellence.downloader.entity.TaskEntity.STATUS_ERROR;
import static com.excellence.downloader.entity.TaskEntity.STATUS_PAUSE;
import static com.excellence.downloader.entity.TaskEntity.STATUS_SUCCESS;

import com.excellence.downloader.FileDownloader.DownloadTask;
import com.zv.downloader.R;

import android.widget.Button;
import android.widget.ProgressBar;

/**
* <pre>
* author : VeiZhang
Expand Down Expand Up @@ -159,6 +159,13 @@ public void invalidateTask()
}
}

public static void setProgress(ProgressBar progressBar, long max, long progress) {
max = Math.max(max, 1);
progress = progress > max ? 0 : progress;
// progressBar.setMax(100);
progressBar.setProgress((int) Math.floor((float) progress / max * 100));
}

public void setSpeed(String speed)
{
mStartBtn.setText(speed);
Expand Down

0 comments on commit a0001ab

Please sign in to comment.