diff options
author | cyBerta <cyberta@riseup.net> | 2020-12-28 16:13:52 +0100 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2020-12-28 16:13:52 +0100 |
commit | a41c9876bac7c769a876d5aebc3e797c7c2e73a4 (patch) | |
tree | 2b581beebea84883f75b35ef3079cf27ecf1c945 /app/src/fatweb/java | |
parent | 0ce7baa3ce5138d9b298b67cfcd03d04ba6a66c0 (diff) |
debounce notification creation during app download
Diffstat (limited to 'app/src/fatweb/java')
-rw-r--r-- | app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/DownloadConnector.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/DownloadConnector.java b/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/DownloadConnector.java index f081331f..8723f515 100644 --- a/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/DownloadConnector.java +++ b/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/DownloadConnector.java @@ -95,11 +95,16 @@ public class DownloadConnector { long totalBytesRead = 0; int bufferSize = 8 * 1024; long bytesRead; + int lastProgress = 0; while ((bytesRead = source.read(sinkBuffer, bufferSize)) != -1) { sink.emit(); totalBytesRead += bytesRead; int progress = (int) ((totalBytesRead * 100) / contentLength); - callback.onUpdate(progress); + // debouncing callbacks + if (lastProgress < progress) { + lastProgress = progress; + callback.onUpdate(progress); + } } sink.flush(); |