Added some helper functions for filtering

pull/14/head
Sam Bosley 13 years ago
parent c45360c415
commit 5f8dd36db5

@ -29,6 +29,10 @@ public final class Functions {
return new Field("(strftime('%s','now')*1000)");
}
public static Field fromNow(long millis) {
return new Field("(strftime('%s','now')*1000 + " + millis + ")");
}
public static Field cast(Field field, String newType) {
return new Field("CAST(" + field.toString() + " AS " +
newType + ")");

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

@ -131,6 +131,15 @@
<!-- Notifications disabled warning -->
<string name="TLA_notification_disabled">Astrid reminders are disabled! You will not receive any reminders</string>
<string-array name="TLA_filters">
<item>Active</item>
<item>Today</item>
<item>Soon</item>
<item>Late</item>
<item>Done</item>
<item>Hidden</item>
</string-array>
<!-- ====================================================== TaskAdapter == -->
<!-- Format string to indicate task is hidden (%s => task name) -->

@ -99,11 +99,26 @@ public class TaskDao extends DatabaseDao<Task> {
Task.DELETION_DATE.eq(0));
}
/** @return tasks that are due within the next 24 hours */
public static Criterion dueToday() {
return Criterion.and(TaskCriteria.activeAndVisible(), Task.DUE_DATE.gt(0), Task.DUE_DATE.lt(Functions.fromNow(DateUtilities.ONE_DAY)));
}
/** @return tasks that are due within the next 72 hours */
public static Criterion dueSoon() {
return Criterion.and(TaskCriteria.activeAndVisible(), Task.DUE_DATE.gt(0), Task.DUE_DATE.lt(Functions.fromNow(3 * DateUtilities.ONE_DAY)));
}
/** @return tasks that are not hidden at current time */
public static Criterion isVisible() {
return Task.HIDE_UNTIL.lt(Functions.now());
}
/** @return tasks that are hidden at the current time */
public static Criterion isHidden() {
return Task.HIDE_UNTIL.gt(Functions.now());
}
/** @return tasks that have a due date */
public static Criterion hasDeadlines() {
return Task.DUE_DATE.neq(0);

Loading…
Cancel
Save