Browse Source

Fix download progress notification not auto dismissed sometimes

renovate/org.robolectric-robolectric-4.x
Ammar Githam 4 years ago
parent
commit
b99ee88c97
  1. 7
      app/src/main/java/awais/instagrabber/workers/DownloadWorker.java

7
app/src/main/java/awais/instagrabber/workers/DownloadWorker.java

@ -200,6 +200,10 @@ public class DownloadWorker extends Worker {
final float percent) {
final Notification notification = createProgressNotification(position, total, percent);
try {
if (notification == null) {
notificationManager.cancel(notificationId);
return;
}
setForegroundAsync(new ForegroundInfo(notificationId, notification)).get();
} catch (ExecutionException | InterruptedException e) {
Log.e(TAG, "updateDownloadProgress", e);
@ -216,6 +220,9 @@ public class DownloadWorker extends Worker {
} else {
totalPercent = (int) ((100f * (position - 1) / total) + (1f / total) * (percent));
}
if (totalPercent == 100) {
return null;
}
// Log.d(TAG, "createProgressNotification: position: " + position
// + ", total: " + total
// + ", percent: " + percent

Loading…
Cancel
Save