@@ -11,6 +11,8 @@ public class PhotoBean implements Serializable{ |
||
11 | 11 |
|
12 | 12 |
public String photoName; |
13 | 13 |
|
14 |
+ public String groupId; |
|
15 |
+ |
|
14 | 16 |
public int sessionSeq; |
15 | 17 |
|
16 | 18 |
public long sessionDate; |
@@ -7,7 +7,7 @@ import android.database.sqlite.SQLiteOpenHelper; |
||
7 | 7 |
public class DBHelper extends SQLiteOpenHelper{ |
8 | 8 |
|
9 | 9 |
private static final String DB_NAME = "paiai"; |
10 |
- private static final int DB_VERSION = 1; |
|
10 |
+ private static final int DB_VERSION = 2; |
|
11 | 11 |
private static DBHelper instance; |
12 | 12 |
|
13 | 13 |
public static final String PHOTO_INFO_TABLE = "photo_info_table"; |
@@ -23,6 +23,7 @@ public class DBHelper extends SQLiteOpenHelper{ |
||
23 | 23 |
String SESSION_SEQ = "session_seq"; |
24 | 24 |
String IS_RAW_PHOTO= "is_raw_photo"; |
25 | 25 |
String UPLOADED_STATUS = "upload_status"; |
26 |
+ String GROUP_ID = "group_id"; |
|
26 | 27 |
|
27 | 28 |
} |
28 | 29 |
|
@@ -44,7 +45,23 @@ public class DBHelper extends SQLiteOpenHelper{ |
||
44 | 45 |
|
45 | 46 |
@Override |
46 | 47 |
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { |
48 |
+ switch (oldVersion){ |
|
49 |
+ case 1: |
|
50 |
+ upgradeToVersion2(db); |
|
51 |
+ break; |
|
52 |
+ default: |
|
53 |
+ dropAndRecreateTables(db); |
|
54 |
+ break; |
|
55 |
+ } |
|
56 |
+ } |
|
47 | 57 |
|
58 |
+ private void upgradeToVersion2(SQLiteDatabase db){ |
|
59 |
+ db.execSQL("Alter table "+ PHOTO_INFO_TABLE+" add column "+PHOTO_INFO_COLUMNS.GROUP_ID +" VARCHAR"); |
|
60 |
+ } |
|
61 |
+ |
|
62 |
+ private void dropAndRecreateTables(SQLiteDatabase db){ |
|
63 |
+ db.execSQL("DROP TABLE IF EXISTS " + PHOTO_INFO_TABLE); |
|
64 |
+ createTables(db); |
|
48 | 65 |
} |
49 | 66 |
|
50 | 67 |
private void createTables(SQLiteDatabase db){ |
@@ -60,6 +77,7 @@ public class DBHelper extends SQLiteOpenHelper{ |
||
60 | 77 |
sql.append(PHOTO_INFO_COLUMNS.PHOTO_PATH).append(" VARCHAR, "); |
61 | 78 |
sql.append(PHOTO_INFO_COLUMNS.LENSMAN_ID).append(" VARCHAR, "); |
62 | 79 |
sql.append(PHOTO_INFO_COLUMNS.SESSION_ID).append(" VARCHAR, "); |
80 |
+ sql.append(PHOTO_INFO_COLUMNS.GROUP_ID).append(" VARCHAR, "); |
|
63 | 81 |
sql.append(PHOTO_INFO_COLUMNS.IS_RAW_PHOTO).append(" INTEGER, "); |
64 | 82 |
sql.append(PHOTO_INFO_COLUMNS.SESSION_SEQ).append(" INTEGER, "); |
65 | 83 |
sql.append(PHOTO_INFO_COLUMNS.SESSION_DATE).append(" LONG, "); |
@@ -70,6 +70,7 @@ public class DBService { |
||
70 | 70 |
PhotoBean item = new PhotoBean(); |
71 | 71 |
item.lensmanId = c.getString(c.getColumnIndex(DBHelper.PHOTO_INFO_COLUMNS.LENSMAN_ID)); |
72 | 72 |
item.sessionId = c.getString(c.getColumnIndex(DBHelper.PHOTO_INFO_COLUMNS.SESSION_ID)); |
73 |
+ item.groupId = c.getString(c.getColumnIndex(DBHelper.PHOTO_INFO_COLUMNS.GROUP_ID)); |
|
73 | 74 |
item.isRawPhoto =(c.getInt(c.getColumnIndex(DBHelper.PHOTO_INFO_COLUMNS.IS_RAW_PHOTO))>0); |
74 | 75 |
item.uploadStatus = c.getInt(c.getColumnIndex(DBHelper.PHOTO_INFO_COLUMNS.UPLOADED_STATUS)); |
75 | 76 |
item.captureTime = c.getLong(c.getColumnIndex(DBHelper.PHOTO_INFO_COLUMNS.CAPTURE_TIME)); |
@@ -89,6 +90,7 @@ public class DBService { |
||
89 | 90 |
cv.put(DBHelper.PHOTO_INFO_COLUMNS.PHOTO_NAME, item.photoName); |
90 | 91 |
cv.put(DBHelper.PHOTO_INFO_COLUMNS.PHOTO_PATH, item.photoPath); |
91 | 92 |
cv.put(DBHelper.PHOTO_INFO_COLUMNS.SESSION_ID, item.sessionId); |
93 |
+ cv.put(DBHelper.PHOTO_INFO_COLUMNS.GROUP_ID, item.groupId); |
|
92 | 94 |
cv.put(DBHelper.PHOTO_INFO_COLUMNS.LENSMAN_ID,item.lensmanId); |
93 | 95 |
cv.put(DBHelper.PHOTO_INFO_COLUMNS.UPLOADED_STATUS,item.uploadStatus); |
94 | 96 |
cv.put(DBHelper.PHOTO_INFO_COLUMNS.SESSION_DATE,item.sessionDate); |
@@ -191,7 +191,14 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie |
||
191 | 191 |
if (data == null || data.getStringExtra("info") == null) { |
192 | 192 |
return; |
193 | 193 |
} |
194 |
- presenter.change2QRCodeSessionId(data.getStringExtra("info")); |
|
194 |
+ //TODO 支持扫群二维码,添加session到group |
|
195 |
+ String qrInfo = data.getStringExtra("info"); |
|
196 |
+ if(qrInfo.startsWith("http://pai.ai/g/")){ |
|
197 |
+ String groupId = qrInfo.substring(qrInfo.lastIndexOf("/")+1); |
|
198 |
+ presenter.addSessionPhotos2Group(groupId); |
|
199 |
+ }else{ |
|
200 |
+ presenter.change2QRCodeSessionId(data.getStringExtra("info")); |
|
201 |
+ } |
|
195 | 202 |
} |
196 | 203 |
} |
197 | 204 |
|
@@ -21,5 +21,6 @@ public class SessionContract { |
||
21 | 21 |
interface Presenter extends BasePresenter{ |
22 | 22 |
void swipeToDeletePhoto(int index); |
23 | 23 |
void change2QRCodeSessionId(String sessionId); |
24 |
+ void addSessionPhotos2Group(String groupId); |
|
24 | 25 |
} |
25 | 26 |
} |
@@ -25,6 +25,7 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
25 | 25 |
private SessionContract.View sessionView; |
26 | 26 |
private SessionBean sessionBean; |
27 | 27 |
private boolean isWorking; |
28 |
+ private String groupId; |
|
28 | 29 |
|
29 | 30 |
private static final String TAG = "SessionPresenter"; |
30 | 31 |
|
@@ -92,6 +93,7 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
92 | 93 |
} |
93 | 94 |
} |
94 | 95 |
LogHelper.d(TAG,"onSessionPhotoCaptured "+bean); |
96 |
+ bean.groupId = groupId; |
|
95 | 97 |
DBService.getInstance().addPhotoBean(bean); |
96 | 98 |
sessionView.showPhotoRecyclerView(); |
97 | 99 |
sessionView.addNewPhoto(bean); |
@@ -124,6 +126,11 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
124 | 126 |
} |
125 | 127 |
|
126 | 128 |
@Override |
129 |
+ public void addSessionPhotos2Group(String groupId) { |
|
130 |
+ this.groupId = groupId; |
|
131 |
+ } |
|
132 |
+ |
|
133 |
+ @Override |
|
127 | 134 |
public void onBoxStatusFetched(String boxNo, String boxStatus, int boxStatusCode) { |
128 | 135 |
LogHelper.d(TAG,"onBoxStatusFetched 盒子当前状态 "+boxStatus+" code = "+boxStatusCode); |
129 | 136 |
if(boxStatusCode == 200){ |
@@ -5,7 +5,7 @@ buildscript { |
||
5 | 5 |
jcenter() |
6 | 6 |
} |
7 | 7 |
dependencies { |
8 |
- classpath 'com.android.tools.build:gradle:2.2.0' |
|
8 |
+ classpath 'com.android.tools.build:gradle:2.2.2' |
|
9 | 9 |
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' |
10 | 10 |
// NOTE: Do not place your application dependencies here; they belong |
11 | 11 |
// in the individual module build.gradle files |