Пример #1
0
  /**
   * Cancel the last message sent for the given messageType
   *
   * @param messageType
   * @throws NotificationServiceException
   */
  public void deleteLastMessage(NotificationMessageType messageType)
      throws NotificationServiceException {

    TransportChannelObject senderChannel = transportSenderChannels.get(messageType);
    if (senderChannel == null) {
      throw new NotificationServiceException(
          "Received an unknown message type: '"
              + messageType
              + "', can't find a transport channel to delete the notification");
    }

    // delete the last message of this messageType
    senderChannel.deleteNotification();
  } // deleteLastMessage
Пример #2
0
  /** @param notifId The notification id of the notification message to be deleted */
  private void deleteNotificationById(int notifId) {

    GenericLogger logger = nativePlatform.getNativeLogger();
    logger.debug(
        TAG,
        "Trying to delete the notification by id: '"
            + notifId
            + "', searching for the relevant object");

    boolean isObjFound = false;

    for (TransportChannelObject channelObj : transportSenderChannels.values()) {

      channelObj.acquireLock(); // Lock the object to prevent changing its
      // state

      Integer chanObjNotifId = channelObj.getNotificationId();

      if (chanObjNotifId != null && chanObjNotifId == notifId) { // Found
        // the
        // object
        // to be
        // cancelled
        logger.debug(TAG, "Found the object with notifId: '" + notifId + "' to be cancelled");
        channelObj.deleteNotification();
        isObjFound = true;
        channelObj.releaseLock(); // release the lock
        break;
      } else {
        channelObj.releaseLock(); // release the lock and continue
        // iterating
      }
    }

    if (!isObjFound) {
      logger.debug(TAG, "Failed to find the Notification with Id: '" + notifId + "'");
    }
  }