Skip to content

Commit

Permalink
Checking for presence of a key is safer than a 'magic' default value
Browse files Browse the repository at this point in the history
  • Loading branch information
wdullaer committed Aug 30, 2019
1 parent a55d4b8 commit 7cfd527
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,17 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
highlightedDays = (HashSet<Calendar>) savedInstanceState.getSerializable(KEY_HIGHLIGHTED_DAYS);
mThemeDark = savedInstanceState.getBoolean(KEY_THEME_DARK);
mThemeDarkChanged = savedInstanceState.getBoolean(KEY_THEME_DARK_CHANGED);
mAccentColor = savedInstanceState.getInt(KEY_ACCENT, Integer.MAX_VALUE);
if (mAccentColor == Integer.MAX_VALUE) mAccentColor = null;
if (savedInstanceState.containsKey(KEY_ACCENT)) mAccentColor = savedInstanceState.getInt(KEY_ACCENT);
mVibrate = savedInstanceState.getBoolean(KEY_VIBRATE);
mDismissOnPause = savedInstanceState.getBoolean(KEY_DISMISS);
mAutoDismiss = savedInstanceState.getBoolean(KEY_AUTO_DISMISS);
mTitle = savedInstanceState.getString(KEY_TITLE);
mOkResid = savedInstanceState.getInt(KEY_OK_RESID);
mOkString = savedInstanceState.getString(KEY_OK_STRING);
mOkColor = savedInstanceState.getInt(KEY_OK_COLOR, Integer.MAX_VALUE);
if (mOkColor == Integer.MAX_VALUE) mOkColor = null;
if (savedInstanceState.containsKey(KEY_OK_COLOR)) mOkColor = savedInstanceState.getInt(KEY_OK_COLOR);
mCancelResid = savedInstanceState.getInt(KEY_CANCEL_RESID);
mCancelString = savedInstanceState.getString(KEY_CANCEL_STRING);
mCancelColor = savedInstanceState.getInt(KEY_CANCEL_COLOR, Integer.MAX_VALUE);
if (mCancelColor == Integer.MAX_VALUE) mCancelColor = null;
if (savedInstanceState.containsKey(KEY_CANCEL_COLOR)) mCancelColor = savedInstanceState.getInt(KEY_CANCEL_COLOR);
mVersion = (Version) savedInstanceState.getSerializable(KEY_VERSION);
mScrollOrientation = (ScrollOrientation) savedInstanceState.getSerializable(KEY_SCROLL_ORIENTATION);
mTimezone = (TimeZone) savedInstanceState.getSerializable(KEY_TIMEZONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,20 +640,18 @@ public void onCreate(Bundle savedInstanceState) {
mTitle = savedInstanceState.getString(KEY_TITLE);
mThemeDark = savedInstanceState.getBoolean(KEY_THEME_DARK);
mThemeDarkChanged = savedInstanceState.getBoolean(KEY_THEME_DARK_CHANGED);
mAccentColor = savedInstanceState.getInt(KEY_ACCENT, Integer.MAX_VALUE);
if (mAccentColor == Integer.MAX_VALUE) mAccentColor = null;
if (savedInstanceState.containsKey(KEY_ACCENT)) mAccentColor = savedInstanceState.getInt(KEY_ACCENT);
mVibrate = savedInstanceState.getBoolean(KEY_VIBRATE);
mDismissOnPause = savedInstanceState.getBoolean(KEY_DISMISS);
mEnableSeconds = savedInstanceState.getBoolean(KEY_ENABLE_SECONDS);
mEnableMinutes = savedInstanceState.getBoolean(KEY_ENABLE_MINUTES);
mOkResid = savedInstanceState.getInt(KEY_OK_RESID);
mOkString = savedInstanceState.getString(KEY_OK_STRING);
mOkColor = savedInstanceState.getInt(KEY_OK_COLOR, Integer.MAX_VALUE);
if (savedInstanceState.containsKey(KEY_OK_COLOR)) mOkColor = savedInstanceState.getInt(KEY_OK_COLOR);
if (mOkColor == Integer.MAX_VALUE) mOkColor = null;
mCancelResid = savedInstanceState.getInt(KEY_CANCEL_RESID);
mCancelString = savedInstanceState.getString(KEY_CANCEL_STRING);
mCancelColor = savedInstanceState.getInt(KEY_CANCEL_COLOR, Integer.MAX_VALUE);
if (mCancelColor == Integer.MAX_VALUE) mCancelColor = null;
if (savedInstanceState.containsKey(KEY_CANCEL_COLOR)) mCancelColor = savedInstanceState.getInt(KEY_CANCEL_COLOR);
mVersion = (Version) savedInstanceState.getSerializable(KEY_VERSION);
mLimiter = savedInstanceState.getParcelable(KEY_TIMEPOINTLIMITER);
mLocale = (Locale) savedInstanceState.getSerializable(KEY_LOCALE);
Expand Down

0 comments on commit 7cfd527

Please sign in to comment.