From aad1feb6feacd92647e8f20c9603e882566447a2 Mon Sep 17 00:00:00 2001 From: hlq07 Date: Wed, 20 Jun 2018 15:04:01 +0800 Subject: [PATCH] redefine running state and support alarmMethod "both" --- .../java/org/cutem/cutecalendar/model/TodoItemUtil.java | 6 ++++-- .../cutecalendar/presenter/ShowTodoItemDetailStrategy.java | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/cutem/cutecalendar/model/TodoItemUtil.java b/app/src/main/java/org/cutem/cutecalendar/model/TodoItemUtil.java index 2687028..1280b2f 100644 --- a/app/src/main/java/org/cutem/cutecalendar/model/TodoItemUtil.java +++ b/app/src/main/java/org/cutem/cutecalendar/model/TodoItemUtil.java @@ -473,7 +473,8 @@ public class TodoItemUtil { public static boolean isNeedNextAlarm(@NotNull TodoItem item, @NotNull Calendar nextAlarm) { String alarmMethod = item.getStringProperty(ALARM_METHOD); - if (Objects.equals("dialog", alarmMethod) || Objects.equals("area", alarmMethod)) { + if (Objects.equals("dialog", alarmMethod) || Objects.equals("area", alarmMethod) + || Objects.equals("both", alarmMethod)) { return !nextAlarm.after(item.getBgn()); } else { return false; @@ -494,7 +495,8 @@ public class TodoItemUtil { } public static boolean isRunning(@NotNull TodoItem item) { - return !isBeforeStart(item) && !isEnded(item); + Calendar now = CalendarUtil.roundToMinute(Calendar.getInstance()); + return isIntersectedDuring(item, now, now); } } diff --git a/app/src/main/java/org/cutem/cutecalendar/presenter/ShowTodoItemDetailStrategy.java b/app/src/main/java/org/cutem/cutecalendar/presenter/ShowTodoItemDetailStrategy.java index d61d0b4..6edf9fa 100644 --- a/app/src/main/java/org/cutem/cutecalendar/presenter/ShowTodoItemDetailStrategy.java +++ b/app/src/main/java/org/cutem/cutecalendar/presenter/ShowTodoItemDetailStrategy.java @@ -82,12 +82,12 @@ public class ShowTodoItemDetailStrategy extends VBox { private static String getFinishInfo(@NotNull TodoItem item) { if (TodoItemUtil.isFinished(item)) { return "finish"; + } else if (TodoItemUtil.isRunning(item)) { + return "running"; } else if (TodoItemUtil.isBeforeStart(item)) { return "not start"; - } else if (TodoItemUtil.isEnded(item)) { - return "overdue"; } else { - return "running"; + return "overdue"; } }