@Nullable @Override public DialogPreference getPreference() { return super.getPreference(); }
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState == null) { currentValue = getNumberPickerPreference().getValue(); } else { currentValue = savedInstanceState.getInt(SAVE_STATE_VALUE); } }
@NonNull @Override protected View onCreateDialogView(@NonNull Context context) { Context context2 = new AlertDialog.Builder(context).getContext(); // Context context2 = new AlertDialog.Builder(context, getTheme()).getContext(); return super.onCreateDialogView(context2); }
@Override protected void onBindDialogView(View view) { super.onBindDialogView(view); picker = (CustomNumberPicker) view.findViewById(R.id.numpicker_pref); picker.setMaxValue(getNumberPickerPreference().maxValue); picker.setMinValue(getNumberPickerPreference().minValue); picker.setValue(currentValue); }
@Override protected void onPrepareDialogBuilder(AlertDialog.Builder builder) { Context context = getContext(); builder.setTitle(context.getString(R.string.pref_dialog_title)); builder.setPositiveButton(context.getString(R.string.pref_dialog_positive_btn_text), this); builder.setNegativeButton(context.getString(R.string.pref_dialog_negative_btn_text), this); super.onPrepareDialogBuilder(builder); }
/** * Copied from {@link AppCompatDialogFragment}. * * @hide */ @SuppressWarnings("RestrictedApi") @RestrictTo(LIBRARY_GROUP) @Override public void setupDialog(Dialog dialog, int style) { if (dialog instanceof AppCompatDialog) { // If the dialog is an AppCompatDialog, we'll handle it AppCompatDialog acd = (AppCompatDialog) dialog; switch (style) { case STYLE_NO_INPUT: dialog.getWindow().addFlags( WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); // fall through... case STYLE_NO_FRAME: case STYLE_NO_TITLE: acd.supportRequestWindowFeature(Window.FEATURE_NO_TITLE); } } else { // Else, just let super handle it super.setupDialog(dialog, style); } }
/** * Initializes the color picker dialog components. * * <p>Runs when the dialog opens.</p> * * @param view The color picker dialog layout. */ @Override protected void onBindDialogView(final View view) { super.onBindDialogView(view); final ColorPicker colorPicker = view.findViewById(R.id.colorPicker); final ValueBar valueBar = view.findViewById(R.id.colorPickerValueBar); final SaturationBar saturationBar = view.findViewById(R.id.colorPickerSaturationBar); final int persistedColor = getColorPickerPreference().getPersistedColor(); colorPicker.setOnColorChangedListener(this); colorPicker.addValueBar(valueBar); colorPicker.addSaturationBar(saturationBar); colorPicker.setColor(persistedColor); colorPicker.setOldCenterColor(persistedColor); }
/** * {@inheritDoc} */ @Override protected void onBindDialogView(View view) { super.onBindDialogView(view); mTimePicker = (TimePicker) view.findViewById(R.id.edit); // Exception: There is no TimePicker with the id 'edit' in the dialog. if (mTimePicker == null) { throw new IllegalStateException("Dialog view must contain a TimePicker with id 'edit'"); } // Get the time from the related Preference Integer minutesAfterMidnight = null; DialogPreference preference = getPreference(); if (preference instanceof TimePreference) { minutesAfterMidnight = ((TimePreference) preference).getTime(); } // Set the time to the TimePicker if (minutesAfterMidnight != null) { int hours = minutesAfterMidnight / 60; int minutes = minutesAfterMidnight % 60; boolean is24hour = DateFormat.is24HourFormat(getContext()); mTimePicker.setIs24HourView(is24hour); mTimePicker.setCurrentHour(hours); mTimePicker.setCurrentMinute(minutes); } }