Use different ids

This commit is contained in:
Nathan Mascitelli 2020-03-24 20:03:04 -04:00
parent 16345468e3
commit c2d87f57e5

View File

@ -21,6 +21,7 @@ import java.util.concurrent.ConcurrentLinkedDeque;
public class DownloadServiceNotification { public class DownloadServiceNotification {
private static final String TAG = "DownloadSvcNotification"; private static final String TAG = "DownloadSvcNotification";
private static final int REPORT_ID = 3; private static final int REPORT_ID = 3;
private static final int AUTO_REPORT_ID = 4;
private final Context context; private final Context context;
private NotificationCompat.Builder notificationCompatBuilder; private NotificationCompat.Builder notificationCompatBuilder;
@ -123,6 +124,7 @@ public class DownloadServiceNotification {
String channelId; String channelId;
int titleId; int titleId;
int iconId; int iconId;
int id;
PendingIntent intent; PendingIntent intent;
if (failedDownloads == 0) { if (failedDownloads == 0) {
// We are generating an auto-download report // We are generating an auto-download report
@ -130,11 +132,13 @@ public class DownloadServiceNotification {
titleId = R.string.auto_download_report_title; titleId = R.string.auto_download_report_title;
iconId = R.drawable.stat_notify_sync; iconId = R.drawable.stat_notify_sync;
intent = ClientConfig.downloadServiceCallbacks.getAutoDownloadReportNotificationContentIntent(context); intent = ClientConfig.downloadServiceCallbacks.getAutoDownloadReportNotificationContentIntent(context);
id = AUTO_REPORT_ID;
} else { } else {
channelId = NotificationUtils.CHANNEL_ID_ERROR; channelId = NotificationUtils.CHANNEL_ID_ERROR;
titleId = R.string.download_report_title; titleId = R.string.download_report_title;
iconId = R.drawable.stat_notify_sync_error; iconId = R.drawable.stat_notify_sync_error;
intent = ClientConfig.downloadServiceCallbacks.getReportNotificationContentIntent(context); intent = ClientConfig.downloadServiceCallbacks.getReportNotificationContentIntent(context);
id = REPORT_ID;
} }
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelId); NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelId);
@ -148,7 +152,7 @@ public class DownloadServiceNotification {
builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
} }
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(REPORT_ID, builder.build()); nm.notify(id, builder.build());
} else { } else {
Log.d(TAG, "No report is created"); Log.d(TAG, "No report is created");
} }