Skip to content

Commit

Permalink
Set default time to now+1h (fixes #152)
Browse files Browse the repository at this point in the history
  • Loading branch information
nevenz committed Aug 17, 2017
1 parent b024b5e commit c370360
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,14 @@ private void restoreState(Bundle savedInstanceState) {
private void setValues(OrgDateTime time) {
Calendar cal;

Calendar nextMinute = Calendar.getInstance();
nextMinute.add(Calendar.MINUTE, 1);
// TODO: Make it configurable
Calendar defaultTime = Calendar.getInstance();
defaultTime.add(Calendar.HOUR, 1);

if (time != null) {
cal = time.getCalendar();
} else {
cal = nextMinute;
cal = defaultTime;
}

mIsActive.setChecked(time == null || time.isActive());
Expand All @@ -346,10 +347,10 @@ private void setValues(OrgDateTime time) {

mIsTimeUsed.setChecked(time != null && time.hasTime());

/* If date/time is set but there's no time part, use next minute for the time as default. */
/* If there is no time part, set it to default's. */
if (time != null && !time.hasTime()) {
mCurrentHour = nextMinute.get(Calendar.HOUR_OF_DAY);
mCurrentMinute = nextMinute.get(Calendar.MINUTE);
mCurrentHour = defaultTime.get(Calendar.HOUR_OF_DAY);
mCurrentMinute = defaultTime.get(Calendar.MINUTE);
} else {
mCurrentHour = cal.get(Calendar.HOUR_OF_DAY);
mCurrentMinute = cal.get(Calendar.MINUTE);
Expand Down

0 comments on commit c370360

Please sign in to comment.