Java Code Examples for com.eveningoutpost.dexdrip.Models.AlertType#get_alert()

The following examples show how to use com.eveningoutpost.dexdrip.Models.AlertType#get_alert() . 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: Notifications.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private long calcuatleArmTimeBg(long now) {
    Long wakeTimeBg = Long.MAX_VALUE;
    ActiveBgAlert activeBgAlert = ActiveBgAlert.getOnly();
    if (activeBgAlert != null) {
        AlertType alert = AlertType.get_alert(activeBgAlert.alert_uuid);
        if (alert != null) {
            wakeTimeBg = activeBgAlert.next_alert_at ;
            Log.d(TAG , "ArmTimer BG alert -waking at: "+ new Date(wakeTimeBg) +" in " +  (wakeTimeBg - now)/60000d + " minutes");
            if (wakeTimeBg < now) {
                // next alert should be at least one minute from now.
                wakeTimeBg = now + 60000;
                Log.w(TAG , "setting next alert to 1 minute from now (no problem right now, but needs a fix someplace else)");
            }
            
        }
    }
    Log.d("Notifications" , "calcuatleArmTimeBg returning: "+ new Date(wakeTimeBg) +" in " +  (wakeTimeBg - now)/60000d + " minutes");
    return wakeTimeBg;
}
 
Example 2
Source File: Notifications.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private long calcuatleArmTimeBg(long now) {
    Long wakeTimeBg = Long.MAX_VALUE;
    ActiveBgAlert activeBgAlert = ActiveBgAlert.getOnly();
    if (activeBgAlert != null) {
        AlertType alert = AlertType.get_alert(activeBgAlert.alert_uuid);
        if (alert != null) {
            wakeTimeBg = activeBgAlert.next_alert_at ;
            Log.d(TAG , "ArmTimer BG alert -waking at: "+ new Date(wakeTimeBg) +" in " +  (wakeTimeBg - now)/60000d + " minutes");
            if (wakeTimeBg < now) {
                // next alert should be at least one minute from now.
                wakeTimeBg = now + 60000;
                Log.w(TAG , "setting next alert to 1 minute from now (no problem right now, but needs a fix someplace else)");
            }
            
        }
    }
    Log.d("Notifications" , "calcuatleArmTimeBg returning: "+ new Date(wakeTimeBg) +" in " +  (wakeTimeBg - now)/60000d + " minutes");
    return wakeTimeBg;
}
 
Example 3
Source File: Notifications.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private long calcuatleArmTimeBg(long now) {
    Long wakeTimeBg = Long.MAX_VALUE;
    ActiveBgAlert activeBgAlert = ActiveBgAlert.getOnly();
    if (activeBgAlert != null) {
        AlertType alert = AlertType.get_alert(activeBgAlert.alert_uuid);
        if (alert != null) {
            wakeTimeBg = activeBgAlert.next_alert_at ;
            Log.d(TAG , "ArmTimer BG alert -waking at: "+ new Date(wakeTimeBg) +" in " +  (wakeTimeBg - now)/60000d + " minutes");
            if (wakeTimeBg < now) {
                // next alert should be at least one minute from now.
                wakeTimeBg = now + 60000;
                Log.w(TAG , "setting next alert to 1 minute from now (no problem right now, but needs a fix someplace else)");
            }
            
        }
    }
    Log.d("Notifications" , "calcuatleArmTimeBg returning: "+ new Date(wakeTimeBg) +" in " +  (wakeTimeBg - now)/60000d + " minutes");
    return wakeTimeBg;
}
 
Example 4
Source File: Notifications.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private long calcuatleArmTimeBg(long now) {
    Long wakeTimeBg = Long.MAX_VALUE;
    ActiveBgAlert activeBgAlert = ActiveBgAlert.getOnly();
    if (activeBgAlert != null) {
        AlertType alert = AlertType.get_alert(activeBgAlert.alert_uuid);
        if (alert != null) {
            wakeTimeBg = activeBgAlert.next_alert_at ;
            Log.d(TAG , "ArmTimer BG alert -waking at: "+ new Date(wakeTimeBg) +" in " +  (wakeTimeBg - now)/60000d + " minutes");
            if (wakeTimeBg < now) {
                // next alert should be at least one minute from now.
                wakeTimeBg = now + 60000;
                Log.w(TAG , "setting next alert to 1 minute from now (no problem right now, but needs a fix someplace else)");
            }
            
        }
    }
    Log.d("Notifications" , "calcuatleArmTimeBg returning: "+ new Date(wakeTimeBg) +" in " +  (wakeTimeBg - now)/60000d + " minutes");
    return wakeTimeBg;
}
 
Example 5
Source File: Notifications.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
private long calcuatleArmTimeBg(long now) {
    Long wakeTimeBg = Long.MAX_VALUE;
    ActiveBgAlert activeBgAlert = ActiveBgAlert.getOnly();
    if (activeBgAlert != null) {
        AlertType alert = AlertType.get_alert(activeBgAlert.alert_uuid);
        if (alert != null) {
            wakeTimeBg = activeBgAlert.next_alert_at ;
            Log.d(TAG , "ArmTimer BG alert -waking at: "+ new Date(wakeTimeBg) +" in " +  (wakeTimeBg - now)/60000d + " minutes");
            if (wakeTimeBg < now) {
                // next alert should be at least one minute from now.
                wakeTimeBg = now + 60000;
                Log.w(TAG , "setting next alert to 1 minute from now (no problem right now, but needs a fix someplace else)");
            }
            
        }
    }
    Log.d("Notifications" , "calcuatleArmTimeBg returning: "+ new Date(wakeTimeBg) +" in " +  (wakeTimeBg - now)/60000d + " minutes");
    return wakeTimeBg;
}
 
Example 6
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 7
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 8
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 9
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 10
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);
    }

}
 
Example 11
Source File: ListenerService.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
private void syncAlertTypeData(DataMap dataMap, Context context) {//KS
    Log.d(TAG, "syncAlertTypeData");

    ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
    if (entries != null) {

        Gson gson = new GsonBuilder()
                .excludeFieldsWithoutExposeAnnotation()
                .registerTypeAdapter(Date.class, new DateTypeAdapter())
                .serializeSpecialFloatingPointValues()
                .create();

        Log.d(TAG, "syncAlertTypeData add AlertType Table entries count=" + entries.size());
        Sensor.InitDb(context);//ensure database has already been initialized
        AlertType.remove_all();
        for (DataMap entry : entries) {
            if (entry != null) {
                String alertrecord = entry.getString("alert");
                if (alertrecord != null) {
                    AlertType data = gson.fromJson(alertrecord, AlertType.class);
                    AlertType exists = AlertType.get_alert(data.uuid);
                    if (exists != null) {
                        Log.d(TAG, "syncAlertTypeData AlertType exists for uuid=" + data.uuid + " name=" + data.name);
                        exists.name = data.name;
                        exists.active = data.active;
                        exists.volume = data.volume;
                        exists.vibrate = data.vibrate;
                        exists.light = data.light;
                        exists.override_silent_mode = data.override_silent_mode;
                        exists.predictive = data.predictive;
                        exists.time_until_threshold_crossed = data.time_until_threshold_crossed;
                        exists.above= data.above;
                        exists.threshold = data.threshold;
                        exists.all_day = data.all_day;
                        exists.start_time_minutes = data.start_time_minutes;
                        exists.end_time_minutes = data.end_time_minutes;
                        exists.minutes_between = data.minutes_between;
                        exists.default_snooze = data.default_snooze;
                        exists.text = data.text;
                        exists.mp3_file = data.mp3_file;
                        exists.save();
                    }
                    else {
                        data.save();
                        Log.d(TAG, "syncAlertTypeData AlertType does not exist for uuid=" + data.uuid);
                    }
                    exists = AlertType.get_alert(data.uuid);
                    if (exists != null)
                        Log.d(TAG, "syncAlertTypeData AlertType GSON saved BG: " + exists.toS());
                    else
                        Log.d(TAG, "syncAlertTypeData AlertType GSON NOT saved");
                }
            }
        }
    }
}
 
Example 12
Source File: ListenerService.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
private void syncAlertTypeData(DataMap dataMap, Context context) {//KS
    Log.d(TAG, "syncAlertTypeData");

    ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
    if (entries != null) {

        Gson gson = new GsonBuilder()
                .excludeFieldsWithoutExposeAnnotation()
                .registerTypeAdapter(Date.class, new DateTypeAdapter())
                .serializeSpecialFloatingPointValues()
                .create();

        Log.d(TAG, "syncAlertTypeData add AlertType Table entries count=" + entries.size());
        Sensor.InitDb(context);//ensure database has already been initialized
        AlertType.remove_all();
        for (DataMap entry : entries) {
            if (entry != null) {
                String alertrecord = entry.getString("alert");
                if (alertrecord != null) {
                    AlertType data = gson.fromJson(alertrecord, AlertType.class);
                    AlertType exists = AlertType.get_alert(data.uuid);
                    if (exists != null) {
                        Log.d(TAG, "syncAlertTypeData AlertType exists for uuid=" + data.uuid + " name=" + data.name);
                        exists.name = data.name;
                        exists.active = data.active;
                        exists.volume = data.volume;
                        exists.vibrate = data.vibrate;
                        exists.light = data.light;
                        exists.override_silent_mode = data.override_silent_mode;
                        exists.predictive = data.predictive;
                        exists.time_until_threshold_crossed = data.time_until_threshold_crossed;
                        exists.above= data.above;
                        exists.threshold = data.threshold;
                        exists.all_day = data.all_day;
                        exists.start_time_minutes = data.start_time_minutes;
                        exists.end_time_minutes = data.end_time_minutes;
                        exists.minutes_between = data.minutes_between;
                        exists.default_snooze = data.default_snooze;
                        exists.text = data.text;
                        exists.mp3_file = data.mp3_file;
                        exists.save();
                    }
                    else {
                        data.save();
                        Log.d(TAG, "syncAlertTypeData AlertType does not exist for uuid=" + data.uuid);
                    }
                    exists = AlertType.get_alert(data.uuid);
                    if (exists != null)
                        Log.d(TAG, "syncAlertTypeData AlertType GSON saved BG: " + exists.toS());
                    else
                        Log.d(TAG, "syncAlertTypeData AlertType GSON NOT saved");
                }
            }
        }
    }
}