@@ -21,7 +21,7 @@ public class PhotoBean implements Serializable{ |
||
21 | 21 |
|
22 | 22 |
public long captureTime; |
23 | 23 |
|
24 |
- public boolean isUploaded; |
|
24 |
+ public int uploadStatus; |
|
25 | 25 |
|
26 | 26 |
public boolean isRawPhoto; |
27 | 27 |
|
@@ -44,4 +44,10 @@ public class PhotoBean implements Serializable{ |
||
44 | 44 |
", sessionSeq=" + sessionSeq + |
45 | 45 |
'}'; |
46 | 46 |
} |
47 |
+ |
|
48 |
+ public interface UploadStatus { |
|
49 |
+ int STATUS_NO_BEGIN = 0; |
|
50 |
+ int STATUS_SUCCESS = 1; |
|
51 |
+ int STATUS_ERROR = -1; |
|
52 |
+ } |
|
47 | 53 |
} |
@@ -22,7 +22,7 @@ public class DBHelper extends SQLiteOpenHelper{ |
||
22 | 22 |
String SESSION_DATE = "session_date"; |
23 | 23 |
String SESSION_SEQ = "session_seq"; |
24 | 24 |
String IS_RAW_PHOTO= "is_raw_photo"; |
25 |
- String IS_UPLOADED = "is_uploaded"; |
|
25 |
+ String UPLOADED_STATUS = "upload_status"; |
|
26 | 26 |
|
27 | 27 |
} |
28 | 28 |
|
@@ -65,7 +65,7 @@ public class DBHelper extends SQLiteOpenHelper{ |
||
65 | 65 |
sql.append(PHOTO_INFO_COLUMNS.IS_RAW_PHOTO).append(" INTEGER, "); |
66 | 66 |
sql.append(PHOTO_INFO_COLUMNS.SESSION_SEQ).append(" INTEGER, "); |
67 | 67 |
sql.append(PHOTO_INFO_COLUMNS.SESSION_DATE).append(" LONG, "); |
68 |
- sql.append(PHOTO_INFO_COLUMNS.IS_UPLOADED).append(" INTEGER, "); |
|
68 |
+ sql.append(PHOTO_INFO_COLUMNS.UPLOADED_STATUS).append(" INTEGER, "); |
|
69 | 69 |
sql.append(PHOTO_INFO_COLUMNS.CAPTURE_TIME).append(" LONG "); |
70 | 70 |
sql.append(")"); |
71 | 71 |
db.execSQL(sql.toString()); |
@@ -71,7 +71,7 @@ public class DBService { |
||
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 | 73 |
item.isRawPhoto =(c.getInt(c.getColumnIndex(DBHelper.PHOTO_INFO_COLUMNS.IS_RAW_PHOTO))>0); |
74 |
- item.isUploaded = (c.getInt(c.getColumnIndex(DBHelper.PHOTO_INFO_COLUMNS.IS_UPLOADED))>0); |
|
74 |
+ item.uploadStatus = c.getInt(c.getColumnIndex(DBHelper.PHOTO_INFO_COLUMNS.UPLOADED_STATUS)); |
|
75 | 75 |
item.captureTime = c.getLong(c.getColumnIndex(DBHelper.PHOTO_INFO_COLUMNS.CAPTURE_TIME)); |
76 | 76 |
item.photoId = c.getLong(c.getColumnIndex(DBHelper.PHOTO_INFO_COLUMNS.PHOTO_ID)); |
77 | 77 |
item.photoName = c.getString(c.getColumnIndex(DBHelper.PHOTO_INFO_COLUMNS.PHOTO_NAME)); |
@@ -90,7 +90,7 @@ public class DBService { |
||
90 | 90 |
cv.put(DBHelper.PHOTO_INFO_COLUMNS.PHOTO_PATH, item.photoPath); |
91 | 91 |
cv.put(DBHelper.PHOTO_INFO_COLUMNS.SESSION_ID, item.sessionId); |
92 | 92 |
cv.put(DBHelper.PHOTO_INFO_COLUMNS.LENSMAN_ID,item.lensmanId); |
93 |
- cv.put(DBHelper.PHOTO_INFO_COLUMNS.IS_UPLOADED,item.isUploaded); |
|
93 |
+ cv.put(DBHelper.PHOTO_INFO_COLUMNS.UPLOADED_STATUS,item.uploadStatus); |
|
94 | 94 |
cv.put(DBHelper.PHOTO_INFO_COLUMNS.SESSION_DATE,item.sessionDate); |
95 | 95 |
cv.put(DBHelper.PHOTO_INFO_COLUMNS.SESSION_SEQ,item.sessionSeq); |
96 | 96 |
return cv; |
@@ -222,7 +222,7 @@ public class DBService { |
||
222 | 222 |
db = dbHelper.getReadableDatabase(); |
223 | 223 |
db.beginTransaction(); |
224 | 224 |
c = db.rawQuery("select * from " + DBHelper.PHOTO_INFO_TABLE + " where " |
225 |
- + DBHelper.PHOTO_INFO_COLUMNS.IS_UPLOADED + " = '" + 0 + "'"+" order by " |
|
225 |
+ + DBHelper.PHOTO_INFO_COLUMNS.UPLOADED_STATUS + " = '" + 0 + "'"+" order by " |
|
226 | 226 |
+ DBHelper.PHOTO_INFO_COLUMNS.CAPTURE_TIME + " desc limit 1 ", null); |
227 | 227 |
if (c.moveToNext()) { |
228 | 228 |
photoBean = cursor2PhotoBean(c); |
@@ -44,7 +44,7 @@ public class UploadService extends Service implements UploadTask.OnPhotoUploadLi |
||
44 | 44 |
@Override |
45 | 45 |
public void onPhotoUploadSucceed(PhotoBean bean) { |
46 | 46 |
if(bean.equals(currentPhoto)){ |
47 |
- currentPhoto.isUploaded = true; |
|
47 |
+ currentPhoto.uploadStatus = PhotoBean.UploadStatus.STATUS_SUCCESS; |
|
48 | 48 |
DBService.getInstance().updatePhotoBean(currentPhoto); |
49 | 49 |
if(listener!=null){ |
50 | 50 |
listener.onPhotoUploaded(currentPhoto); |
@@ -57,6 +57,8 @@ public class UploadService extends Service implements UploadTask.OnPhotoUploadLi |
||
57 | 57 |
@Override |
58 | 58 |
public void onPhotoUploadFail(PhotoBean bean) { |
59 | 59 |
if(bean.equals(currentPhoto)){ |
60 |
+ currentPhoto.uploadStatus = PhotoBean.UploadStatus.STATUS_ERROR; |
|
61 |
+ DBService.getInstance().updatePhotoBean(currentPhoto); |
|
60 | 62 |
currentPhoto = null; |
61 | 63 |
} |
62 | 64 |
startUpload(); |
@@ -101,7 +101,7 @@ public class SessionInteractor { |
||
101 | 101 |
public void run() { |
102 | 102 |
fetchThumbnailTask(); |
103 | 103 |
} |
104 |
- },1000,5000); |
|
104 |
+ },1000,1000); |
|
105 | 105 |
} |
106 | 106 |
|
107 | 107 |
private void fetchThumbnailTask(){ |
@@ -123,7 +123,7 @@ public class SessionInteractor { |
||
123 | 123 |
} |
124 | 124 |
bean.captureTime = bean.photoId; |
125 | 125 |
bean.isRawPhoto = false; |
126 |
- bean.isUploaded = false; |
|
126 |
+ bean.uploadStatus = PhotoBean.UploadStatus.STATUS_NO_BEGIN; |
|
127 | 127 |
bean.sessionId = sessionBean.sessionId; |
128 | 128 |
bean.lensmanId = sessionBean.lensmanId; |
129 | 129 |
bean.sessionSeq = sessionBean.sessionSeq; |
@@ -154,7 +154,7 @@ public class SessionInteractor { |
||
154 | 154 |
bean.photoPath = file.getString("path"); |
155 | 155 |
bean.captureTime = bean.photoId; |
156 | 156 |
bean.isRawPhoto = false; |
157 |
- bean.isUploaded = false; |
|
157 |
+ bean.uploadStatus = PhotoBean.UploadStatus.STATUS_NO_BEGIN; |
|
158 | 158 |
bean.sessionId = sessionBean.sessionId; |
159 | 159 |
bean.lensmanId = sessionBean.lensmanId; |
160 | 160 |
bean.sessionSeq = sessionBean.sessionSeq; |
@@ -73,26 +73,38 @@ public class SessionRecyclerAdapter extends RecyclerView.Adapter<SessionRecycler |
||
73 | 73 |
return; |
74 | 74 |
} |
75 | 75 |
final SessionBean item = sessionList.get(position); |
76 |
+ |
|
77 |
+ int height = width; |
|
78 |
+ ViewGroup.LayoutParams lp=holder.photo.getLayoutParams(); |
|
79 |
+ lp.width = width; |
|
80 |
+ lp.height = height; |
|
81 |
+ holder.photo.setLayoutParams(lp); |
|
82 |
+ holder.sesseionSeq.setText(String.valueOf(item.sessionSeq)); |
|
76 | 83 |
ArrayList<PhotoBean> photoList = item.sessionPhotos; |
84 |
+ |
|
77 | 85 |
if(photoList!=null && photoList.size()>0){ |
78 | 86 |
String path = Constants.APP_IMAGE_DIR + File.separator+item.sessionId+File.separator |
79 | 87 |
+Constants.THUMBNAIL_DIR_NAME+File.separator+item.sessionPhotos.get(0).photoName; |
80 | 88 |
ImageLoaderUtils.displayLocalImage(path, holder.photo, options); |
81 | 89 |
int uploaded = 0; |
90 |
+ int error = 0; |
|
82 | 91 |
for(PhotoBean bean : photoList){ |
83 |
- if(bean.isUploaded){ |
|
92 |
+ if(bean.uploadStatus == PhotoBean.UploadStatus.STATUS_SUCCESS){ |
|
84 | 93 |
uploaded++; |
85 | 94 |
} |
95 |
+ if(bean.uploadStatus == PhotoBean.UploadStatus.STATUS_ERROR){ |
|
96 |
+ error++; |
|
97 |
+ } |
|
98 |
+ } |
|
99 |
+ if(error>0){ |
|
100 |
+ holder.uploadStatus.setText(R.string.upload_error); |
|
101 |
+ }else if(uploaded<photoList.size()){ |
|
102 |
+ holder.uploadStatus.setText(R.string.upload_processing); |
|
103 |
+ }else{ |
|
104 |
+ holder.uploadStatus.setText(R.string.upload_success); |
|
86 | 105 |
} |
87 |
- holder.uploadStatus.setText(getUploadStatusText(item.sessionPhotos)); |
|
88 | 106 |
holder.uploadProgressBar.setProgress(100*uploaded/photoList.size()); |
89 | 107 |
} |
90 |
- int height = width; |
|
91 |
- ViewGroup.LayoutParams lp=holder.photo.getLayoutParams(); |
|
92 |
- lp.width = width; |
|
93 |
- lp.height = height; |
|
94 |
- holder.photo.setLayoutParams(lp); |
|
95 |
- holder.sesseionSeq.setText(String.valueOf(item.sessionSeq)); |
|
96 | 108 |
holder.itemView.setOnClickListener(new View.OnClickListener(){ |
97 | 109 |
@Override |
98 | 110 |
public void onClick(View v) { |
@@ -111,18 +123,6 @@ public class SessionRecyclerAdapter extends RecyclerView.Adapter<SessionRecycler |
||
111 | 123 |
return sessionList.size(); |
112 | 124 |
} |
113 | 125 |
|
114 |
- private String getUploadStatusText(ArrayList<PhotoBean> photoList){ |
|
115 |
- int uploaded = 0; |
|
116 |
- for(PhotoBean bean : photoList){ |
|
117 |
- if(bean.isUploaded){ |
|
118 |
- uploaded++; |
|
119 |
- } |
|
120 |
- } |
|
121 |
- String uploadStr = uploaded+"/"+photoList.size(); |
|
122 |
- |
|
123 |
- return uploadStr; |
|
124 |
- } |
|
125 |
- |
|
126 | 126 |
|
127 | 127 |
class MyViewHolder extends RecyclerView.ViewHolder{ |
128 | 128 |
|
@@ -95,7 +95,7 @@ public class UploadActivity extends BaseActivity implements UploadContract.View |
||
95 | 95 |
|
96 | 96 |
@Override |
97 | 97 |
public void updateSessionUploadViewAt(int position) { |
98 |
- |
|
98 |
+ adapter.notifyItemChanged(position); |
|
99 | 99 |
} |
100 | 100 |
|
101 | 101 |
@Override |
@@ -120,7 +120,7 @@ public class UploadPresenter implements UploadContract.Presenter,BaseInteractor. |
||
120 | 120 |
}else{ |
121 | 121 |
for(PhotoBean photoBean : photoList){ |
122 | 122 |
if(photoBean.photoId == bean.photoId){ |
123 |
- photoBean.isUploaded = true; |
|
123 |
+ photoBean.uploadStatus = PhotoBean.UploadStatus.STATUS_SUCCESS; |
|
124 | 124 |
break; |
125 | 125 |
} |
126 | 126 |
} |
@@ -14,6 +14,10 @@ |
||
14 | 14 |
<string name="login_fail">登录失败</string> |
15 | 15 |
<string name="please_wait">请稍候</string> |
16 | 16 |
|
17 |
+ <string name="upload_processing">上传中</string> |
|
18 |
+ <string name="upload_error">上传失败</string> |
|
19 |
+ <string name="upload_success">上传成功</string> |
|
20 |
+ |
|
17 | 21 |
<string name="network_disconnect">当前无网络连接</string> |
18 | 22 |
|
19 | 23 |
<string name="qr_scan_hint">将取景框对准二维码,\n即可自动扫码</string> |