Search in sources :

Example 6 with ConfirmationDialog

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

the class StandardBolusActivity method onClick.

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

Example 7 with ConfirmationDialog

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

the class EditBRProfileActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        finish();
        return true;
    } else if (item.getItemId() == R.id.edit_br_nav_done) {
        (confirmationDialog = new ConfirmationDialog(this, HTMLUtil.getHTML(R.string.edit_br_profile_confirmation), () -> {
            showManualOverlay();
            List<ConfigurationBlock> blocks = new ArrayList<>();
            blocks.add(nameBlock);
            profileBlock.setProfileBlocks(FixedSizeProfileBlock.convertToRelative(profileBlocks));
            blocks.add(profileBlock);
            WriteConfigurationTaskRunner taskRunner = new WriteConfigurationTaskRunner(getServiceConnector(), blocks);
            showLoadingIndicator();
            taskRunner.fetch(this);
        })).show();
    } else if (item.getItemId() == R.id.edit_br_nav_edit_name) {
        EditText editName = new EditText(this);
        editName.setInputType(InputType.TYPE_CLASS_TEXT);
        editName.setFilters(new InputFilter[] { new InputFilter.LengthFilter(21) });
        editName.setText(nameBlock.getName());
        AlertDialog alertDialog = new AlertDialog.Builder(this).setTitle(R.string.edit_name).setMessage(R.string.leave_empty_for_default_value).setView(editName).setPositiveButton(R.string.okay, ((dialog, which) -> {
            nameBlock.setName(editName.getText().toString());
            adjustTitle();
        })).setNegativeButton(R.string.cancel, null).create();
        alertDialog.show();
    }
    return super.onOptionsItemSelected(item);
}
Also used : EditText(android.widget.EditText) AlertDialog(android.support.v7.app.AlertDialog) Bundle(android.os.Bundle) ConfigurationBlock(sugar.free.sightparser.applayer.descriptors.configuration_blocks.ConfigurationBlock) TaskRunner(sugar.free.sightparser.handling.TaskRunner) BRProfile4Block(sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile4Block) EditBRBlockDialog(sugar.free.sightremote.utils.EditBRBlockDialog) SerializationUtils(sugar.free.sightparser.SerializationUtils) BRProfile2Block(sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile2Block) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) BRProfileAdapter(sugar.free.sightremote.adapters.BRProfileAdapter) MaxBRAmountBlock(sugar.free.sightparser.applayer.descriptors.configuration_blocks.MaxBRAmountBlock) MenuInflater(android.view.MenuInflater) Toast(android.widget.Toast) Menu(android.view.Menu) BRProfileBlockAdapter(sugar.free.sightremote.adapters.BRProfileBlockAdapter) Status(sugar.free.sightparser.pipeline.Status) BRProfile3Block(sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile3Block) FixedSizeProfileBlock(sugar.free.sightremote.utils.FixedSizeProfileBlock) FactoryMinBRAmountBlock(sugar.free.sightparser.applayer.descriptors.configuration_blocks.FactoryMinBRAmountBlock) InputType(android.text.InputType) HTMLUtil(sugar.free.sightremote.utils.HTMLUtil) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) NameBlock(sugar.free.sightparser.applayer.descriptors.configuration_blocks.NameBlock) CustomEvent(com.crashlytics.android.answers.CustomEvent) RecyclerView(android.support.v7.widget.RecyclerView) BRProfileBlock(sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfileBlock) List(java.util.List) R(sugar.free.sightremote.R) AlertDialog(android.support.v7.app.AlertDialog) ReadConfigurationTaskRunner(sugar.free.sightparser.handling.taskrunners.ReadConfigurationTaskRunner) BRProfile5Block(sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile5Block) BRProfile1Block(sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfile1Block) Answers(com.crashlytics.android.answers.Answers) Nullable(android.support.annotation.Nullable) InputFilter(android.text.InputFilter) EditText(android.widget.EditText) WriteConfigurationTaskRunner(sugar.free.sightparser.handling.taskrunners.WriteConfigurationTaskRunner) ConfirmationDialog(sugar.free.sightremote.dialogs.ConfirmationDialog) ConfigurationBlock(sugar.free.sightparser.applayer.descriptors.configuration_blocks.ConfigurationBlock) InputFilter(android.text.InputFilter) ArrayList(java.util.ArrayList) WriteConfigurationTaskRunner(sugar.free.sightparser.handling.taskrunners.WriteConfigurationTaskRunner) 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