public class SettingTimeDialogPreference extends SettingDateTimeDialogPreference<TimePickerDialog.TimeOptions>
SettingDateTimeDialogPreference implementation that may be used to allow to a user to pick
its preferred time for a specific setting preference.
This preference implementation by default displays the preferred time formatted by format specified
via SettingDateTimeDialogPreference.setFormat(SimpleDateFormat) as summary text. The default format is 'hh:mm a'.
If no time is specified, the standard summary text is displayed. The preferred time may be specified
via setTime(Date) and obtained via getTime() or getTimeInMillis().
When SettingDialogPreference.handleOnDialogButtonClick(Dialog, int) is called, this preference implementation
handles only TimePickerDialog type of dialog. If its Dialog#BUTTON_POSITIVE button
has been clicked, the time provided via TimePickerDialog#getTime() is set as time for
this preference via setTime(long).
String into milliseconds value
using TimePickerDialog.TimeParser#parse(String). See TypedArray.getString(int).
SettingDateTimeDialogPreference,
SettingTimeDialogPreference Attributes
uiSettingTimeDialogPreferenceStyleSettingDialogPreference.OnClickListenerNO_DIALOG_ID| Constructor and Description |
|---|
SettingTimeDialogPreference(android.content.Context context)
Same as
SettingTimeDialogPreference(Context, AttributeSet) without attributes. |
SettingTimeDialogPreference(android.content.Context context,
android.util.AttributeSet attrs)
Same as
SettingTimeDialogPreference(Context, AttributeSet, int) with
R.attr#uiSettingTimeDialogPreferenceStyle as attribute for default style. |
SettingTimeDialogPreference(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr)
Same as
SettingTimeDialogPreference(Context, AttributeSet, int, int) with 0 as
default style. |
SettingTimeDialogPreference(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 |
|---|---|
TimePickerDialog.TimeOptions |
getDialogOptions()
Dialog options of this preference with the preferred time specified as
TimePickerDialog.TimeOptions#time(long), if it is set. |
Date |
getTime()
Like
getTimeInMillis(), but this method may be used to check whether the time value
has been specified or not, as this method will return null Date object if there is
no time value specified. |
long |
getTimeInMillis()
Returns the preferred time value of this preference.
|
protected void |
onConfigureDialogOptions(TimePickerDialog.TimeOptions 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 TimePickerDialog.TimeOptions |
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.handleOnDialogButtonClick(Dialog, int) if the given dialog has
id associated with this dialog preference. |
void |
setTime(Date time)
Same as
setTime(long) with milliseconds value of the given date. |
void |
setTime(long timeInMillis)
Sets a preferred time value for this preference.
|
onBindView, onGetDefaultValue, onGetSummaryText, onSetInitialValue, setFormatgetDialogId, handleOnDialogButtonClick, setOnClickListener, synchronizeSummaryViewsetKeycallChangeListener, compareTo, findPreferenceInHierarchy, getContext, getDependency, getEditor, getExtras, getFragment, getIcon, getIntent, getKey, getLayoutResource, getOnPreferenceChangeListener, getOnPreferenceClickListener, getOrder, getPersistedBoolean, getPersistedFloat, getPersistedInt, getPersistedLong, getPersistedString, getPersistedStringSet, getPreferenceManager, getSharedPreferences, getShouldDisableView, getSummary, getTitle, getTitleRes, getView, getWidgetLayoutResource, hasKey, isEnabled, isPersistent, isSelectable, notifyChanged, notifyDependencyChange, notifyHierarchyChanged, onAttachedToActivity, onAttachedToHierarchy, onClick, onCreateView, onDependencyChanged, onParentChanged, onPrepareForRemoval, onRestoreInstanceState, onSaveInstanceState, peekExtras, persistBoolean, persistFloat, persistInt, persistLong, persistString, persistStringSet, restoreHierarchyState, saveHierarchyState, setDefaultValue, setDependency, setEnabled, setFragment, setIcon, setIcon, setIntent, setLayoutResource, setOnPreferenceChangeListener, setOnPreferenceClickListener, setOrder, setPersistent, setSelectable, setShouldDisableView, setSummary, setSummary, setTitle, setTitle, setWidgetLayoutResource, shouldCommit, shouldDisableDependents, shouldPersist, toStringpublic SettingTimeDialogPreference(android.content.Context context)
SettingTimeDialogPreference(Context, AttributeSet) without attributes.public SettingTimeDialogPreference(android.content.Context context,
android.util.AttributeSet attrs)
SettingTimeDialogPreference(Context, AttributeSet, int) with
R.attr#uiSettingTimeDialogPreferenceStyle as attribute for default style.public SettingTimeDialogPreference(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr)
SettingTimeDialogPreference(Context, AttributeSet, int, int) with 0 as
default style.public SettingTimeDialogPreference(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr,
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.protected TimePickerDialog.TimeOptions onCreateDialogOptions(android.content.res.Resources resources)
SettingDialogPreference
Default implementation creates instance of DialogOptions.
onCreateDialogOptions in class SettingDialogPreference<TimePickerDialog.TimeOptions>resources - Application resources that may be used supply default values from resources
for the options.protected void onConfigureDialogOptions(TimePickerDialog.TimeOptions options,
android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr,
int defStyleRes)
SettingDialogPreferenceonConfigureDialogOptions in class SettingDialogPreference<TimePickerDialog.TimeOptions>options - The options created via SettingDialogPreference.onCreateDialogOptions(Resources).public void setTime(Date time)
setTime(long) with milliseconds value of the given date.time - The desired time with milliseconds value. May be null which corresponds
to 0.getTime()public void setTime(long timeInMillis)
If value of this preference changes, it is persisted and the change listener is notified about the change.
timeInMillis - The preferred time in milliseconds to be persisted.getTimeInMillis()public Date getTime()
getTimeInMillis(), but this method may be used to check whether the time value
has been specified or not, as this method will return null Date object if there is
no time value specified.null if no time value has been specified yet.setTime(Date),
getDialogOptions()public long getTimeInMillis()
setTime(long),
getDialogOptions()public TimePickerDialog.TimeOptions getDialogOptions()
TimePickerDialog.TimeOptions#time(long), if it is set.getDialogOptions in class SettingDialogPreference<TimePickerDialog.TimeOptions>getTimeInMillis()protected boolean onHandleDialogButtonClick(Dialog dialog,
int button)
SettingDialogPreferenceSettingDialogPreference.handleOnDialogButtonClick(Dialog, int) if the given dialog has
id associated with this dialog preference.onHandleDialogButtonClick in class SettingDialogPreference<TimePickerDialog.TimeOptions>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.