public final class SettingDateDialogPreference extends SettingDateTimeDialogPreference<DatePickerDialog.DateOptions>
SettingDateTimeDialogPreference implementation that may be used to allow to a user to pick
its preferred date for a specific setting preference.
This preference implementation by default displays the preferred date formatted by format specified
via SettingDateTimeDialogPreference.setFormat(SimpleDateFormat) as summary text. The default format is 'MMM dd, yyyy'.
If no date is specified, the standard summary text is displayed. The preferred date may be specified
via setDate(long) and obtained via getDate() or getDateInMillis().
When SettingDialogPreference.handleDialogButtonClick(Dialog, int) is called, this preference implementation
handles only DatePickerDialog type of dialog. If its Dialog.BUTTON_POSITIVE button
has been clicked, the date provided via DatePickerDialog.getDate() is set as date for
this preference via setDate(long).
String into milliseconds value
using DatePickerDialog.DateParser#parse(String). See TypedArray.getString(int).
SettingDateTimeDialogPreference,
SettingDateDialogPreference Attributes
settingDateDialogPreferenceStyleSettingTimeDialogPreferenceSettingDialogPreference.OnClickListenerandroidx.preference.Preference.BaseSavedState, androidx.preference.Preference.OnPreferenceChangeListener, androidx.preference.Preference.OnPreferenceClickListener, androidx.preference.Preference.SummaryProvider<T extends androidx.preference.Preference>NO_DIALOG_ID| Constructor and Description |
|---|
SettingDateDialogPreference(android.content.Context context)
Same as
SettingDateDialogPreference(Context, AttributeSet) without attributes. |
SettingDateDialogPreference(android.content.Context context,
android.util.AttributeSet attrs)
Same as
SettingDateDialogPreference(Context, AttributeSet, int) with
R.attr.settingDateDialogPreferenceStyle as attribute for default style. |
SettingDateDialogPreference(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr)
Same as
SettingDateDialogPreference(Context, AttributeSet, int, int) with 0 as
default style. |
SettingDateDialogPreference(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr,
int defStyleRes)
Creates a new instance of SettingInputPreference for the given context.
|
| Modifier and Type | Method and Description |
|---|---|
Date |
getDate()
Like
getDateInMillis(), but this method may be used to check whether the date value
has been specified or not, as this method will return null Date object if there is
no date value specified. |
long |
getDateInMillis()
Returns the preferred date value of this preference.
|
DatePickerDialog.DateOptions |
getDialogOptions()
Dialog options of this preference with the preferred date specified as
DatePickerDialog.DateOptions#date(long), if it is set. |
protected void |
onConfigureDialogOptions(DatePickerDialog.DateOptions options,
android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr,
int defStyleRes)
Called from one of constructors to configure dialog options specific for this dialog preference.
|
protected DatePickerDialog.DateOptions |
onCreateDialogOptions(android.content.res.Resources resources)
Called to create instance of dialog options specific for this dialog preference.
|
protected boolean |
onHandleDialogButtonClick(Dialog dialog,
int button)
Called from
SettingDialogPreference.handleDialogButtonClick(Dialog, int) if the given dialog has
id associated with this dialog preference. |
void |
setDate(Date date)
Same as
setDate(long) with milliseconds value of the given date. |
void |
setDate(long dateInMillis)
Sets a preferred date value for this preference.
|
onBindViewHolder, onGetDefaultValue, onGetSummaryText, onSetInitialValue, setFormatgetDialogId, handleDialogButtonClick, setDialogId, setOnClickListener, synchronizeSummaryViewsetKeycallChangeListener, compareTo, findPreferenceInHierarchy, getContext, getDependency, getExtras, getFragment, getIcon, getIntent, getKey, getLayoutResource, getOnPreferenceChangeListener, getOnPreferenceClickListener, getOrder, getParent, getPersistedBoolean, getPersistedFloat, getPersistedInt, getPersistedLong, getPersistedString, getPersistedStringSet, getPreferenceDataStore, getPreferenceManager, getSharedPreferences, getShouldDisableView, getSummary, getSummaryProvider, getTitle, getWidgetLayoutResource, hasKey, isCopyingEnabled, isEnabled, isIconSpaceReserved, isPersistent, isSelectable, isShown, isSingleLineTitle, isVisible, notifyChanged, notifyDependencyChange, notifyHierarchyChanged, onAttached, onAttachedToHierarchy, onAttachedToHierarchy, onClick, onDependencyChanged, onDetached, onInitializeAccessibilityNodeInfo, onParentChanged, onPrepareForRemoval, onRestoreInstanceState, onSaveInstanceState, onSetInitialValue, peekExtras, performClick, performClick, persistBoolean, persistFloat, persistInt, persistLong, persistString, persistStringSet, restoreHierarchyState, saveHierarchyState, setCopyingEnabled, setDefaultValue, setDependency, setEnabled, setFragment, setIcon, setIcon, setIconSpaceReserved, setIntent, setLayoutResource, setOnPreferenceChangeListener, setOnPreferenceClickListener, setOrder, setPersistent, setPreferenceDataStore, setSelectable, setShouldDisableView, setSingleLineTitle, setSummary, setSummary, setSummaryProvider, setTitle, setTitle, setViewId, setVisible, setWidgetLayoutResource, shouldDisableDependents, shouldPersist, toStringpublic SettingDateDialogPreference(@NonNull
android.content.Context context)
SettingDateDialogPreference(Context, AttributeSet) without attributes.public SettingDateDialogPreference(@NonNull
android.content.Context context,
@Nullable
android.util.AttributeSet attrs)
SettingDateDialogPreference(Context, AttributeSet, int) with
R.attr.settingDateDialogPreferenceStyle as attribute for default style.public SettingDateDialogPreference(@NonNull
android.content.Context context,
@Nullable
android.util.AttributeSet attrs,
@AttrRes
int defStyleAttr)
SettingDateDialogPreference(Context, AttributeSet, int, int) with 0 as
default style.public SettingDateDialogPreference(@NonNull
android.content.Context context,
@Nullable
android.util.AttributeSet attrs,
@AttrRes
int defStyleAttr,
@StyleRes
int defStyleRes)
context - Context in which will be the new setting preference presented.attrs - Set of Xml attributes used to configure the new instance of this preference.defStyleAttr - An attribute which contains a reference to a default style resource for
this preference within a theme of the given context.defStyleRes - Resource id of the default style for the new preference.@NonNull protected DatePickerDialog.DateOptions onCreateDialogOptions(@NonNull android.content.res.Resources resources)
SettingDialogPreference
Default implementation creates instance of DialogOptions.
onCreateDialogOptions in class SettingDialogPreference<DatePickerDialog.DateOptions>resources - Application resources that may be used supply default values from resources
for the options.protected void onConfigureDialogOptions(@NonNull
DatePickerDialog.DateOptions options,
@NonNull
android.content.Context context,
@Nullable
android.util.AttributeSet attrs,
@AttrRes
int defStyleAttr,
@StyleRes
int defStyleRes)
SettingDialogPreferenceonConfigureDialogOptions in class SettingDialogPreference<DatePickerDialog.DateOptions>options - The options created via SettingDialogPreference.onCreateDialogOptions(Resources).public void setDate(@Nullable
Date date)
setDate(long) with milliseconds value of the given date.date - The desired date with milliseconds value. May be null which corresponds
to 0.getDate()public void setDate(long dateInMillis)
If value of this preference changes, it is persisted and the change listener is notified about the change.
dateInMillis - The preferred date in milliseconds to be persisted.getDateInMillis()@Nullable public Date getDate()
getDateInMillis(), but this method may be used to check whether the date value
has been specified or not, as this method will return null Date object if there is
no date value specified.null if no date value has been specified yet.setDate(Date),
getDialogOptions()public long getDateInMillis()
setDate(long),
getDialogOptions()@NonNull public DatePickerDialog.DateOptions getDialogOptions()
DatePickerDialog.DateOptions#date(long), if it is set.getDialogOptions in class SettingDialogPreference<DatePickerDialog.DateOptions>getDateInMillis()protected boolean onHandleDialogButtonClick(@NonNull
Dialog dialog,
int button)
SettingDialogPreferenceSettingDialogPreference.handleDialogButtonClick(Dialog, int) if the given dialog has
id associated with this dialog preference.onHandleDialogButtonClick in class SettingDialogPreference<DatePickerDialog.DateOptions>dialog - The dialog where the button has been clicked.button - The clicked dialog button.True if the button click event has been successfully handled, false
otherwise.