DownloaderService: only broadcast progress when it actually changes
On a slow download, this could send like 100+ updates even though no more data had been received. closes #1742
This commit is contained in:
parent
d794c5a77c
commit
04298f8886
@ -204,10 +204,16 @@ public abstract class Downloader {
|
||||
* Send progress updates on a timer to avoid flooding receivers with pointless events.
|
||||
*/
|
||||
private final TimerTask progressTask = new TimerTask() {
|
||||
private long lastBytesRead = Long.MIN_VALUE;
|
||||
private long lastTotalBytes = Long.MIN_VALUE;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (downloaderProgressListener != null) {
|
||||
if (downloaderProgressListener != null
|
||||
&& (bytesRead != lastBytesRead || totalBytes != lastTotalBytes)) {
|
||||
downloaderProgressListener.onProgress(bytesRead, totalBytes);
|
||||
lastBytesRead = bytesRead;
|
||||
lastTotalBytes = totalBytes;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user