コード例 #1
0
ファイル: AlertPlayer.java プロジェクト: bklinker/NightWatch
 public synchronized void PreSnooze(Context ctx, String uuid, int repeatTime) {
   Log.i(TAG, "PreSnooze called repeatTime = " + repeatTime);
   stopAlert(ctx, true, false);
   ActiveBgAlert.Create(uuid, true, new Date().getTime() + repeatTime * 60000);
   ActiveBgAlert activeBgAlert = ActiveBgAlert.getOnly();
   if (activeBgAlert == null) {
     Log.wtf(TAG, "Just created the alert, where did it go...");
     return;
   }
   activeBgAlert.snooze(repeatTime);
 }
コード例 #2
0
ファイル: AlertPlayer.java プロジェクト: bklinker/NightWatch
 public synchronized void Snooze(Context ctx, int repeatTime) {
   Log.i(TAG, "Snooze called repeatTime = " + repeatTime);
   stopAlert(ctx, false, false);
   ActiveBgAlert activeBgAlert = ActiveBgAlert.getOnly();
   if (activeBgAlert == null) {
     Log.w(
         TAG,
         "Error, snooze was called but no alert is active. alert was probably removed in ui ");
     return;
   }
   activeBgAlert.snooze(repeatTime);
 }
コード例 #3
0
ファイル: AlertPlayer.java プロジェクト: bklinker/NightWatch
  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;
    }
  }
コード例 #4
0
  void displayStatus() {
    ActiveBgAlert aba = ActiveBgAlert.getOnly();
    AlertType activeBgAlert = ActiveBgAlert.alertTypegetOnly();

    // aba and activeBgAlert should both either exist ot not exist. all other cases are a bug in
    // another place
    if (aba == null && activeBgAlert != null) {
      UserError.Log.wtf(
          TAG, "ERRRO displayStatus: aba == null, but activeBgAlert != null exiting...");
      return;
    }
    if (aba != null && activeBgAlert == null) {
      UserError.Log.wtf(
          TAG, "ERRRO displayStatus: aba != null, but activeBgAlert == null exiting...");
      return;
    }
    String status;
    if (activeBgAlert == null) {
      status = "No active alert exists";
      alertStatus.setText(status);
      buttonSnooze.setVisibility(View.GONE);
      snoozeValue.setVisibility(View.GONE);
    } else {
      if (!aba.ready_to_alarm()) {
        status =
            "Active alert exists named \""
                + activeBgAlert.name
                + "\" Alert snoozed until "
                + DateFormat.getTimeInstance(DateFormat.MEDIUM).format(new Date(aba.next_alert_at))
                + " ("
                + (aba.next_alert_at - new Date().getTime()) / 60000
                + " minutes left)";
      } else {
        status = "Active alert exists named \"" + activeBgAlert.name + "\" (not snoozed)";
      }
      SetSnoozePickerValues(snoozeValue, activeBgAlert.above, activeBgAlert.default_snooze);
      alertStatus.setText(status);
    }
  }
コード例 #5
0
ファイル: AlertPlayer.java プロジェクト: bklinker/NightWatch
  // 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);
    }
  }
コード例 #6
0
ファイル: AlertPlayer.java プロジェクト: bklinker/NightWatch
  public synchronized void startAlert(
      Context ctx, boolean trendingToAlertEnd, AlertType newAlert, String bgValue) {
    Log.d(TAG, "startAlert called, Threadid " + Thread.currentThread().getId());
    if (trendingToAlertEnd) {
      Log.d(TAG, "startAlert: This alert is trending to it's end will not do anything");
      return;
    }

    stopAlert(ctx, true, false);
    int alertIn = newAlert.minutes_between;
    if (alertIn < 1) {
      alertIn = 1;
    }
    ActiveBgAlert.Create(newAlert.uuid, false, new Date().getTime() + alertIn * 60000);
    Vibrate(ctx, newAlert, bgValue, newAlert.override_silent_mode, 0);
  }