Example #1
0
  public synchronized void stopAlert(
      Context ctx, boolean ClearData, boolean clearIfSnoozeFinished) {

    Log.d(
        TAG,
        "stopAlert: stop called ClearData "
            + ClearData
            + "  ThreadID "
            + Thread.currentThread().getId());
    if (ClearData) {
      ActiveBgAlert.ClearData();
    }
    if (clearIfSnoozeFinished) {
      ActiveBgAlert.ClearIfSnoozeFinished();
    }
    notificationDismiss(ctx);
    if (mediaPlayer != null) {
      mediaPlayer.stop();
      mediaPlayer.release();
      mediaPlayer = null;
    }
  }
Example #2
0
  // Check the state and alrarm if needed
  public void ClockTick(Context ctx, boolean trendingToAlertEnd, String bgValue) {
    if (trendingToAlertEnd) {
      Log.d(TAG, "ClockTick: This alert is trending to it's end will not do anything");
      return;
    }
    ActiveBgAlert activeBgAlert = ActiveBgAlert.getOnly();
    if (activeBgAlert == null) {
      // Nothing to do ...
      return;
    }
    if (activeBgAlert.ready_to_alarm()) {
      stopAlert(ctx, false, false);

      int timeFromStartPlaying = activeBgAlert.getUpdatePlayTime();
      AlertType alert = AlertType.get_alert(activeBgAlert.alert_uuid);
      if (alert == null) {
        Log.w(TAG, "ClockTick: The alert was already deleted... will not play");
        ActiveBgAlert.ClearData();
        return;
      }
      Log.d(TAG, "ClockTick: Playing the alert again");
      Vibrate(ctx, alert, bgValue, alert.override_silent_mode, timeFromStartPlaying);
    }
  }