From d2ef357403c43ee4df0c453c7d0fc10ff3429dcc Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Fri, 24 Feb 2017 14:35:35 +1100 Subject: [PATCH] Invert if statement to bail early. --- .../org/fdroid/fdroid/NotificationHelper.java | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/NotificationHelper.java b/app/src/main/java/org/fdroid/fdroid/NotificationHelper.java index edee5abf7..6fedc9d95 100644 --- a/app/src/main/java/org/fdroid/fdroid/NotificationHelper.java +++ b/app/src/main/java/org/fdroid/fdroid/NotificationHelper.java @@ -189,30 +189,33 @@ class NotificationHelper { notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_INSTALLED); return; } - if (notificationManager.areNotificationsEnabled()) { - Notification notification; - if (entry.status == AppUpdateStatusManager.Status.Installed) { - if (useStackedNotifications()) { - notification = createInstalledNotification(entry); - notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_UPDATES); - notificationManager.notify(entry.getUniqueKey(), NOTIFY_ID_INSTALLED, notification); - } else if (installed.size() == 1) { - notification = createInstalledNotification(entry); - notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_UPDATES); - notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_INSTALLED); - notificationManager.notify(GROUP_INSTALLED, NOTIFY_ID_INSTALLED, notification); - } - } else { - if (useStackedNotifications()) { - notification = createUpdateNotification(entry); - notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_INSTALLED); - notificationManager.notify(entry.getUniqueKey(), NOTIFY_ID_UPDATES, notification); - } else if (updates.size() == 1) { - notification = createUpdateNotification(entry); - notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_UPDATES); - notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_INSTALLED); - notificationManager.notify(GROUP_UPDATES, NOTIFY_ID_UPDATES, notification); - } + + if (!notificationManager.areNotificationsEnabled()) { + return; + } + + Notification notification; + if (entry.status == AppUpdateStatusManager.Status.Installed) { + if (useStackedNotifications()) { + notification = createInstalledNotification(entry); + notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_UPDATES); + notificationManager.notify(entry.getUniqueKey(), NOTIFY_ID_INSTALLED, notification); + } else if (installed.size() == 1) { + notification = createInstalledNotification(entry); + notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_UPDATES); + notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_INSTALLED); + notificationManager.notify(GROUP_INSTALLED, NOTIFY_ID_INSTALLED, notification); + } + } else { + if (useStackedNotifications()) { + notification = createUpdateNotification(entry); + notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_INSTALLED); + notificationManager.notify(entry.getUniqueKey(), NOTIFY_ID_UPDATES, notification); + } else if (updates.size() == 1) { + notification = createUpdateNotification(entry); + notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_UPDATES); + notificationManager.cancel(entry.getUniqueKey(), NOTIFY_ID_INSTALLED); + notificationManager.notify(GROUP_UPDATES, NOTIFY_ID_UPDATES, notification); } } }