use of android.widget.NumberPicker in project xDrip by NightscoutFoundation.
the class SnoozeActivity method setOnClickListenerOnDisableButton.
/**
* Functionality used at least three times moved to a function. Adds an onClickListener that will disable the identified alert<br>
* Depending on type of disable, also active alarms will be set to inactive<br>
* - if snoozeType = ALL_ALERTS then the active bg alert will be deleted if any<br>
* - if snoozeType = LOW_ALERTS and if active low bg alert exists then it will be deleted<br>
* - if snoozeType = HIGH_ALERTS and if active high bg alert exists then it will be deleted<br>
* @param button to which onclicklistener should be added
* @param snoozeType identifies the alert, an enum value of SnoozeType
*/
private void setOnClickListenerOnDisableButton(Button button, SnoozeType snoozeType) {
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final Dialog d = new Dialog(SnoozeActivity.this);
d.setTitle(R.string.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);
// don't use SetSnoozePickerValues because an additional value must be added
// adding place for "until you re-enable"
String[] values = new String[snoozeValues.length + 1];
for (int i = 0; i < values.length - 1; i++) values[i] = getNameFromTime(snoozeValues[i]);
values[values.length - 1] = getString(R.string.until_you_reenable);
snoozeValue.setMaxValue(values.length - 1);
snoozeValue.setMinValue(0);
snoozeValue.setDisplayedValues(values);
snoozeValue.setWrapSelectorWheel(false);
snoozeValue.setValue(getSnoozeLocation(60));
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
long minutes;
if (snoozeValue.getValue() == snoozeValue.getMaxValue()) {
minutes = infiniteSnoozeValueInMinutes;
} else {
minutes = SnoozeActivity.getTimeFromSnoozeValue(snoozeValue.getValue());
}
snoozeForType(minutes, snoozeType, prefs);
d.dismiss();
// also make sure the text in the Activity is changed
displayStatus();
showDisableEnableButtons();
}
});
b2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
d.dismiss();
showDisableEnableButtons();
}
});
d.show();
}
});
}
use of android.widget.NumberPicker in project xDrip by NightscoutFoundation.
the class SnoozeActivity method setOnClickListenerOnDisableButton.
/**
* Functionality used at least three times moved to a function. Adds an onClickListener that will disable the identified alert<br>
* Depending on type of disable, also active alarms will be set to inactive<br>
* - if alert = "alerts_disabled_until" then the active bg alert will be deleted if any<br>
* - if alert = "low_alerts_disabled_until" and if active low bg alert exists then it will be deleted<br>
* - if alert = "high_alerts_disabled_until" and if active high bg alert exists then it will be deleted<br>
* @param button to which onclicklistener should be added
* @param alert identifies the alert, the text string used in the preferences ie alerts_disabled_until, low_alerts_disabled_until or high_alerts_disabled_until
*/
private void setOnClickListenerOnDisableButton(Button button, String alert) {
final String disableType = alert;
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final Dialog d = new Dialog(SnoozeActivity.this);
d.setTitle(R.string.default_snooze);
d.setTitle(R.string.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);
// don't use SetSnoozePickerValues because an additional value must be added
// adding place for "until you re-enable"
String[] values = new String[snoozeValues.length + 1];
for (int i = 0; i < values.length - 1; i++) values[i] = getNameFromTime(snoozeValues[i]);
values[values.length - 1] = getString(R.string.until_you_reenable);
snoozeValue.setMaxValue(values.length - 1);
snoozeValue.setMinValue(0);
snoozeValue.setDisplayedValues(values);
snoozeValue.setWrapSelectorWheel(false);
snoozeValue.setValue(getSnoozeLocatoin(60));
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Long disableUntil = new Date().getTime() + (snoozeValue.getValue() == snoozeValue.getMaxValue() ? infiniteSnoozeValueInMinutes : +(SnoozeActivity.getTimeFromSnoozeValue(snoozeValue.getValue()))) * 1000 * 60;
prefs.edit().putLong(disableType, disableUntil).apply();
// check if active bg alert exists and delete it depending on type of alert
ActiveBgAlert aba = ActiveBgAlert.getOnly();
if (aba != null) {
AlertType activeBgAlert = ActiveBgAlert.alertTypegetOnly();
if (disableType.equalsIgnoreCase("alerts_disabled_until") || (activeBgAlert.above && disableType.equalsIgnoreCase("high_alerts_disabled_until")) || (!activeBgAlert.above && disableType.equalsIgnoreCase("low_alerts_disabled_until"))) {
// active bg alert exists which is a type that is being disabled so let's remove it completely from the database
ActiveBgAlert.ClearData();
}
}
if (disableType.equalsIgnoreCase("alerts_disabled_until")) {
// disabling all , after the Snooze time set, all alarms will be re-enabled, inclusive low and high bg alarms
prefs.edit().putLong("high_alerts_disabled_until", 0).apply();
prefs.edit().putLong("low_alerts_disabled_until", 0).apply();
}
d.dismiss();
// also make sure the text in the Activity is changed
displayStatus();
showDisableEnableButtons();
recheckAlerts();
}
});
b2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
d.dismiss();
showDisableEnableButtons();
}
});
d.show();
}
});
}
use of android.widget.NumberPicker in project xDrip-plus by jamorham.
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;
}
});
}
use of android.widget.NumberPicker in project platform_packages_apps_PdfViewer by CopperheadOS.
the class JumpToPageFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
mPicker = new NumberPicker(getActivity());
mPicker.setMinValue(1);
mPicker.setMaxValue(((PdfViewer) getActivity()).mNumPages);
mPicker.setValue(((PdfViewer) getActivity()).mPage);
final FrameLayout layout = new FrameLayout(getActivity());
layout.addView(mPicker, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER));
return new AlertDialog.Builder(getActivity()).setView(layout).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
mPicker.clearFocus();
((PdfViewer) getActivity()).positiveButtonRenderPage(mPicker.getValue());
}
}).setNegativeButton(android.R.string.cancel, null).create();
}
use of android.widget.NumberPicker in project stillStanding by katsik.
the class NumberPickerPreference method onCreateDialogView.
@Override
protected View onCreateDialogView() {
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.gravity = Gravity.CENTER;
picker = new NumberPicker(getContext());
picker.setLayoutParams(layoutParams);
FrameLayout dialogView = new FrameLayout(getContext());
dialogView.addView(picker);
return dialogView;
}
Aggregations