Created
August 19, 2010 21:34
-
-
Save timsu/538982 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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