@Test public void createCommaSeparatedListOfSenders_withMoreSendersThanShouldBeDisplayed() throws Exception { NotificationContent content1 = createNotificationContent("alice@example.com"); NotificationContent content2 = createNotificationContent("bob@example.com"); NotificationContent content3 = createNotificationContent("cloe@example.com"); NotificationContent content4 = createNotificationContent("dagobert@example.com"); NotificationContent content5 = createNotificationContent("ed@example.com"); NotificationContent content6 = createNotificationContent("fiona@example.com"); String result = lockScreenNotification.createCommaSeparatedListOfSenders( Arrays.asList(content1, content2, content3, content4, content5, content6)); assertEquals( "alice@example.com, bob@example.com, cloe@example.com, dagobert@example.com, ed@example.com", result); }
String createCommaSeparatedListOfSenders(List<NotificationContent> contents) { Set<CharSequence> senders = new LinkedHashSet<CharSequence>(MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION); for (NotificationContent content : contents) { senders.add(content.sender); if (senders.size() == MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION) { break; } } return TextUtils.join(", ", senders); }
LockScreenNotification { String createCommaSeparatedListOfSenders(List<NotificationContent> contents) { Set<CharSequence> senders = new LinkedHashSet<CharSequence>(MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION); for (NotificationContent content : contents) { senders.add(content.sender); if (senders.size() == MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION) { break; } } return TextUtils.join(", ", senders); } }
LockScreenNotification { String createCommaSeparatedListOfSenders(List<NotificationContent> contents) { Set<CharSequence> senders = new LinkedHashSet<CharSequence>(MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION); for (NotificationContent content : contents) { senders.add(content.sender); if (senders.size() == MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION) { break; } } return TextUtils.join(", ", senders); } LockScreenNotification(NotificationController controller); }
LockScreenNotification { String createCommaSeparatedListOfSenders(List<NotificationContent> contents) { Set<CharSequence> senders = new LinkedHashSet<CharSequence>(MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION); for (NotificationContent content : contents) { senders.add(content.sender); if (senders.size() == MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION) { break; } } return TextUtils.join(", ", senders); } LockScreenNotification(NotificationController controller); static LockScreenNotification newInstance(NotificationController controller); void configureLockScreenNotification(Builder builder, NotificationData notificationData); }
LockScreenNotification { String createCommaSeparatedListOfSenders(List<NotificationContent> contents) { Set<CharSequence> senders = new LinkedHashSet<CharSequence>(MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION); for (NotificationContent content : contents) { senders.add(content.sender); if (senders.size() == MAX_NUMBER_OF_SENDERS_IN_LOCK_SCREEN_NOTIFICATION) { break; } } return TextUtils.join(", ", senders); } LockScreenNotification(NotificationController controller); static LockScreenNotification newInstance(NotificationController controller); void configureLockScreenNotification(Builder builder, NotificationData notificationData);  }