mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-18 04:37:30 +00:00
Fix download progress notification not auto dismissed sometimes
This commit is contained in:
parent
60e5007376
commit
b99ee88c97
@ -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…
Reference in New Issue
Block a user