Search in sources :

Example 26 with NumberPicker

use of android.widget.NumberPicker in project Talon-for-Twitter by klinker24.

the class ConfigurePagerActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case android.R.id.home:
            onBackPressed();
            return true;
        case R.id.menu_select_number_of_pages:
            final NumberPicker picker = new NumberPicker(context);
            FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            picker.setLayoutParams(params);
            picker.setMaxValue(TimelinePagerAdapter.MAX_EXTRA_PAGES);
            picker.setMinValue(0);
            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.setTitle(R.string.menu_number_of_pages);
            builder.setView(picker);
            builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    sharedPrefs.edit().putInt("number_of_extra_pages", picker.getValue()).commit();
                    dialog.dismiss();
                    recreate();
                }
            });
            builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
            builder.create().show();
            return true;
        default:
            return true;
    }
}
Also used : AlertDialog(android.app.AlertDialog) NumberPicker(android.widget.NumberPicker) DialogInterface(android.content.DialogInterface) FrameLayout(android.widget.FrameLayout)

Example 27 with NumberPicker

use of android.widget.NumberPicker in project collect by opendatakit.

the class NumberPickerDialog method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.number_picker_dialog, null);
    final NumberPicker numberPicker = view.findViewById(R.id.number_picker);
    numberPicker.setMaxValue(((String[]) getArguments().getSerializable(DISPLAYED_VALUES)).length - 1);
    numberPicker.setMinValue(0);
    numberPicker.setWrapSelectorWheel(false);
    numberPicker.setDisplayedValues((String[]) getArguments().getSerializable(DISPLAYED_VALUES));
    numberPicker.setValue(((String[]) getArguments().getSerializable(DISPLAYED_VALUES)).length - 1 - getArguments().getInt(PROGRESS));
    return new MaterialAlertDialogBuilder(getActivity()).setTitle(R.string.number_picker_title).setView(view).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            listener.onNumberPickerValueSelected(getArguments().getInt(WIDGET_ID), numberPicker.getValue());
        }
    }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
        }
    }).create();
}
Also used : NumberPicker(android.widget.NumberPicker) DialogInterface(android.content.DialogInterface) LayoutInflater(android.view.LayoutInflater) View(android.view.View) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder)

Example 28 with NumberPicker

use of android.widget.NumberPicker in project xDrip by NightscoutFoundation.

the class EditAlertActivity method setDefaultSnoozeSpinner.

public void setDefaultSnoozeSpinner(int defaultSnooze) {
    editSnooze.setText(String.valueOf(defaultSnooze));
    editSnooze.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View mView, MotionEvent mMotionEvent) {
            if (mMotionEvent.getAction() == MotionEvent.ACTION_DOWN) {
                final Dialog d = new Dialog(mContext);
                d.setTitle("Default Snooze");
                d.setContentView(R.layout.snooze_picker);
                Button b1 = (Button) d.findViewById(R.id.button1);
                Button b2 = (Button) d.findViewById(R.id.button2);
                final NumberPicker snoozeValue = (NumberPicker) d.findViewById(R.id.numberPicker1);
                int defaultSnooze = safeGetDefaultSnooze();
                SnoozeActivity.SetSnoozePickerValues(snoozeValue, above, defaultSnooze);
                b1.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        int defaultSnooze = SnoozeActivity.getTimeFromSnoozeValue(snoozeValue.getValue());
                        editSnooze.setText(String.valueOf(defaultSnooze));
                        d.dismiss();
                    }
                });
                b2.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        d.dismiss();
                    }
                });
                d.show();
            }
            return false;
        }
    });
}
Also used : NumberPicker(android.widget.NumberPicker) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) AlertDialog(android.app.AlertDialog) TimePickerDialog(android.app.TimePickerDialog) Dialog(android.app.Dialog) View(android.view.View) TextView(android.widget.TextView) Paint(android.graphics.Paint) MotionEvent(android.view.MotionEvent)

Example 29 with NumberPicker

use of android.widget.NumberPicker in project xDrip-plus by jamorham.

the class EditAlertActivity method setPreSnoozeSpinner.

public void setPreSnoozeSpinner() {
    buttonPreSnooze.setOnClickListener(new View.OnClickListener() {

        @Override
        public // public boolean onTouch(View mView, MotionEvent mMotionEvent) {
        void onClick(View v) {
            final Dialog d = new Dialog(mContext);
            d.setTitle("Snooze this alert...");
            d.setContentView(R.layout.snooze_picker);
            Button b1 = (Button) d.findViewById(R.id.button1);
            Button b2 = (Button) d.findViewById(R.id.button2);
            b1.setText("pre-Snooze");
            final NumberPicker snoozeValue = (NumberPicker) d.findViewById(R.id.numberPicker1);
            int defaultSnooze = safeGetDefaultSnooze();
            SnoozeActivity.SetSnoozePickerValues(snoozeValue, above, defaultSnooze);
            b1.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    int intValue = SnoozeActivity.getTimeFromSnoozeValue(snoozeValue.getValue());
                    AlertPlayer.getPlayer().PreSnooze(getApplicationContext(), uuid, intValue);
                    d.dismiss();
                }
            });
            b2.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    d.dismiss();
                }
            });
            d.show();
        }
    });
}
Also used : NumberPicker(android.widget.NumberPicker) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) AlertDialog(android.app.AlertDialog) TimePickerDialog(android.app.TimePickerDialog) Dialog(android.app.Dialog) View(android.view.View) TextView(android.widget.TextView) Paint(android.graphics.Paint)

Example 30 with NumberPicker

use of android.widget.NumberPicker in project xDrip by NightscoutFoundation.

the class EditAlertActivity method setPreSnoozeSpinner.

public void setPreSnoozeSpinner() {
    buttonPreSnooze.setOnClickListener(new View.OnClickListener() {

        @Override
        public // public boolean onTouch(View mView, MotionEvent mMotionEvent) {
        void onClick(View v) {
            final Dialog d = new Dialog(mContext);
            d.setTitle("Snooze this alert...");
            d.setContentView(R.layout.snooze_picker);
            Button b1 = (Button) d.findViewById(R.id.button1);
            Button b2 = (Button) d.findViewById(R.id.button2);
            b1.setText("pre-Snooze");
            final NumberPicker snoozeValue = (NumberPicker) d.findViewById(R.id.numberPicker1);
            int defaultSnooze = safeGetDefaultSnooze();
            SnoozeActivity.SetSnoozePickerValues(snoozeValue, above, defaultSnooze);
            b1.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    int intValue = SnoozeActivity.getTimeFromSnoozeValue(snoozeValue.getValue());
                    AlertPlayer.getPlayer().PreSnooze(getApplicationContext(), uuid, intValue);
                    d.dismiss();
                }
            });
            b2.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    d.dismiss();
                }
            });
            d.show();
        }
    });
}
Also used : NumberPicker(android.widget.NumberPicker) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) AlertDialog(android.app.AlertDialog) TimePickerDialog(android.app.TimePickerDialog) Dialog(android.app.Dialog) View(android.view.View) TextView(android.widget.TextView) Paint(android.graphics.Paint)

Aggregations

NumberPicker (android.widget.NumberPicker)32 View (android.view.View)19 TextView (android.widget.TextView)14 DialogInterface (android.content.DialogInterface)12 Dialog (android.app.Dialog)10 Button (android.widget.Button)10 AlertDialog (android.app.AlertDialog)8 LayoutInflater (android.view.LayoutInflater)6 Paint (android.graphics.Paint)5 NonNull (android.support.annotation.NonNull)5 AlertDialog (android.support.v7.app.AlertDialog)5 CompoundButton (android.widget.CompoundButton)5 FrameLayout (android.widget.FrameLayout)5 OnClick (butterknife.OnClick)5 TimePickerDialog (android.app.TimePickerDialog)4 ListView (android.widget.ListView)4 Activity (android.app.Activity)3 Intent (android.content.Intent)3 ImageView (android.widget.ImageView)3 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)3