From a41c9876bac7c769a876d5aebc3e797c7c2e73a4 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Mon, 28 Dec 2020 16:13:52 +0100 Subject: debounce notification creation during app download --- .../java/se.leap.bitmaskclient/appUpdate/DownloadConnector.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'app/src/fatweb/java') 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(); -- cgit v1.2.3