From d59b1700c8b14f7d8adf7f31a4d480b3dc4e43e0 Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Sun, 14 Oct 2012 15:43:53 +0530 Subject: [PATCH] Update progressbar less often --- src/org/wikimedia/commons/UploadService.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/org/wikimedia/commons/UploadService.java b/src/org/wikimedia/commons/UploadService.java index dccec5306..8cfc2b919 100644 --- a/src/org/wikimedia/commons/UploadService.java +++ b/src/org/wikimedia/commons/UploadService.java @@ -36,16 +36,19 @@ public class UploadService extends IntentService { private class NotificationUpdateProgressListener implements ProgressListener { Notification curNotification; + private int lastPercent = 0; public NotificationUpdateProgressListener(Notification curNotification) { Log.d("Commons", "Fuckity"); this.curNotification = curNotification; } @Override public void onProgress(long transferred, long total) { - double percent = (double)transferred / (double)total * 100; - Log.d("Commons", "Uploaded " + percent + "% (" + transferred + " of " + total + ")"); - curNotification.contentView.setProgressBar(R.id.uploadNotificationProgress, 100, (int)percent, false); - notificationManager.notify(NOTIFICATION_DOWNLOAD_IN_PROGRESS, curNotification); + int percent =(int) ((double)transferred / (double)total * 100); + if(percent > lastPercent) { + curNotification.contentView.setProgressBar(R.id.uploadNotificationProgress, 100, percent, false); + notificationManager.notify(NOTIFICATION_DOWNLOAD_IN_PROGRESS, curNotification); + lastPercent = percent; + } } }