/**
   * Create and show a notification containing the conversations name where the new conversation
   * message was posted.
   */
  private void sendNewConversationMessageNotification(int groupId, int conversationId) {
    Intent intent;
    boolean loggedIn = Util.getInstance(this).getLoggedInModerator() != null;
    if (loggedIn) {
      // User is logged in as local moderator.
      intent = new Intent(this, ModeratorMainActivity.class);
    } else {
      // User isn't logged in.
      intent = new Intent(this, GroupActivity.class);
    }
    intent.putExtra("groupId", groupId);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    // Create a PendingIntent containing the entire back stack.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    if (loggedIn) {
      stackBuilder.addParentStack(ModeratorMainActivity.class);
    } else {
      stackBuilder.addParentStack(GroupActivity.class);
    }
    stackBuilder.addNextIntent(intent);
    PendingIntent pendingIntent =
        stackBuilder.getPendingIntent(groupId, PendingIntent.FLAG_UPDATE_CURRENT);

    // Set group icon as large icon.
    Conversation conversation =
        new GroupDatabaseManager(getApplicationContext()).getConversation(conversationId);
    Bitmap bitmap =
        BitmapFactory.decodeResource(
            getResources(),
            GroupController.getConversationIcon(conversation, getApplicationContext()));
    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder =
        new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_stat_notification_icon_1)
            .setColor(ContextCompat.getColor(this, R.color.uni_main_primary))
            .setLargeIcon(bitmap)
            .setContentTitle(
                String.format(
                    getString(R.string.push_message_conversation), conversation.getTitle()))
            .setAutoCancel(true)
            .setSound(defaultSoundUri)
            .setContentIntent(pendingIntent);

    if (conversation.getNumberOfUnreadConversationMessages() > 1) {
      notificationBuilder.setContentText(
          getString(R.string.push_message_new_conversation_messages));
      notificationBuilder.setNumber(conversation.getNumberOfUnreadConversationMessages());
    } else {
      notificationBuilder.setContentText(getString(R.string.push_message_new_conversation_message));
    }

    NotificationManager notificationManager =
        (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(5, notificationBuilder.build());
  }
 /**
  * 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());
     }
   }
 }