2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-10-13 13:57:57 +00:00

Added progress bar in notification while sending file

REVIEW: 121980
This commit is contained in:
Vineet Garg
2015-01-15 22:57:06 -08:00
committed by Albert Vaca
parent ded027d3cc
commit 1edca5e45c
8 changed files with 141 additions and 24 deletions

View File

@@ -143,18 +143,20 @@ public class SharePlugin extends Plugin {
public void run() {
try {
OutputStream output = new FileOutputStream(destinationFullPath.getPath());
byte data[] = new byte[1024];
long total = 0;
long progress = 0,prevProgressPercentage = 0;
int count;
while ((count = input.read(data)) >= 0) {
total += count;
progress += count;
output.write(data, 0, count);
if (fileLength > 0) {
if (total >= fileLength) break;
float progress = (total * 100 / fileLength);
builder.setProgress(100,(int)progress,false);
notificationManager.notify(notificationId,builder.build());
if (progress >= fileLength) break;
long progressPercentage = (progress * 100 / fileLength);
if ((progressPercentage - prevProgressPercentage) > 0) {
prevProgressPercentage = progressPercentage;
builder.setProgress(100, (int) progressPercentage, false);
notificationManager.notify(notificationId, builder.build());
}
}
//else Log.e("SharePlugin", "Infinite loop? :D");
}