Skip to content

Instantly share code, notes, and snippets.

@timsu
Created August 19, 2010 21:34
Show Gist options
  • Select an option

  • Save timsu/538982 to your computer and use it in GitHub Desktop.

Select an option

Save timsu/538982 to your computer and use it in GitHub Desktop.
public final class SimpleTask extends AbstractModel {
// --- properties
/** ID */
public static final LongProperty ID = new LongProperty(
TABLE, ID_PROPERTY_NAME);
/** Name of Task */
public static final StringProperty TITLE = new StringProperty(
TABLE, "title");
/** Unixtime Task was completed. 0 means active */
public static final LongProperty COMPLETION_DATE = new LongProperty(
TABLE, "completed");
// --- defaults
/** Default values container */
private static final ContentValues defaultValues = new ContentValues();
static {
defaultValues.put(TITLE.name, "");
defaultValues.put(COMPLETION_DATE.name, 0);
}
@Override
public ContentValues getDefaultValues() {
return defaultValues;
}
// ... boilerplate ...
/** Checks whether task is done. Requires COMPLETION_DATE */
public boolean isCompleted() {
return getValue(COMPLETION_DATE) > 0;
}
}
public void activeTasks() {
TodorooCursor<SimpleTask> cursor = taskDao.query(Query.select(SimpleTask.TITLE).where(SimpleTask.COMPLETION_DATE.eq(0)));
try {
SimpleTask task = new SimpleTask();
for(cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
task.readFromCursor(cursor);
System.out.println(task.getValue(SimpleTask.TITLE);
}
} finally {
cursor.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment