updated comments
This commit is contained in:
parent
3b4fcbe602
commit
7f5c18bd2b
1 changed files with 21 additions and 16 deletions
|
@ -41,7 +41,7 @@ public class TimePickerPreference extends DialogPreference implements
|
||||||
* @param context
|
* @param context
|
||||||
* @param attrs
|
* @param attrs
|
||||||
*/
|
*/
|
||||||
public TimePickerPreference(Context context, AttributeSet attrs) {
|
public TimePickerPreference(final Context context, final AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
@ -51,8 +51,8 @@ public class TimePickerPreference extends DialogPreference implements
|
||||||
* @param attrs
|
* @param attrs
|
||||||
* @param defStyle
|
* @param defStyle
|
||||||
*/
|
*/
|
||||||
public TimePickerPreference(Context context, AttributeSet attrs,
|
public TimePickerPreference(final Context context, final AttributeSet attrs,
|
||||||
int defStyle) {
|
final int defStyle) {
|
||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
@ -86,23 +86,24 @@ public class TimePickerPreference extends DialogPreference implements
|
||||||
return tp;
|
return tp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
* @see
|
||||||
* android.widget.TimePicker.OnTimeChangedListener#onTimeChanged(android
|
* android.widget.TimePicker.OnTimeChangedListener#onTimeChanged(android
|
||||||
* .widget.TimePicker, int, int)
|
* .widget.TimePicker, int, int)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onTimeChanged(TimePicker view, int hour, int minute) {
|
public void onTimeChanged(final TimePicker view, final int hour, final int minute) {
|
||||||
|
|
||||||
persistString(String.format("%02d:%02d", hour, minute));
|
persistString(String.format("%02d:%02d", hour, minute));
|
||||||
callChangeListener(String.format("%02d:%02d", hour, minute));
|
callChangeListener(String.format("%02d:%02d", hour, minute));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If not a positive result, restore the original value
|
||||||
|
* before going to super.onDialogClosed(positiveResult).
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void onDialogClosed(boolean positiveResult) {
|
protected void onDialogClosed(boolean positiveResult) {
|
||||||
// Bug #1185 "[SE-QS] GMX: Nach Abbruch der Einstellungen der Ruhezeiten werden diese trotzdem uebernommen"
|
|
||||||
|
|
||||||
if (!positiveResult) {
|
if (!positiveResult) {
|
||||||
persistString(String.format("%02d:%02d", originalHour, originalMinute));
|
persistString(String.format("%02d:%02d", originalHour, originalMinute));
|
||||||
|
@ -111,13 +112,11 @@ public class TimePickerPreference extends DialogPreference implements
|
||||||
super.onDialogClosed(positiveResult);
|
super.onDialogClosed(positiveResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see android.preference.Preference#setDefaultValue(java.lang.Object)
|
* @see android.preference.Preference#setDefaultValue(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultValue(Object defaultValue) {
|
public void setDefaultValue(final Object defaultValue) {
|
||||||
// BUG this method is never called if you use the 'android:defaultValue' attribute in your XML preference file, not sure why it isn't
|
// BUG this method is never called if you use the 'android:defaultValue' attribute in your XML preference file, not sure why it isn't
|
||||||
|
|
||||||
super.setDefaultValue(defaultValue);
|
super.setDefaultValue(defaultValue);
|
||||||
|
@ -136,10 +135,10 @@ public class TimePickerPreference extends DialogPreference implements
|
||||||
/**
|
/**
|
||||||
* Get the hour value (in 24 hour time)
|
* Get the hour value (in 24 hour time)
|
||||||
*
|
*
|
||||||
* @return The hour value, will be 0 to 23 (inclusive)
|
* @return The hour value, will be 0 to 23 (inclusive) or -1 if illegal
|
||||||
*/
|
*/
|
||||||
private int getHour() {
|
private int getHour() {
|
||||||
String time = getPersistedString(this.defaultValue);
|
String time = getTime();
|
||||||
if (time == null || !time.matches(VALIDATION_EXPRESSION)) {
|
if (time == null || !time.matches(VALIDATION_EXPRESSION)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -150,10 +149,10 @@ public class TimePickerPreference extends DialogPreference implements
|
||||||
/**
|
/**
|
||||||
* Get the minute value
|
* Get the minute value
|
||||||
*
|
*
|
||||||
* @return the minute value, will be 0 to 59 (inclusive)
|
* @return the minute value, will be 0 to 59 (inclusive) or -1 if illegal
|
||||||
*/
|
*/
|
||||||
private int getMinute() {
|
private int getMinute() {
|
||||||
String time = getPersistedString(this.defaultValue);
|
String time = getTime();
|
||||||
if (time == null || !time.matches(VALIDATION_EXPRESSION)) {
|
if (time == null || !time.matches(VALIDATION_EXPRESSION)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -161,6 +160,12 @@ public class TimePickerPreference extends DialogPreference implements
|
||||||
return Integer.valueOf(time.split(":")[1]);
|
return Integer.valueOf(time.split(":")[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the time. It is only legal, if it matches
|
||||||
|
* {@link #VALIDATION_EXPRESSION}.
|
||||||
|
*
|
||||||
|
* @return the time as hh:mm
|
||||||
|
*/
|
||||||
public String getTime() {
|
public String getTime() {
|
||||||
return getPersistedString(this.defaultValue);
|
return getPersistedString(this.defaultValue);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue