Search in sources :

Example 1 with ConfirmationDialog

use of sugar.free.sightremote.dialogs.ConfirmationDialog in project SightRemote by TebbeUbben.

the class ChangeActiveBRProfileActivity method onProfileChange.

@Override
public void onProfileChange(int profile) {
    ActiveProfileBlock block = new ActiveProfileBlock();
    block.setActiveProfile(ActiveProfileBlock.ActiveProfile.values()[profile]);
    ArrayList<ConfigurationBlock> blocks = new ArrayList<>();
    blocks.add(block);
    WriteConfigurationTaskRunner taskRunner = new WriteConfigurationTaskRunner(getServiceConnector(), blocks);
    (confirmationDialog = new ConfirmationDialog(this, HTMLUtil.getHTML(R.string.change_br_profile_confirmation), () -> {
        taskRunner.fetch(this);
        adapter.setActiveProfile(profile);
        adapter.notifyDataSetChanged();
    }, () -> adapter.notifyDataSetChanged())).show();
}
Also used : ConfigurationBlock(sugar.free.sightparser.applayer.descriptors.configuration_blocks.ConfigurationBlock) ArrayList(java.util.ArrayList) WriteConfigurationTaskRunner(sugar.free.sightparser.handling.taskrunners.WriteConfigurationTaskRunner) ActiveProfileBlock(sugar.free.sightparser.applayer.descriptors.configuration_blocks.ActiveProfileBlock) ConfirmationDialog(sugar.free.sightremote.dialogs.ConfirmationDialog)

Example 2 with ConfirmationDialog

use of sugar.free.sightremote.dialogs.ConfirmationDialog in project SightRemote by TebbeUbben.

the class StatusActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item == startPump) {
        if (getServiceConnector().getStatus() == Status.CONNECTED) {
            SetPumpStatusMessage message = new SetPumpStatusMessage();
            message.setPumpStatus(PumpStatus.STARTED);
            SingleMessageTaskRunner taskRunner = new SingleMessageTaskRunner(getServiceConnector(), message);
            (confirmationDialog = new ConfirmationDialog(this, HTMLUtil.getHTML(R.string.start_pump_confirmation), () -> {
                startPump.setVisible(false);
                if (StatusActivity.this.taskRunner != null)
                    StatusActivity.this.taskRunner.cancel();
                taskRunner.fetch(errorToastResultCallback);
                handler.removeCallbacks(taskRunnerRunnable);
                handler.postDelayed(taskRunnerRunnable, 500);
            })).show();
        }
        return true;
    } else if (item == stopPump) {
        if (getServiceConnector().getStatus() == Status.CONNECTED) {
            SetPumpStatusMessage message = new SetPumpStatusMessage();
            message.setPumpStatus(PumpStatus.STOPPED);
            SingleMessageTaskRunner taskRunner = new SingleMessageTaskRunner(getServiceConnector(), message);
            (confirmationDialog = new ConfirmationDialog(this, HTMLUtil.getHTML(R.string.stop_pump_confirmation), () -> {
                stopPump.setVisible(false);
                if (StatusActivity.this.taskRunner != null)
                    StatusActivity.this.taskRunner.cancel();
                taskRunner.fetch(errorToastResultCallback);
                handler.removeCallbacks(taskRunnerRunnable);
                handler.postDelayed(taskRunnerRunnable, 500);
            })).show();
        }
        return true;
    }
    return super.onOptionsItemSelected(item);
}
Also used : SetPumpStatusMessage(sugar.free.sightparser.applayer.messages.remote_control.SetPumpStatusMessage) SingleMessageTaskRunner(sugar.free.sightparser.handling.SingleMessageTaskRunner) ConfirmationDialog(sugar.free.sightremote.dialogs.ConfirmationDialog)

Example 3 with ConfirmationDialog

use of sugar.free.sightremote.dialogs.ConfirmationDialog in project SightRemote by TebbeUbben.

the class ExtendedBolusActivity method onClick.

@Override
public void onClick(View view) {
    ExtendedBolusMessage message = new ExtendedBolusMessage();
    message.setAmount(bolusAmountPicker.getPickerValue());
    message.setDuration(durationPicker.getPickerValue());
    SingleMessageTaskRunner taskRunner = new SingleMessageTaskRunner(getServiceConnector(), message);
    (confirmationDialog = new ConfirmationDialog(this, HTMLUtil.getHTML(R.string.extended_bolus_confirmation, UnitFormatter.formatUnits(bolusAmountPicker.getPickerValue()), UnitFormatter.formatDuration(durationPicker.getPickerValue())), () -> {
        showLoadingIndicator();
        taskRunner.fetch(ExtendedBolusActivity.this);
    })).show();
}
Also used : ExtendedBolusMessage(sugar.free.sightparser.applayer.messages.remote_control.ExtendedBolusMessage) SingleMessageTaskRunner(sugar.free.sightparser.handling.SingleMessageTaskRunner) ConfirmationDialog(sugar.free.sightremote.dialogs.ConfirmationDialog)

Example 4 with ConfirmationDialog

use of sugar.free.sightremote.dialogs.ConfirmationDialog in project SightRemote by TebbeUbben.

the class MultiwaveBolusActivity method onClick.

@Override
public void onClick(View view) {
    MultiwaveBolusMessage message = new MultiwaveBolusMessage();
    message.setAmount(immediateBolusAmountPicker.getPickerValue());
    message.setDelayedAmount(delayedBolusAmountPicker.getPickerValue());
    message.setDuration(durationPicker.getPickerValue());
    SingleMessageTaskRunner taskRunner = new SingleMessageTaskRunner(getServiceConnector(), message);
    (confirmationDialog = new ConfirmationDialog(this, HTMLUtil.getHTML(R.string.multiwave_bolus_confirmation, UnitFormatter.formatUnits(immediateBolusAmountPicker.getPickerValue()), UnitFormatter.formatUnits(delayedBolusAmountPicker.getPickerValue()), UnitFormatter.formatDuration(durationPicker.getPickerValue())), () -> {
        showLoadingIndicator();
        taskRunner.fetch(MultiwaveBolusActivity.this);
    })).show();
}
Also used : SingleMessageTaskRunner(sugar.free.sightparser.handling.SingleMessageTaskRunner) MultiwaveBolusMessage(sugar.free.sightparser.applayer.messages.remote_control.MultiwaveBolusMessage) ConfirmationDialog(sugar.free.sightremote.dialogs.ConfirmationDialog)

Example 5 with ConfirmationDialog

use of sugar.free.sightremote.dialogs.ConfirmationDialog in project SightRemote by TebbeUbben.

the class TemporaryBasalRateActivity method onClick.

@Override
public void onClick(View v) {
    int duration = durationPicker.getPickerValue();
    int amount = percentage.getValue() * 10;
    SetTBRTaskRunner taskRunner = new SetTBRTaskRunner(getServiceConnector(), amount, duration);
    (confirmationDialog = new ConfirmationDialog(this, HTMLUtil.getHTML(R.string.tbr_confirmation, amount, UnitFormatter.formatDuration(duration)), () -> {
        showManualOverlay();
        showLoadingIndicator();
        taskRunner.fetch(TemporaryBasalRateActivity.this);
    })).show();
}
Also used : SetTBRTaskRunner(sugar.free.sightremote.taskrunners.SetTBRTaskRunner) ConfirmationDialog(sugar.free.sightremote.dialogs.ConfirmationDialog)

Aggregations

ConfirmationDialog (sugar.free.sightremote.dialogs.ConfirmationDialog)7 SingleMessageTaskRunner (sugar.free.sightparser.handling.SingleMessageTaskRunner)4 ArrayList (java.util.ArrayList)2 ConfigurationBlock (sugar.free.sightparser.applayer.descriptors.configuration_blocks.ConfigurationBlock)2 WriteConfigurationTaskRunner (sugar.free.sightparser.handling.taskrunners.WriteConfigurationTaskRunner)2 Bundle (android.os.Bundle)1 Nullable (android.support.annotation.Nullable)1 AlertDialog (android.support.v7.app.AlertDialog)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 InputFilter (android.text.InputFilter)1 InputType (android.text.InputType)1 Menu (android.view.Menu)1 MenuInflater (android.view.MenuInflater)1 MenuItem (android.view.MenuItem)1 EditText (android.widget.EditText)1 Toast (android.widget.Toast)1 Answers (com.crashlytics.android.answers.Answers)1 CustomEvent (com.crashlytics.android.answers.CustomEvent)1 List (java.util.List)1