• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoawindowspythonrubyphpgameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdombtronvb.netdirectxarduinopreviewerゲームエンジン

Commit MetaInfo

Revision3f061341152167d094d5e3046dc27e0d4a9c9cff (tree)
Time2014-05-18 18:57:15
AuthorMasahiko, SAWAI <say@user...>
CommiterMasahiko, SAWAI

Log Message

Refactored CsvUploadStatusDBHelper

Change Summary

Incremental Difference

--- a/simple-battery-logger/simple-battery-logger-dropbox/proguard.cfg
+++ b/simple-battery-logger/simple-battery-logger-dropbox/proguard.cfg
@@ -64,22 +64,22 @@
6464
6565 # Removes all calls to Log. Delete the methods if you want to keep.
6666 -assumenosideeffects class android.util.Log {
67- public static int v(...);
68- public static int d(...);
69- public static int i(...);
70- public static int w(...);
71- public static int e(...);
72- public static int wtf(...);
67+# public static int v(...);
68+# public static int d(...);
69+# public static int i(...);
70+# public static int w(...);
71+# public static int e(...);
72+# public static int wtf(...);
7373 }
7474
7575 -assumenosideeffects class org.routine_work.util.Log {
76- public static int v(...);
77- public static int d(...);
78- public static int i(...);
79- public static int w(...);
80- public static int e(...);
81- public static int log(...);
82- public static int setOutputLevel(...);
83- public static int setTraceMode(...);
76+# public static int v(...);
77+# public static int d(...);
78+# public static int i(...);
79+# public static int w(...);
80+# public static int e(...);
81+# public static int log(...);
82+# public static int setOutputLevel(...);
83+# public static int setTraceMode(...);
8484 }
8585
--- a/simple-battery-logger/simple-battery-logger-dropbox/src/org/routine_work/simple_battery_logger/dropbox_uploader/UploadCsvFilesService.java
+++ b/simple-battery-logger/simple-battery-logger-dropbox/src/org/routine_work/simple_battery_logger/dropbox_uploader/UploadCsvFilesService.java
@@ -67,19 +67,28 @@ public class UploadCsvFilesService extends IntentService
6767 @Override
6868 public void onCreate()
6969 {
70+ Log.v(LOG_TAG, "Hello");
71+
7072 super.onCreate();
7173 dbHelper = new CsvUploadStatusDBHelper(this);
7274 db = dbHelper.getWritableDatabase();
75+
76+ Log.v(LOG_TAG, "Bye");
7377 }
7478
7579 @Override
7680 public void onDestroy()
7781 {
82+ Log.v(LOG_TAG, "Hello");
83+
7884 if (db != null)
7985 {
8086 db.close();
87+ db = null;
8188 }
8289 super.onDestroy();
90+
91+ Log.v(LOG_TAG, "Bye");
8392 }
8493
8594 @Override
@@ -136,15 +145,8 @@ public class UploadCsvFilesService extends IntentService
136145 uploadedFileCount++;
137146 if ((uploadedFileCount % UPLOAD_INTERVAL_FILE_COUNT) == 0)
138147 {
139- try
140- {
141- Log.i(LOG_TAG, "UploadCsvFilesService : Upload Waiting... UPLOAD_WAIT_TIME_IN_MILISEC => " + UPLOAD_INTERVAL_TIME_IN_MILISEC);
142- Thread.sleep(UPLOAD_INTERVAL_TIME_IN_MILISEC);
143- }
144- catch (InterruptedException ex)
145- {
146- Log.w(LOG_TAG, ex.getLocalizedMessage(), ex);
147- }
148+ Log.i(LOG_TAG, "UploadCsvFilesService : Upload Waiting... UPLOAD_WAIT_TIME_IN_MILISEC => " + UPLOAD_INTERVAL_TIME_IN_MILISEC);
149+ uploadInterval();
148150 }
149151 }
150152 }
@@ -203,4 +205,16 @@ public class UploadCsvFilesService extends IntentService
203205 NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
204206 notificationManager.cancel(NOTIFICATION_ID_UPLOAD_CSV_FILES);
205207 }
208+
209+ private void uploadInterval()
210+ {
211+ try
212+ {
213+ Thread.sleep(UPLOAD_INTERVAL_TIME_IN_MILISEC);
214+ }
215+ catch (InterruptedException ex)
216+ {
217+ Log.w(LOG_TAG, ex.getLocalizedMessage(), ex);
218+ }
219+ }
206220 }
--- a/simple-battery-logger/simple-battery-logger-dropbox/src/org/routine_work/simple_battery_logger/dropbox_uploader/UploadNewCsvFilesService.java
+++ b/simple-battery-logger/simple-battery-logger-dropbox/src/org/routine_work/simple_battery_logger/dropbox_uploader/UploadNewCsvFilesService.java
@@ -87,7 +87,7 @@ public class UploadNewCsvFilesService extends IntentService
8787 }
8888
8989 List<String> uploadTargetCsvFilePathList = UploadServiceUtils.getNewCsvFilePathList(this);
90- Log.d(LOG_TAG, "UploadNewCsvFilesService : uploadTargetCsvFilePathList.size" + uploadTargetCsvFilePathList.size());
90+ Log.d(LOG_TAG, "UploadNewCsvFilesService : uploadTargetCsvFilePathList.size => " + uploadTargetCsvFilePathList.size());
9191 if (uploadTargetCsvFilePathList.size() > 0)
9292 {
9393 String[] csvFilePaths = uploadTargetCsvFilePathList.toArray(new String[0]);
--- a/simple-battery-logger/simple-battery-logger-dropbox/src/org/routine_work/simple_battery_logger/dropbox_uploader/db/CsvUploadStatusDBHelper.java
+++ b/simple-battery-logger/simple-battery-logger-dropbox/src/org/routine_work/simple_battery_logger/dropbox_uploader/db/CsvUploadStatusDBHelper.java
@@ -63,6 +63,7 @@ public class CsvUploadStatusDBHelper extends SQLiteOpenHelper
6363 public long insertOrUpdate(SQLiteDatabase db, File file)
6464 {
6565 Log.v(LOG_TAG, "Hello");
66+ long rowID;
6667
6768 String filePath = file.getAbsolutePath();
6869 long lastModfied = file.lastModified();
@@ -72,20 +73,29 @@ public class CsvUploadStatusDBHelper extends SQLiteOpenHelper
7273 values.put(CsvUploadStatus.Columns.FILEPATH, filePath);
7374 values.put(CsvUploadStatus.Columns.MODIFIED, lastModfied);
7475
75- long rowID = getIDByFilePath(db, filePath);
76- if (rowID == -1)
76+ db.beginTransaction();
77+ try
7778 {
78- rowID = db.insert(CsvUploadStatus.TABLE_NAME, null, values);
79+ rowID = getIDByFilePath(db, filePath);
80+ if (rowID == -1)
81+ {
82+ rowID = db.insert(CsvUploadStatus.TABLE_NAME, null, values);
83+ }
84+ else
85+ {
86+ String whereClause = CsvUploadStatus.Columns.ID + " = ? ";
87+ String[] whereArgs =
88+ {
89+ String.valueOf(rowID),
90+ };
91+ values.put(CsvUploadStatus.Columns.ID, rowID);
92+ db.update(CsvUploadStatus.TABLE_NAME, values, whereClause, whereArgs);
93+ }
94+ db.setTransactionSuccessful();
7995 }
80- else
96+ finally
8197 {
82- String whereClause = CsvUploadStatus.Columns.ID + " = ? ";
83- String[] whereArgs =
84- {
85- String.valueOf(rowID),
86- };
87- values.put(CsvUploadStatus.Columns.ID, rowID);
88- db.update(CsvUploadStatus.TABLE_NAME, values, whereClause, whereArgs);
98+ db.endTransaction();
8999 }
90100
91101 Log.v(LOG_TAG, "Bye");
@@ -236,5 +246,4 @@ public class CsvUploadStatusDBHelper extends SQLiteOpenHelper
236246 {
237247 db.execSQL(CsvUploadStatus.VACCUM_SQL);
238248 }
239-
240249 }