@Override protected void onBindDialogView(View v) { super.onBindDialogView(v); mSeekBar.setMax((mMax - mMin) / mInterval); mSeekBar.setProgress((mValue - mMin) / mInterval); }
@Override protected void onDialogClosed(boolean positiveResult) { final float newValue = (float) mSeekBarValue / SEEKBAR_RESOLUTION; if (positiveResult && callChangeListener(newValue)) { setValue(newValue); } else { callChangeListener(mValue); } super.onDialogClosed(positiveResult); }
@Override protected View onCreateDialogView() { mSeekBarValue = (int) (mValue * SEEKBAR_RESOLUTION); View view = super.onCreateDialogView(); SeekBar seekbar = view.findViewById(R.id.slider_preference_seekbar); seekbar.setMax(SEEKBAR_RESOLUTION); seekbar.setProgress(mSeekBarValue); seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { SliderPreference.this.mSeekBarValue = progress; callChangeListener((float) SliderPreference.this.mSeekBarValue / SEEKBAR_RESOLUTION); } } }); return view; }
@Override protected void onPrepareDialogBuilder(AlertDialog.Builder builder) { super.onPrepareDialogBuilder(builder); builder.setNegativeButton(null, null); builder.setPositiveButton(null, null); builder.setTitle(null); } }
@Override protected void onRestoreInstanceState(Parcelable state) { Bundle bundle = (Bundle) state; super.onRestoreInstanceState(bundle.getParcelable(STATE_KEY_SUPER)); mSeekBarValue = bundle.getInt(STATE_KEY_SEEK_BAR_VALUE); callChangeListener((float) mSeekBarValue / SEEKBAR_RESOLUTION); } }
@Override protected Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); Bundle state = new Bundle(); state.putParcelable(STATE_KEY_SUPER, superState); state.putInt(STATE_KEY_SEEK_BAR_VALUE, mSeekBarValue); return state; }
@Override protected void showDialog(Bundle state) { super.showDialog(state); final AlertDialog dlg = (AlertDialog) getDialog(); dlg.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (validate()) { save(); dlg.dismiss(); } } }); }
@Override protected void onPrepareDialogBuilder(AlertDialog.Builder builder) { super.onPrepareDialogBuilder(builder); if (mCloseOnSelected) { // Don't show the positive button; clicking a color will be the "positive" action builder.setPositiveButton(null, null); } }
@Override protected void onRestoreInstanceState(Parcelable state) { if (state == null || !state.getClass().equals(SavedState.class)) { // Didn't save state for us in onSaveInstanceState super.onRestoreInstanceState(state); return; } SavedState myState = (SavedState) state; super.onRestoreInstanceState(myState.getSuperState()); setText(myState.text); }
@Override protected Parcelable onSaveInstanceState() { if(LOGV) Log.v(TAG, getKey() + ": onSaveInstanceState"); final Bundle extras = new Bundle(); if(mDialog != null) { extras.putBundle(EXTRA_DIALOG_STATE, mDialog.onSaveInstanceState()); mDialog.dismiss(); //extras.putString(EXTRA_DIALOG_VALUE, toPersistedString(getDialogValue())); } final Parcelable superState = super.onSaveInstanceState(); return InstanceState.createFrom(this, superState, extras); }
/** * @see DialogPreference#showDialog */ public void showDialog() { super.showDialog(null); }
@Override protected void onBindDialogView(View view) { super.onBindDialogView(view); CompatHelper.getCompat().setTime(timePicker, hours, minutes); }
@Override protected void onDialogClosed(boolean positiveResult) { super.onDialogClosed(positiveResult); if (positiveResult) { hours = CompatHelper.getCompat().getHour(timePicker); minutes = CompatHelper.getCompat().getMinute(timePicker); final String time = String.format("%1$02d:%2$02d", hours, minutes); if (callChangeListener(time)) { persistString(time); } } }
@Override protected View onCreateDialogView() { final View view = super.onCreateDialogView();
@Override protected void onPrepareDialogBuilder(AlertDialog.Builder builder) { super.onPrepareDialogBuilder(builder); builder.setNegativeButton(null, null); } }
@Override protected void onRestoreInstanceState(final Parcelable state) { if (!(state instanceof SavedState)) { super.onRestoreInstanceState(state); return; } final SavedState myState = (SavedState) state; super.onRestoreInstanceState(myState.getSuperState()); setSubtype(myState.mSubtype); }
@Override protected Parcelable onSaveInstanceState() { final Parcelable superState = super.onSaveInstanceState(); final Dialog dialog = getDialog(); if (dialog == null || !dialog.isShowing()) { return superState; } final SavedState myState = new SavedState(superState); myState.mSubtype = mSubtype; return myState; }
@Override public void showDialog(Bundle state) { super.showDialog(state); Window window = getDialog().getWindow(); window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); }
@Override protected void onBindDialogView(View view) { super.onBindDialogView(view); startEditText = (TextView) view.findViewById(R.id.min_value); endEditText = (TextView) view.findViewById(R.id.max_value); SharedPreferences pref = getSharedPreferences(); int startValue = pref.getInt(startKey, 0); int endValue = pref.getInt(endKey, 0); startEditText.setText(String.valueOf(startValue)); endEditText.setText(String.valueOf(endValue)); }
@Override protected void onDialogClosed(boolean positiveResult) { if (positiveResult) { SharedPreferences.Editor editor = getEditor(); editor.putInt(startKey, Integer.parseInt(startEditText.getText().toString())); editor.putInt(endKey, Integer.parseInt(endEditText.getText().toString())); editor.commit(); } super.onDialogClosed(positiveResult); } }