@Override protected void onBindDialogView(View view) { super.onBindDialogView(view); mVolumeBar = (SeekBar) view.findViewById(R.id.volume_bar); Integer volumeLevel = null; DialogPreference preference = getPreference(); if (preference instanceof VolumePreference) { volumeLevel = ((VolumePreference) preference).getVolume(); } if (volumeLevel != null) { mVolumeBar.setProgress(volumeLevel); } }
@Override public boolean onPreferenceDisplayDialog(PreferenceFragmentCompat caller, Preference pref) { // check if dialog is already showing if (getFragmentManager().findFragmentByTag(DIALOG_FRAGMENT_TAG) != null) { return true; } if (pref instanceof DialogPreference) { String key = pref.getKey(); final DialogFragment f; if (KEY_RELEASE_NOTE.equals(key)) { f = ReleaseNoteDialogFragment.newInstance(key); } else if (KEY_LICENSE.equals(key)) { f = LicenseDialogFragmentProvider.newFragment(getActivity()); } else { return false; } f.setTargetFragment(this, 0); f.show(getFragmentManager(), DIALOG_FRAGMENT_TAG); return true; } return false; }
@Override protected void onBindDialogView(View view) { super.onBindDialogView(view); mColorPickerView = (ColorPickerView) view.findViewById(R.id.color_picker_view); ColorPanelView preColorPanelView = (ColorPanelView) view.findViewById(R.id.color_panel_old); mNewColorPanelView = (ColorPanelView) view.findViewById(R.id.color_panel_new); if (null == mColorPickerView || null == preColorPanelView || null == mNewColorPanelView) { throw new IllegalStateException("Dialog view must contain a ColorPickerView or ColorPanelView"); } mColorPickerView.setOnColorChangedListener(onColorChangedListener); boolean isFontColor = getString(R.string.font_color_key).equals(getArguments().getString(ARG_KEY)); mColorPickerView.setAlphaSliderVisible(!isFontColor); int color = -1; DialogPreference preference = getPreference(); if (preference instanceof ColorPickerPreference) { color = ((ColorPickerPreference) preference).getColor(); } if (color == 0) color = getDefaultColor(isFontColor); mColorPickerView.setColor(color, true); preColorPanelView.setColor(color); }
@Override public void onDialogClosed(boolean positiveResult) { if (positiveResult) { int volumeLevel = mVolumeBar.getProgress(); DialogPreference preference = getPreference(); if (preference instanceof VolumePreference) { VolumePreference volumePreference = (VolumePreference) preference; if (volumePreference.callChangeListener(volumeLevel)) { volumePreference.setVolume(volumeLevel); } } } }
@Override public void onDialogClosed(boolean positiveResult) { if (positiveResult) { int color = mColorPickerView.getColor(); DialogPreference preference = getPreference(); if (preference instanceof ColorPickerPreference) { ((ColorPickerPreference) preference).setColor(color); } } }