/** * See the file "LICENSE" for the full license governing this code. */ package com.todoroo.astrid.alarms; import android.content.ContentValues; import com.todoroo.andlib.data.AbstractModel; import com.todoroo.andlib.data.Property; import com.todoroo.andlib.data.Table; import com.todoroo.andlib.data.TodorooCursor; import com.todoroo.andlib.data.Property.IntegerProperty; import com.todoroo.andlib.data.Property.LongProperty; import com.todoroo.astrid.model.Metadata; import com.todoroo.astrid.model.Task; /** * Data Model which represents an alarm * * @author Tim Su * */ @SuppressWarnings("nls") public class Alarm extends AbstractModel { // --- table public static final Table TABLE = new Table("alarm", Alarm.class); // --- properties /** ID */ public static final LongProperty ID = new LongProperty( TABLE, ID_PROPERTY_NAME); /** Associated Task */ public static final LongProperty TASK = new LongProperty( TABLE, "task"); /** Associated Task */ public static final IntegerProperty TIME = new IntegerProperty( TABLE, "time"); /** Associated Task */ public static final IntegerProperty TYPE = new IntegerProperty( TABLE, "type"); /** List of all properties for this model */ public static final Property[] PROPERTIES = generateProperties(Alarm.class); // --- constants /** this alarm was already triggered */ public static final int TYPE_TRIGGERED = 0; /** this alarm is single-shot */ public static final int TYPE_SINGLE = 1; /** this alarm repeats itself until turned off */ public static final int TYPE_REPEATING = 2; // --- defaults /** Default values container */ private static final ContentValues defaultValues = new ContentValues(); static { defaultValues.put(TYPE.name, TYPE_SINGLE); } @Override public ContentValues getDefaultValues() { return defaultValues; } // --- data access boilerplate public Alarm() { super(); } public Alarm(TodorooCursor cursor) { this(); readPropertiesFromCursor(cursor); } public void readFromCursor(TodorooCursor cursor) { super.readPropertiesFromCursor(cursor); } @Override public long getId() { return getIdHelper(ID); }; // --- parcelable helpers private static final Creator CREATOR = new ModelCreator(Task.class); @Override protected Creator getCreator() { return CREATOR; } }