Search in sources :

Example 6 with ActiveBgAlert

use of com.eveningoutpost.dexdrip.Models.ActiveBgAlert in project xDrip by NightscoutFoundation.

the class FakeNumbers method addListenerOnButton.

public void addListenerOnButton() {
    button = (Button) findViewById(R.id.log);
    button.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            EditText value = (EditText) findViewById(R.id.bg_value);
            int intValue = Integer.parseInt(value.getText().toString());
            int filterdValue = intValue;
            if (intValue > 200) {
                filterdValue = (int) (filterdValue * 1.2);
            }
            BgReading bgReading = BgReading.create(intValue * 1000, filterdValue * 1000, getApplicationContext(), new Date().getTime());
            Intent intent = new Intent(getApplicationContext(), Home.class);
            startActivity(intent);
            finish();
        }
    });
    button = (Button) findViewById(R.id.StartTest);
    button.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            ActiveBgAlert aba = ActiveBgAlert.getOnly();
            ActiveBgAlert.ClearData();
            ActiveBgAlert.Create("some string", true, new Date().getTime());
        }
    });
    button = (Button) findViewById(R.id.StartTestAlerts);
    button.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            AlertType.testAll(getApplicationContext());
            BgReading.TestgetUnclearTimes();
        }
    });
}
Also used : EditText(android.widget.EditText) Intent(android.content.Intent) BgReading(com.eveningoutpost.dexdrip.Models.BgReading) View(android.view.View) Date(java.util.Date) ActiveBgAlert(com.eveningoutpost.dexdrip.Models.ActiveBgAlert)

Example 7 with ActiveBgAlert

use of com.eveningoutpost.dexdrip.Models.ActiveBgAlert in project xDrip-plus by jamorham.

the class FakeNumbers method addListenerOnButton.

public void addListenerOnButton() {
    button = (Button) findViewById(R.id.log);
    button.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            EditText value = (EditText) findViewById(R.id.bg_value);
            int intValue = Integer.parseInt(value.getText().toString());
            int filterdValue = intValue;
            if (intValue > 200) {
                filterdValue = (int) (filterdValue * 1.2);
            }
            BgReading bgReading = BgReading.create(intValue * 1000, filterdValue * 1000, getApplicationContext(), new Date().getTime());
            Intent intent = new Intent(getApplicationContext(), Home.class);
            startActivity(intent);
            finish();
        }
    });
    button = (Button) findViewById(R.id.StartTest);
    button.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            ActiveBgAlert aba = ActiveBgAlert.getOnly();
            ActiveBgAlert.ClearData();
            ActiveBgAlert.Create("some string", true, new Date().getTime());
        }
    });
    button = (Button) findViewById(R.id.StartTestAlerts);
    button.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            AlertType.testAll(getApplicationContext());
            BgReading.TestgetUnclearTimes();
        }
    });
}
Also used : EditText(android.widget.EditText) Intent(android.content.Intent) BgReading(com.eveningoutpost.dexdrip.Models.BgReading) View(android.view.View) Date(java.util.Date) ActiveBgAlert(com.eveningoutpost.dexdrip.Models.ActiveBgAlert)

Example 8 with ActiveBgAlert

use of com.eveningoutpost.dexdrip.Models.ActiveBgAlert in project xDrip-plus by jamorham.

the class AlertPlayer method ClockTick.

// 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()) {
        // also don't cancel notification
        stopAlert(ctx, false, 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);
    }
}
Also used : AlertType(com.eveningoutpost.dexdrip.Models.AlertType) ActiveBgAlert(com.eveningoutpost.dexdrip.Models.ActiveBgAlert)

Example 9 with ActiveBgAlert

use of com.eveningoutpost.dexdrip.Models.ActiveBgAlert in project xDrip by NightscoutFoundation.

the class AlertPlayer method PreSnooze.

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);
}
Also used : Date(java.util.Date) ActiveBgAlert(com.eveningoutpost.dexdrip.Models.ActiveBgAlert)

Example 10 with ActiveBgAlert

use of com.eveningoutpost.dexdrip.Models.ActiveBgAlert in project xDrip by NightscoutFoundation.

the class AlertPlayer method ClockTick.

// 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()) {
        // also don't cancel notification
        stopAlert(ctx, false, 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);
    }
}
Also used : AlertType(com.eveningoutpost.dexdrip.Models.AlertType) ActiveBgAlert(com.eveningoutpost.dexdrip.Models.ActiveBgAlert)

Aggregations

ActiveBgAlert (com.eveningoutpost.dexdrip.Models.ActiveBgAlert)16 AlertType (com.eveningoutpost.dexdrip.Models.AlertType)10 Date (java.util.Date)10 View (android.view.View)4 Dialog (android.app.Dialog)2 Intent (android.content.Intent)2 Button (android.widget.Button)2 EditText (android.widget.EditText)2 NumberPicker (android.widget.NumberPicker)2 TextView (android.widget.TextView)2 BgReading (com.eveningoutpost.dexdrip.Models.BgReading)2