@Test public void testRemoveNewMailNotification() throws Exception { enablePrivacyMode(); MessageReference messageReference = createMessageReference(1); int notificationIndex = 0; int notificationId = NotificationIds.getNewMailStackedNotificationId(account, notificationIndex); LocalMessage message = createLocalMessage(); NotificationContent content = createNotificationContent(); NotificationHolder holder = createNotificationHolder(content, notificationIndex); addToNotificationContentCreator(message, content); whenAddingContentReturn(content, AddNotificationResult.newNotification(holder)); Notification summaryNotification = createNotification(); addToDeviceNotifications(summaryNotification); newMailNotifications.addNewMailNotification(account, message, 23); whenRemovingContentReturn(messageReference, RemoveNotificationResult.cancelNotification(notificationId)); newMailNotifications.removeNewMailNotification(account, messageReference); int summaryNotificationId = NotificationIds.getNewMailSummaryNotificationId(account); verify(notificationManager).cancel(notificationId); verify(notificationManager, times(2)).notify(summaryNotificationId, summaryNotification); }
public void removeNewMailNotification(Account account, MessageReference messageReference) { synchronized (lock) { NotificationData notificationData = getNotificationData(account); if (notificationData == null) { return; } RemoveNotificationResult result = notificationData.removeNotificationForMessage(messageReference); if (result.isUnknownNotification()) { return; } cancelNotification(result.getNotificationId()); if (result.shouldCreateNotification()) { createStackedNotification(account, result.getNotificationHolder()); } updateSummaryNotification(account, notificationData); } }
NewMailNotifications { public void removeNewMailNotification(Account account, MessageReference messageReference) { synchronized (lock) { NotificationData notificationData = getNotificationData(account); if (notificationData == null) { return; } RemoveNotificationResult result = notificationData.removeNotificationForMessage(messageReference); if (result.isUnknownNotification()) { return; } cancelNotification(result.getNotificationId()); if (result.shouldCreateNotification()) { createStackedNotification(account, result.getNotificationHolder()); } updateSummaryNotification(account, notificationData); } } }
NewMailNotifications { public void removeNewMailNotification(Account account, MessageReference messageReference) { synchronized (lock) { NotificationData notificationData = getNotificationData(account); if (notificationData == null) { return; } RemoveNotificationResult result = notificationData.removeNotificationForMessage(messageReference); if (result.isUnknownNotification()) { return; } cancelNotification(result.getNotificationId()); if (result.shouldCreateNotification()) { createStackedNotification(account, result.getNotificationHolder()); } updateSummaryNotification(account, notificationData); } } NewMailNotifications(NotificationController controller, NotificationContentCreator contentCreator,
            DeviceNotifications deviceNotifications, WearNotifications wearNotifications); }
NewMailNotifications { public void removeNewMailNotification(Account account, MessageReference messageReference) { synchronized (lock) { NotificationData notificationData = getNotificationData(account); if (notificationData == null) { return; } RemoveNotificationResult result = notificationData.removeNotificationForMessage(messageReference); if (result.isUnknownNotification()) { return; } cancelNotification(result.getNotificationId()); if (result.shouldCreateNotification()) { createStackedNotification(account, result.getNotificationHolder()); } updateSummaryNotification(account, notificationData); } } NewMailNotifications(NotificationController controller, NotificationContentCreator contentCreator,
            DeviceNotifications deviceNotifications, WearNotifications wearNotifications); static NewMailNotifications newInstance(NotificationController controller,
            NotificationActionCreator actionCreator); void addNewMailNotification(Account account, LocalMessage message, int unreadMessageCount); void removeNewMailNotification(Account account, MessageReference messageReference); void clearNewMailNotifications(Account account); }
NewMailNotifications { public void removeNewMailNotification(Account account, MessageReference messageReference) { synchronized (lock) { NotificationData notificationData = getNotificationData(account); if (notificationData == null) { return; } RemoveNotificationResult result = notificationData.removeNotificationForMessage(messageReference); if (result.isUnknownNotification()) { return; } cancelNotification(result.getNotificationId()); if (result.shouldCreateNotification()) { createStackedNotification(account, result.getNotificationHolder()); } updateSummaryNotification(account, notificationData); } } NewMailNotifications(NotificationController controller, NotificationContentCreator contentCreator,
            DeviceNotifications deviceNotifications, WearNotifications wearNotifications); static NewMailNotifications newInstance(NotificationController controller,
            NotificationActionCreator actionCreator); void addNewMailNotification(Account account, LocalMessage message, int unreadMessageCount); void removeNewMailNotification(Account account, MessageReference messageReference); void clearNewMailNotifications(Account account);  }