From 66850a525a80956db0095dcb7cd87bae8cb40a6b Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 22 Nov 2018 10:07:10 +0100 Subject: [PATCH] removed unecessary code in time preference --- .../java/eu/siacs/conversations/ui/TimePreference.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/TimePreference.java b/src/main/java/eu/siacs/conversations/ui/TimePreference.java index c0d5489e9..a7e53ca38 100644 --- a/src/main/java/eu/siacs/conversations/ui/TimePreference.java +++ b/src/main/java/eu/siacs/conversations/ui/TimePreference.java @@ -48,8 +48,8 @@ public class TimePreference extends DialogPreference implements Preference.OnPre super.onBindDialogView(v); long time = getPersistedLong(DEFAULT_VALUE); - picker.setCurrentHour((int) (time / 60)); - picker.setCurrentMinute((int) (time % 60)); + picker.setCurrentHour((int) ((time % (24 * 60)) / 60)); + picker.setCurrentMinute((int) ((time % (24 * 60)) % 60)); } @Override @@ -80,12 +80,8 @@ public class TimePreference extends DialogPreference implements Preference.OnPre @Override protected void onSetInitialValue(final boolean restorePersistedValue, final Object defaultValue) { long time; - if (defaultValue == null) { - time = restorePersistedValue ? getPersistedLong(DEFAULT_VALUE) : DEFAULT_VALUE; - } else if (defaultValue instanceof Long) { + if (defaultValue instanceof Long) { time = restorePersistedValue ? getPersistedLong((Long) defaultValue) : (Long) defaultValue; - } else if (defaultValue instanceof Calendar) { - time = restorePersistedValue ? getPersistedLong(((Calendar)defaultValue).getTimeInMillis()) : ((Calendar)defaultValue).getTimeInMillis(); } else { time = restorePersistedValue ? getPersistedLong(DEFAULT_VALUE) : DEFAULT_VALUE; }