Permalink
Browse files

add trimStart and trimEnd to model

  • Loading branch information...
vitriolix committed Apr 1, 2013
1 parent 6267a31 commit 8417ce5b4ce79f8d6590e0126cb962cf2ae4047f
@@ -6,7 +6,7 @@
public class StoryMakerDB extends SQLiteOpenHelper {
- private static final int DB_VERSION = 2;
+ private static final int DB_VERSION = 3;
private static final String DB_NAME = "sm.db";
public StoryMakerDB(Context context) {
@@ -24,7 +24,13 @@ public void onCreate(SQLiteDatabase db) {
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- db.execSQL(StoryMakerDB.Schema.Projects.UPDATE_TABLE_PROJECTS);
+ if ((oldVersion < 2) && (newVersion == 2)) {
+ db.execSQL(StoryMakerDB.Schema.Projects.UPDATE_TABLE_PROJECTS);
+ }
+ if ((oldVersion < 3) && (newVersion == 3)) {
+ db.execSQL(StoryMakerDB.Schema.Media.UPDATE_TABLE_MEDIA_ADD_TRIM_START);
+ db.execSQL(StoryMakerDB.Schema.Media.UPDATE_TABLE_MEDIA_ADD_TRIM_END);
+ }
}
public class Schema
@@ -98,15 +104,27 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
public static final String COL_MIME_TYPE = "mime_type";
public static final String COL_CLIP_TYPE = "clip_type";
public static final String COL_CLIP_INDEX = "clip_index";
+ public static final String COL_TRIM_START = "trim_start";
+ public static final String COL_TRIM_END = "trim_end";
private static final String CREATE_TABLE_MEDIA = "create table " + NAME + " ("
+ ID + " integer primary key autoincrement, "
+ COL_SCENE_ID + " text not null, "
+ COL_PATH + " text not null, "
+ COL_MIME_TYPE + " text not null, "
+ COL_CLIP_TYPE + " text not null, "
- + COL_CLIP_INDEX + " integer not null"
+ + COL_CLIP_INDEX + " integer not null,"
+ + COL_TRIM_START + " integer,"
+ + COL_TRIM_END + " integer"
+ "); ";
+
+ private static final String UPDATE_TABLE_MEDIA_ADD_TRIM_START = "alter table " + NAME + " "
+ + "ADD COLUMN "
+ + COL_TRIM_START + " integer;";
+
+ private static final String UPDATE_TABLE_MEDIA_ADD_TRIM_END = "alter table " + NAME + " "
+ + "ADD COLUMN "
+ + COL_TRIM_END + " integer;";
}
// public static final String DB_SCHEMA = Lessons.CREATE_TABLE_LESSONS
@@ -20,13 +20,15 @@
protected String clipType; // R.arrays.cliptypes
protected int clipIndex; // which clip is this in the scene
protected int sceneId; // foreign key to the Scene which holds this media
+ protected int trimStart;
+ protected int trimEnd;
public Media(Context context) {
this.context = context;
}
public Media(Context context, int id, String path, String mimeType, String clipType, int clipIndex,
- int sceneId) {
+ int sceneId, int trimStart, int trimEnd) {
super();
this.context = context;
this.id = id;
@@ -35,6 +37,8 @@ public Media(Context context, int id, String path, String mimeType, String clipT
this.clipType = clipType;
this.clipIndex = clipIndex;
this.sceneId = sceneId;
+ this.trimStart = trimStart;
+ this.trimEnd = trimEnd;
}
public Media(Context context, Cursor cursor) {
@@ -52,7 +56,11 @@ public Media(Context context, Cursor cursor) {
cursor.getInt(cursor
.getColumnIndex(StoryMakerDB.Schema.Media.COL_CLIP_INDEX)),
cursor.getInt(cursor
- .getColumnIndex(StoryMakerDB.Schema.Media.COL_SCENE_ID)));
+ .getColumnIndex(StoryMakerDB.Schema.Media.COL_SCENE_ID)),
+ cursor.getInt(cursor
+ .getColumnIndex(StoryMakerDB.Schema.Media.COL_TRIM_START)),
+ cursor.getInt(cursor
+ .getColumnIndex(StoryMakerDB.Schema.Media.COL_TRIM_END)));
}
/***** Table level static methods *****/
@@ -116,22 +124,6 @@ public static Cursor getAllAsCursor(Context context) {
}
/***** Object level methods *****/
-
-// public void save() {
-// // FIXME be smart about insert vs update
-// ContentValues values = new ContentValues();
-// values.put(StoryMakerDB.Schema.Media.COL_PATH, path);
-// values.put(StoryMakerDB.Schema.Media.COL_MIME_TYPE, mimeType);
-// values.put(StoryMakerDB.Schema.Media.COL_CLIP_TYPE, clipType);
-// values.put(StoryMakerDB.Schema.Media.COL_CLIP_INDEX, clipIndex);
-// values.put(StoryMakerDB.Schema.Media.COL_SCENE_ID, sceneId);
-// ContentResolver cr = context.getContentResolver();
-// Uri uri = cr.insert(
-// ProjectsProvider.MEDIA_CONTENT_URI, values);
-// String lastSegment = uri.getLastPathSegment();
-// int newId = Integer.parseInt(lastSegment);
-// this.setId(newId);
-// }
public void save() {
Cursor cursor = getAsCursor(context, id);
@@ -153,6 +145,8 @@ private ContentValues getValues() {
values.put(StoryMakerDB.Schema.Media.COL_CLIP_TYPE, clipType);
values.put(StoryMakerDB.Schema.Media.COL_CLIP_INDEX, clipIndex);
values.put(StoryMakerDB.Schema.Media.COL_SCENE_ID, sceneId);
+ values.put(StoryMakerDB.Schema.Media.COL_TRIM_START, trimStart);
+ values.put(StoryMakerDB.Schema.Media.COL_TRIM_END, trimEnd);
return values;
}
@@ -273,17 +267,45 @@ public void setClipType(String clipType) {
this.clipType = clipType;
}
- /**
- * @return the clipIndex
- */
- public int getClipIndex() {
- return clipIndex;
- }
+ /**
+ * @return the clipIndex
+ */
+ public int getClipIndex() {
+ return clipIndex;
+ }
- /**
- * @param clipIndex the clipIndex to set
- */
- public void setClipIndex(int clipIndex) {
- this.clipIndex = clipIndex;
- }
+ /**
+ * @param clipIndex the clipIndex to set
+ */
+ public void setClipIndex(int clipIndex) {
+ this.clipIndex = clipIndex;
+ }
+
+ /**
+ * @return the trimStart
+ */
+ public int getTrimStart() {
+ return trimStart;
+ }
+
+ /**
+ * @param trimStart the trimStart to set
+ */
+ public void setTrimStart(int trimStart) {
+ this.trimStart = trimStart;
+ }
+
+ /**
+ * @return the trimEnd
+ */
+ public int getTrimEnd() {
+ return trimEnd;
+ }
+
+ /**
+ * @param trimEnd the trimEnd to set
+ */
+ public void setTrimEnd(int trimEnd) {
+ this.trimEnd = trimEnd;
+ }
}

0 comments on commit 8417ce5

Please sign in to comment.