Java Code Examples for com.eveningoutpost.dexdrip.Models.ActiveBgAlert#updateNextAlertAt()

The following examples show how to use com.eveningoutpost.dexdrip.Models.ActiveBgAlert#updateNextAlertAt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AlertPlayer.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
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, false); // also don't cancel notification

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

}
 
Example 2
Source File: AlertPlayer.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
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, false); // also don't cancel notification

        final int minutesFromStartPlaying = activeBgAlert.getAndUpdateAlertingMinutes();
        final AlertType alert = AlertType.get_alert(activeBgAlert.alert_uuid);
        if (alert == null) {
            Log.d(TAG, "ClockTick: The alert was already deleted... will not play");
            ActiveBgAlert.ClearData();
            return;
        }
        Log.d(TAG,"ClockTick: Playing the alert again");
        long nextAlertTime = alert.getNextAlertTime(ctx);
        activeBgAlert.updateNextAlertAt(nextAlertTime);
        
        VibrateNotifyMakeNoise(ctx, alert, bgValue, minutesFromStartPlaying);
        AlertTracker.evaluate();
    }

}
 
Example 3
Source File: AlertPlayer.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
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, false); // also don't cancel notification

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

}
 
Example 4
Source File: AlertPlayer.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
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, false); // also don't cancel notification

        final int minutesFromStartPlaying = activeBgAlert.getAndUpdateAlertingMinutes();
        final AlertType alert = AlertType.get_alert(activeBgAlert.alert_uuid);
        if (alert == null) {
            Log.d(TAG, "ClockTick: The alert was already deleted... will not play");
            ActiveBgAlert.ClearData();
            return;
        }
        Log.d(TAG,"ClockTick: Playing the alert again");
        long nextAlertTime = alert.getNextAlertTime(ctx);
        activeBgAlert.updateNextAlertAt(nextAlertTime);
        
        VibrateNotifyMakeNoise(ctx, alert, bgValue, minutesFromStartPlaying);
        AlertTracker.evaluate();
    }

}
 
Example 5
Source File: AlertPlayer.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
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.d(TAG, "ClockTick: The alert was already deleted... will not play");
            ActiveBgAlert.ClearData();
            return;
        }
        Log.d(TAG,"ClockTick: Playing the alert again");
        long nextAlertTime = alert.getNextAlertTime(ctx);
        activeBgAlert.updateNextAlertAt(nextAlertTime);
        
        Vibrate(ctx, alert, bgValue, alert.override_silent_mode, timeFromStartPlaying);
    }

}