/** * This method will be called when a list of users is posted to the EventBus. * * @param event The bus event containing a list of user objects. */ public void onEvent(BusEventGroupMembers event) { // Unregister this instance. For new push messages the new instance will be registered in // onCreate(). EventBus.getDefault().unregister(this); Log.d(TAG, event.toString()); List<User> users = event.getUsers(); // Store users in database an add them as group members to the group. UserDatabaseManager userDBM = new UserDatabaseManager(this); GroupDatabaseManager groupDBM = new GroupDatabaseManager(this); for (User u : users) { userDBM.storeUser(u); // Update users to make name changes visible. userDBM.updateUser(u); if (u.getActive() != null && u.getActive()) { groupDBM.addUserToGroup(pushMessage.getId1(), u.getId()); } else { groupDBM.removeUserFromGroup(pushMessage.getId1(), u.getId()); } } NotificationSettings notificationSettings = settingsDBM.getGroupNotificationSettings(pushMessage.getId1()); if (notificationSettings == NotificationSettings.GENERAL) { notificationSettings = settingsDBM.getSettings().getNotificationSettings(); } if (notificationSettings.equals(NotificationSettings.ALL)) { sendGroupMemberNotification(pushMessage.getId1()); } groupDBM.setGroupNewEvents(pushMessage.getId1(), true); }
/** * This method will be called when a conversation is posted to the EventBus. * * @param conversation The bus event containing a conversation object. */ public void onEvent(Conversation conversation) { // Unregister this instance. For new push messages the new instance will be registered in // onCreate(). EventBus.getDefault().unregister(this); Log.d(TAG, "EventBus:" + conversation.toString()); GroupDatabaseManager groupDBM = new GroupDatabaseManager(getApplicationContext()); groupDBM.updateConversation(conversation); groupDBM.setGroupNewEvents(pushMessage.getId1(), true); NotificationSettings notificationSettings = settingsDBM.getGroupNotificationSettings(pushMessage.getId1()); if (notificationSettings == NotificationSettings.GENERAL) { notificationSettings = settingsDBM.getSettings().getNotificationSettings(); } if (notificationSettings.equals(NotificationSettings.ALL)) { sendConversationNotification(pushMessage.getId1()); } else if (notificationSettings.equals(NotificationSettings.PRIORITY)) { if (pushMessage.getPushType().equals(PushType.CONVERSATION_NEW)) { sendConversationNotification(pushMessage.getId1()); } } }
/** * This method will be called when conversation messages are posted to the EventBus. * * @param event The bus event containing conversation message objects. */ public void onEvent(BusEventConversationMessages event) { // Unregister this instance. For new push messages the new instance will be registered in // onCreate(). EventBus.getDefault().unregister(this); Log.d(TAG, event.toString()); List<ConversationMessage> conversationMessages = event.getConversationMessages(); // Store new conversation messages in database. GroupDatabaseManager groupDBM = new GroupDatabaseManager(getApplicationContext()); for (ConversationMessage cm : conversationMessages) { groupDBM.storeConversationMessage(cm); } if (!conversationMessages.isEmpty()) { groupDBM.setGroupNewEvents(pushMessage.getId1(), true); NotificationSettings notificationSettings = settingsDBM.getGroupNotificationSettings(pushMessage.getId1()); if (notificationSettings == NotificationSettings.GENERAL) { notificationSettings = settingsDBM.getSettings().getNotificationSettings(); } if (!notificationSettings.equals(NotificationSettings.NONE)) { sendNewConversationMessageNotification(pushMessage.getId1(), pushMessage.getId2()); } } }