|
60
|
+ db.endTransaction();
|
|
|
61
|
+ } catch (Exception e) {
|
|
|
62
|
+ e.printStackTrace();
|
|
|
63
|
+ }
|
|
|
64
|
+ closeDB(db);
|
|
|
65
|
+ }
|
|
|
66
|
+ }
|
|
45
|
67
|
|
|
46
|
68
|
private PhotoBean cursor2PhotoBean(Cursor c) {
|
|
47
|
69
|
PhotoBean item = new PhotoBean();
|
|
|
|
@@ -53,6 +75,8 @@ public class DBService {
|
|
53
|
75
|
item.photoId = c.getLong(c.getColumnIndex(DBHelper.PHOTO_INFO_COLUMNS.PHOTO_ID));
|
|
54
|
76
|
item.photoName = c.getString(c.getColumnIndex(DBHelper.PHOTO_INFO_COLUMNS.PHOTO_NAME));
|
|
55
|
77
|
item.photoPath = c.getString(c.getColumnIndex(DBHelper.PHOTO_INFO_COLUMNS.PHOTO_PATH));
|
|
|
78
|
+ item.sessionDate = c.getLong(c.getColumnIndex(DBHelper.PHOTO_INFO_COLUMNS.SESSION_DATE));
|
|
|
79
|
+ item.sessionSeq = c.getInt(c.getColumnIndex(DBHelper.PHOTO_INFO_COLUMNS.SESSION_SEQ));
|
|
56
|
80
|
return item;
|
|
57
|
81
|
}
|
|
58
|
82
|
|
|
|
|
@@ -66,19 +90,64 @@ public class DBService {
|
|
66
|
90
|
cv.put(DBHelper.PHOTO_INFO_COLUMNS.SESSION_ID, item.sessionId);
|
|
67
|
91
|
cv.put(DBHelper.PHOTO_INFO_COLUMNS.LENSMAN_ID,item.lensmanId);
|
|
68
|
92
|
cv.put(DBHelper.PHOTO_INFO_COLUMNS.IS_UPLOADED,item.isUploaded);
|
|
|
93
|
+ cv.put(DBHelper.PHOTO_INFO_COLUMNS.SESSION_DATE,item.sessionDate);
|
|
|
94
|
+ cv.put(DBHelper.PHOTO_INFO_COLUMNS.SESSION_SEQ,item.sessionSeq);
|
|
69
|
95
|
return cv;
|
|
70
|
96
|
}
|
|
71
|
97
|
|
|
72
|
98
|
public void addPhotoBean(PhotoBean bean){
|
|
73
|
|
-
|
|
|
99
|
+ SQLiteDatabase db = null;
|
|
|
100
|
+ synchronized (DB_LOCK) {
|
|
|
101
|
+ try {
|
|
|
102
|
+ db = dbHelper.getWritableDatabase();
|
|
|
103
|
+ db.beginTransaction();
|
|
|
104
|
+ db.insertWithOnConflict(DBHelper.PHOTO_INFO_TABLE, null, photoBean2ContentValues(bean),
|
|
|
105
|
+ SQLiteDatabase.CONFLICT_REPLACE);
|
|
|
106
|
+ db.setTransactionSuccessful();
|
|
|
107
|
+ } catch (Exception e) {
|
|
|
108
|
+ LogHelper.d(TAG, "dbservice addUploadPhoto error happen " + e);
|
|
|
109
|
+ } finally {
|
|
|
110
|
+ try {
|
|
|
111
|
+ db.endTransaction();
|
|
|
112
|
+ } catch (Exception e) {
|
|
|
113
|
+ e.printStackTrace();
|
|
|
114
|
+ }
|
|
|
115
|
+ closeDB(db);
|
|
|
116
|
+ }
|
|
|
117
|
+ }
|
|
74
|
118
|
}
|
|
75
|
119
|
|
|
76
|
120
|
public void updatePhotoBean(PhotoBean bean){
|
|
77
|
|
-
|
|
|
121
|
+ addPhotoBean(bean);
|
|
78
|
122
|
}
|
|
79
|
123
|
|
|
80
|
124
|
public void deletePhotoBean(PhotoBean bean){
|
|
|
125
|
+ SQLiteDatabase db = null;
|
|
|
126
|
+ synchronized (DB_LOCK) {
|
|
|
127
|
+ try {
|
|
|
128
|
+ db = dbHelper.getReadableDatabase();
|
|
|
129
|
+ db.beginTransaction();
|
|
|
130
|
+ db.execSQL("delete from " + DBHelper.PHOTO_INFO_TABLE + " where "
|
|
|
131
|
+ + DBHelper.PHOTO_INFO_COLUMNS.PHOTO_PATH + " = '" + bean.photoPath + "'");
|
|
|
132
|
+ db.setTransactionSuccessful();
|
|
|
133
|
+ } catch (Exception e) {
|
|
|
134
|
+ LogHelper.d(TAG, "dbservice deleteUploadPhoto error happen " + e);
|
|
|
135
|
+ } finally {
|
|
|
136
|
+ try {
|
|
|
137
|
+ db.endTransaction();
|
|
|
138
|
+ } catch (Exception e) {
|
|
|
139
|
+ e.printStackTrace();
|
|
|
140
|
+ }
|
|
|
141
|
+ closeCursorAndDB(null, db);
|
|
|
142
|
+ }
|
|
|
143
|
+ }
|
|
|
144
|
+ }
|
|
|
145
|
+
|
|
|
146
|
+ public ArrayList<SessionBean> getSessionBeanListByDay(){
|
|
|
147
|
+ ArrayList<SessionBean> sessionBeanArrayList = new ArrayList<>();
|
|
|
148
|
+ //TODO
|
|
81
|
149
|
|
|
|
150
|
+ return sessionBeanArrayList;
|
|
82
|
151
|
}
|
|
83
|
152
|
|
|
84
|
153
|
}
|