@Test public void testMarkMessagesRead() throws InterruptedException { HashSet<String> markedReadIds = new HashSet<>(); markedReadIds.add("1_message_id"); markedReadIds.add("3_message_id"); markedReadIds.add("6_message_id"); inbox.markMessagesRead(markedReadIds); assertEquals(3, inbox.getReadCount()); assertEquals(10, inbox.getCount()); assertEquals(7, inbox.getUnreadCount()); assertEquals(3, inbox.getReadCount()); Map<String, Message> readMessages = createIdToMessageMap(inbox.getReadMessages()); Map<String, Message> unreadMessages = createIdToMessageMap(inbox.getUnreadMessages()); for (String readId : markedReadIds) { assertTrue(readMessages.containsKey(readId)); assertFalse(unreadMessages.containsKey(readId)); } }
public void markMessagesRead(@NonNull final Set<String> messageIds) { executor.execute(new Runnable() { @Override public void run() { messageCenterResolver.markMessagesRead(messageIds); } }); synchronized (inboxLock) { for (String messageId : messageIds) { Message message = unreadMessages.get(messageId); if (message != null) { message.unreadClient = false; unreadMessages.remove(messageId); readMessages.put(messageId, message); } } notifyInboxUpdated(); } }
Inbox { public void markMessagesRead(@NonNull final Set<String> messageIds) { executor.execute(new Runnable() { @Override public void run() { messageCenterResolver.markMessagesRead(messageIds); } }); synchronized (inboxLock) { for (String messageId : messageIds) { Message message = unreadMessages.get(messageId); if (message != null) { message.unreadClient = false; unreadMessages.remove(messageId); readMessages.put(messageId, message); } } notifyInboxUpdated(); } } }
Inbox { public void markMessagesRead(@NonNull final Set<String> messageIds) { executor.execute(new Runnable() { @Override public void run() { messageCenterResolver.markMessagesRead(messageIds); } }); synchronized (inboxLock) { for (String messageId : messageIds) { Message message = unreadMessages.get(messageId); if (message != null) { message.unreadClient = false; unreadMessages.remove(messageId); readMessages.put(messageId, message); } } notifyInboxUpdated(); } } Inbox(@NonNull Context context, @NonNull PreferenceDataStore dataStore,
                 @NonNull AirshipChannel airshipChannel); @VisibleForTesting  Inbox(@NonNull Context context, @NonNull PreferenceDataStore dataStore, @NonNull final JobDispatcher jobDispatcher,
          @NonNull User user, @NonNull MessageCenterResolver resolver, @NonNull Executor executor,
          @NonNull ActivityMonitor activityMonitor, @NonNull AirshipChannel airshipChannel); }
Inbox { public void markMessagesRead(@NonNull final Set<String> messageIds) { executor.execute(new Runnable() { @Override public void run() { messageCenterResolver.markMessagesRead(messageIds); } }); synchronized (inboxLock) { for (String messageId : messageIds) { Message message = unreadMessages.get(messageId); if (message != null) { message.unreadClient = false; unreadMessages.remove(messageId); readMessages.put(messageId, message); } } notifyInboxUpdated(); } } Inbox(@NonNull Context context, @NonNull PreferenceDataStore dataStore,
                 @NonNull AirshipChannel airshipChannel); @VisibleForTesting  Inbox(@NonNull Context context, @NonNull PreferenceDataStore dataStore, @NonNull final JobDispatcher jobDispatcher,
          @NonNull User user, @NonNull MessageCenterResolver resolver, @NonNull Executor executor,
          @NonNull ActivityMonitor activityMonitor, @NonNull AirshipChannel airshipChannel); @NonNull User getUser(); void addListener(@NonNull InboxListener listener); void removeListener(@NonNull InboxListener listener); void fetchMessages(); @Nullable Cancelable fetchMessages(@Nullable FetchMessagesCallback callback); @Nullable Cancelable fetchMessages(@Nullable Looper looper, @Nullable FetchMessagesCallback callback); int getCount(); @NonNull Set<String> getMessageIds(); int getReadCount(); int getUnreadCount(); @NonNull List<Message> getMessages(@Nullable Predicate<Message> predicate); @NonNull List<Message> getMessages(); @NonNull List<Message> getUnreadMessages(@Nullable Predicate<Message> predicate); @NonNull List<Message> getUnreadMessages(); @NonNull List<Message> getReadMessages(@Nullable Predicate<Message> predicate); @NonNull List<Message> getReadMessages(); @Nullable Message getMessage(@Nullable String messageId); @Nullable Message getMessageByUrl(@Nullable String messageUrl); void markMessagesRead(@NonNull final Set<String> messageIds); void markMessagesUnread(@NonNull final Set<String> messageIds); void deleteMessages(@NonNull final Set<String> messageIds); }
Inbox { public void markMessagesRead(@NonNull final Set<String> messageIds) { executor.execute(new Runnable() { @Override public void run() { messageCenterResolver.markMessagesRead(messageIds); } }); synchronized (inboxLock) { for (String messageId : messageIds) { Message message = unreadMessages.get(messageId); if (message != null) { message.unreadClient = false; unreadMessages.remove(messageId); readMessages.put(messageId, message); } } notifyInboxUpdated(); } } Inbox(@NonNull Context context, @NonNull PreferenceDataStore dataStore,
                 @NonNull AirshipChannel airshipChannel); @VisibleForTesting  Inbox(@NonNull Context context, @NonNull PreferenceDataStore dataStore, @NonNull final JobDispatcher jobDispatcher,
          @NonNull User user, @NonNull MessageCenterResolver resolver, @NonNull Executor executor,
          @NonNull ActivityMonitor activityMonitor, @NonNull AirshipChannel airshipChannel); @NonNull User getUser(); void addListener(@NonNull InboxListener listener); void removeListener(@NonNull InboxListener listener); void fetchMessages(); @Nullable Cancelable fetchMessages(@Nullable FetchMessagesCallback callback); @Nullable Cancelable fetchMessages(@Nullable Looper looper, @Nullable FetchMessagesCallback callback); int getCount(); @NonNull Set<String> getMessageIds(); int getReadCount(); int getUnreadCount(); @NonNull List<Message> getMessages(@Nullable Predicate<Message> predicate); @NonNull List<Message> getMessages(); @NonNull List<Message> getUnreadMessages(@Nullable Predicate<Message> predicate); @NonNull List<Message> getUnreadMessages(); @NonNull List<Message> getReadMessages(@Nullable Predicate<Message> predicate); @NonNull List<Message> getReadMessages(); @Nullable Message getMessage(@Nullable String messageId); @Nullable Message getMessageByUrl(@Nullable String messageUrl); void markMessagesRead(@NonNull final Set<String> messageIds); void markMessagesUnread(@NonNull final Set<String> messageIds); void deleteMessages(@NonNull final Set<String> messageIds);  }