Java 类android.support.v7.preference.DialogPreference 实例源码

项目:GitHub    文件:VolumePreferenceFragment.java   
@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);
    }
}
项目:FxcnBeta    文件:PreferencesFragment.java   
@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;
}
项目:OneNote    文件:ColorPickerPreDlgFragCompat.java   
@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);
}
项目:GitHub    文件:VolumePreferenceFragment.java   
@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);
            }
        }
    }
}
项目:OneNote    文件:ColorPickerPreDlgFragCompat.java   
@Override
public void onDialogClosed(boolean positiveResult) {
    if (positiveResult) {
        int color = mColorPickerView.getColor();
        DialogPreference preference = getPreference();
        if (preference instanceof ColorPickerPreference) {
            ((ColorPickerPreference) preference).setColor(color);
        }
    }
}