リビジョン | 9994f71c09930ff975c40792e746197315bcaa88 (tree) |
---|---|
日時 | 2013-01-30 17:00:59 |
作者 | Masahiko, SAWAI <say@user...> |
コミッター | Masahiko, SAWAI |
Refactoring classes in intent provider package.
@@ -23,8 +23,6 @@ | ||
23 | 23 | */ |
24 | 24 | package org.routine_work.intent_lab.intent.provider; |
25 | 25 | |
26 | -import android.provider.BaseColumns; | |
27 | - | |
28 | 26 | /** |
29 | 27 | * |
30 | 28 | * @author sawai |
@@ -39,41 +37,31 @@ interface IntentDBConstants | ||
39 | 37 | { |
40 | 38 | |
41 | 39 | static final String TABLE_NAME = "Intents"; |
42 | - interface Columns extends BaseColumns | |
43 | - { | |
44 | - | |
45 | - String DATA = "_data"; | |
46 | - String CREATED = "created"; | |
47 | - String MODIFIED = "modified"; | |
48 | - String NAME = "name"; | |
49 | - String ACTION = "action"; // Intent.getAction() | |
50 | - String DATA_URI = "data_uri"; // Intent.getData() | |
51 | - } | |
52 | 40 | // CREATE SQL |
53 | 41 | static final String CREATE_TABLE_SQL = "CREATE TABLE " + TABLE_NAME + "(" |
54 | - + " " + Columns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT" | |
55 | - + ", " + Columns.NAME + " TEXT" | |
56 | - + ", " + Columns.DATA + " TEXT" | |
57 | - + ", " + Columns.CREATED + " INTEGER NOT NULL" | |
58 | - + ", " + Columns.MODIFIED + " INTEGER NOT NULL" | |
59 | - + ", " + Columns.ACTION + " TEXT" | |
60 | - + ", " + Columns.DATA_URI + " TEXT" | |
42 | + + " " + IntentStore.Intents.Columns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT" | |
43 | + + ", " + IntentStore.Intents.Columns.NAME + " TEXT" | |
44 | + + ", " + IntentStore.Intents.Columns.DATA + " TEXT" | |
45 | + + ", " + IntentStore.Intents.Columns.CREATED + " INTEGER NOT NULL" | |
46 | + + ", " + IntentStore.Intents.Columns.MODIFIED + " INTEGER NOT NULL" | |
47 | + + ", " + IntentStore.Intents.Columns.ACTION + " TEXT" | |
48 | + + ", " + IntentStore.Intents.Columns.DATA_URI + " TEXT" | |
61 | 49 | + ");"; |
62 | 50 | String CREATE_TITLE_INDEX_SQL = "CREATE INDEX " |
63 | - + TABLE_NAME + "_" + Columns.NAME + "_index " | |
64 | - + "ON " + TABLE_NAME + "(" + Columns.NAME + ");"; | |
51 | + + TABLE_NAME + "_" + IntentStore.Intents.Columns.NAME + "_index " | |
52 | + + "ON " + TABLE_NAME + "(" + IntentStore.Intents.Columns.NAME + ");"; | |
65 | 53 | String CREATE_CREATED_INDEX_SQL = "CREATE INDEX " |
66 | - + TABLE_NAME + "_" + Columns.CREATED + "_index " | |
67 | - + "ON " + TABLE_NAME + "(" + Columns.CREATED + ");"; | |
54 | + + TABLE_NAME + "_" + IntentStore.Intents.Columns.CREATED + "_index " | |
55 | + + "ON " + TABLE_NAME + "(" + IntentStore.Intents.Columns.CREATED + ");"; | |
68 | 56 | String CREATE_MODIFIED_INDEX_SQL = "CREATE INDEX " |
69 | - + TABLE_NAME + "_" + Columns.MODIFIED + "_index " | |
70 | - + "ON " + TABLE_NAME + "(" + Columns.MODIFIED + ");"; | |
57 | + + TABLE_NAME + "_" + IntentStore.Intents.Columns.MODIFIED + "_index " | |
58 | + + "ON " + TABLE_NAME + "(" + IntentStore.Intents.Columns.MODIFIED + ");"; | |
71 | 59 | String CREATE_ACTION_INDEX_SQL = "CREATE INDEX " |
72 | - + TABLE_NAME + "_" + Columns.ACTION + "_index " | |
73 | - + "ON " + TABLE_NAME + "(" + Columns.ACTION + ");"; | |
60 | + + TABLE_NAME + "_" + IntentStore.Intents.Columns.ACTION + "_index " | |
61 | + + "ON " + TABLE_NAME + "(" + IntentStore.Intents.Columns.ACTION + ");"; | |
74 | 62 | String CREATE_DATA_URI_INDEX_SQL = "CREATE INDEX " |
75 | - + TABLE_NAME + "_" + Columns.DATA_URI + "_index " | |
76 | - + "ON " + TABLE_NAME + "(" + Columns.DATA_URI + ");"; | |
63 | + + TABLE_NAME + "_" + IntentStore.Intents.Columns.DATA_URI + "_index " | |
64 | + + "ON " + TABLE_NAME + "(" + IntentStore.Intents.Columns.DATA_URI + ");"; | |
77 | 65 | // DROP SQL |
78 | 66 | static final String DROP_TABLE_SQL = "DROP TABLE " + TABLE_NAME + ";"; |
79 | 67 | } |
@@ -108,7 +108,7 @@ public class IntentProvider extends ContentProvider | ||
108 | 108 | Uri newUri = ContentUris.withAppendedId(IntentStore.Intents.CONTENT_URI, rowID); |
109 | 109 | |
110 | 110 | // update data path |
111 | - String data = initialValues.getAsString(Intents.Columns.DATA); | |
111 | + String data = initialValues.getAsString(IntentStore.Intents.Columns.DATA); | |
112 | 112 | Log.d(LOG_TAG, "insert() : data => " + data); |
113 | 113 | if (data == null) |
114 | 114 | { |
@@ -116,7 +116,7 @@ public class IntentProvider extends ContentProvider | ||
116 | 116 | Log.d(LOG_TAG, "insert() : file => " + file); |
117 | 117 | |
118 | 118 | ContentValues values = new ContentValues(); |
119 | - values.put(Intents.Columns.DATA, file.getPath()); | |
119 | + values.put(IntentStore.Intents.Columns.DATA, file.getPath()); | |
120 | 120 | update(newUri, values, null, null); |
121 | 121 | } |
122 | 122 |
@@ -139,7 +139,7 @@ public class IntentProvider extends ContentProvider | ||
139 | 139 | break; |
140 | 140 | case INTENTS_ITEM_BY_ID: |
141 | 141 | String segment = uri.getPathSegments().get(1); |
142 | - StringBuilder whereClause = new StringBuilder(Intents.Columns._ID).append("=").append(segment); | |
142 | + StringBuilder whereClause = new StringBuilder(IntentStore.Intents.Columns._ID).append("=").append(segment); | |
143 | 143 | if (!TextUtils.isEmpty(where)) |
144 | 144 | { |
145 | 145 | whereClause.append(" AND (").append(where).append(")"); |
@@ -170,7 +170,7 @@ public class IntentProvider extends ContentProvider | ||
170 | 170 | |
171 | 171 | case INTENTS_ITEM_BY_ID: |
172 | 172 | String segment = uri.getPathSegments().get(1); |
173 | - StringBuilder whereClause = new StringBuilder(Intents.Columns._ID).append("=").append(segment); | |
173 | + StringBuilder whereClause = new StringBuilder(IntentStore.Intents.Columns._ID).append("=").append(segment); | |
174 | 174 | if (!TextUtils.isEmpty(where)) |
175 | 175 | { |
176 | 176 | whereClause.append(" AND (").append(where).append(")"); |
@@ -56,12 +56,12 @@ public class IntentStore | ||
56 | 56 | interface Columns extends BaseColumns |
57 | 57 | { |
58 | 58 | |
59 | - String DATA = IntentDBConstants.Intents.Columns.DATA; | |
60 | - String CREATED = IntentDBConstants.Intents.Columns.CREATED; | |
61 | - String MODIFIED = IntentDBConstants.Intents.Columns.MODIFIED; | |
62 | - String NAME = IntentDBConstants.Intents.Columns.NAME; | |
63 | - String ACTION = IntentDBConstants.Intents.Columns.ACTION; | |
64 | - String DATA_URI = IntentDBConstants.Intents.Columns.DATA_URI; | |
59 | + String DATA = "_data"; | |
60 | + String CREATED = "created"; | |
61 | + String MODIFIED = "modified"; | |
62 | + String NAME = "name"; | |
63 | + String ACTION = "action"; // Intent.getAction() | |
64 | + String DATA_URI = "data_uri"; // Intent.getData() | |
65 | 65 | } |
66 | 66 | public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/intents"); |
67 | 67 | public static final String INTENT_LIST_CONTENT_TYPE = "vnd.android.cursor.dir/vnd.routine_work.intent"; |
@@ -125,8 +125,8 @@ public class IntentStore | ||
125 | 125 | OutputStream os = cr.openOutputStream(newUri); |
126 | 126 | try |
127 | 127 | { |
128 | - byte[] marshalIntent = marshalIntent(intent); | |
129 | - os.write(marshalIntent); | |
128 | + byte[] marshalledIntent = marshalIntent(intent); | |
129 | + os.write(marshalledIntent); | |
130 | 130 | } |
131 | 131 | finally |
132 | 132 | { |