1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-12-23 13:26:59 +00:00

Fix download progress notification not auto dismissed sometimes

This commit is contained in:
Ammar Githam 2020-11-10 21:44:31 +09:00
parent 60e5007376
commit b99ee88c97

View File

@ -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