@Override
|
|
188
|
194
|
protected void onPostSuccess() {
|
|
189
|
195
|
super.onPostSuccess();
|
|
|
196
|
+ LogHelper.d(TAG,"fetchThumbnailTask onPostSuccess with photo number = "+photoList.size());
|
|
190
|
197
|
for(PhotoBean bean :photoList){
|
|
191
|
198
|
new SavePhotoTask(bean).executeOnExecutor(ThreadExecutor.getInstance().getExecutor(),bean);
|
|
|
199
|
+ LogHelper.d(TAG,"SavePhotoTask starts "+bean);
|
|
192
|
200
|
}
|
|
193
|
201
|
}
|
|
194
|
202
|
};
|
|
195
|
203
|
fetchThumbnailTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), BoxUrlContainer.FETCH_THUMBNAIL_URL);
|
|
|
204
|
+ LogHelper.d(TAG,"fetchThumbnailTask starts");
|
|
196
|
205
|
}
|
|
197
|
206
|
|
|
198
|
207
|
|
|
|
|
@@ -210,7 +219,7 @@ public class SessionInteractor {
|
|
210
|
219
|
if(BuildConfig.isTestMode){
|
|
211
|
220
|
path = photoBean.photoPath;
|
|
212
|
221
|
}
|
|
213
|
|
- LogHelper.d(TAG,"保存照片到本地,图片链接地址为"+path);
|
|
|
222
|
+ LogHelper.d(TAG,"SavePhotoTask save photo to phone , photo remote url = "+path);
|
|
214
|
223
|
FileOutputStream fOut = null;
|
|
215
|
224
|
HttpURLConnection conn = null;
|
|
216
|
225
|
InputStream inStream = null;
|
|
|
|
@@ -233,11 +242,11 @@ public class SessionInteractor {
|
|
233
|
242
|
fOut.flush();
|
|
234
|
243
|
}
|
|
235
|
244
|
fOut.flush();
|
|
236
|
|
- LogHelper.d(TAG,"保存照片到本地,图片保存至"+file.getAbsolutePath()+"图片大小为"+file.length()+"字节\n\n");
|
|
|
245
|
+ LogHelper.d(TAG,"SavePhotoTask save photo to local path = "+file.getAbsolutePath()+" photo bytes = "+file.length()+"\n");
|
|
237
|
246
|
}
|
|
238
|
247
|
return true;
|
|
239
|
248
|
} catch (Exception e) {
|
|
240
|
|
- e.printStackTrace();
|
|
|
249
|
+ LogHelper.e(TAG,"SavePhotoTask exception occurs "+e);
|
|
241
|
250
|
} finally {
|
|
242
|
251
|
try{
|
|
243
|
252
|
inStream.close();
|
|
|
|
@@ -247,6 +256,11 @@ public class SessionInteractor {
|
|
247
|
256
|
e.printStackTrace();
|
|
248
|
257
|
}
|
|
249
|
258
|
}
|
|
|
259
|
+ try{
|
|
|
260
|
+ Thread.sleep(2000);
|
|
|
261
|
+ }catch (Exception e){
|
|
|
262
|
+ e.printStackTrace();
|
|
|
263
|
+ }
|
|
250
|
264
|
return false;
|
|
251
|
265
|
}
|
|
252
|
266
|
|
|
|
|
@@ -254,8 +268,10 @@ public class SessionInteractor {
|
|
254
|
268
|
protected void onPostExecute(Boolean result) {
|
|
255
|
269
|
super.onPostExecute(result);
|
|
256
|
270
|
if (result) {
|
|
|
271
|
+ LogHelper.d(TAG,"SavePhotoTask onPostExecute success " + photoBean);
|
|
257
|
272
|
listener.onSessionPhotoCaptured(photoBean);
|
|
258
|
273
|
}else{
|
|
|
274
|
+ LogHelper.d(TAG,"SavePhotoTask onPostExecute fail and retry "+photoBean);
|
|
259
|
275
|
new SavePhotoTask(photoBean).executeOnExecutor(ThreadExecutor.getInstance().getExecutor(),photoBean);
|
|
260
|
276
|
}
|
|
261
|
277
|
}
|
|
|
|
@@ -275,7 +291,7 @@ public class SessionInteractor {
|
|
275
|
291
|
params.put("session",randomSessionId);
|
|
276
|
292
|
sessionEndTask = new HttpPostTask(params);
|
|
277
|
293
|
sessionEndTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), BoxUrlContainer.SESSION_END_URL);
|
|
278
|
|
-
|
|
|
294
|
+ LogHelper.d(TAG,"sessionEndTask execute ");
|
|
279
|
295
|
listener.onSessionEnd(sessionBean.sessionId);
|
|
280
|
296
|
}
|
|
281
|
297
|
|
|
|
|
@@ -288,6 +304,7 @@ public class SessionInteractor {
|
|
288
|
304
|
params.put("path",photoBean.photoPath);
|
|
289
|
305
|
HttpPostTask deleteTask = new HttpPostTask(params);
|
|
290
|
306
|
deleteTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), BoxUrlContainer.DELETE_PHOTO_URL);
|
|
|
307
|
+ LogHelper.d(TAG,"deletePhoto execute "+photoBean);
|
|
291
|
308
|
}
|
|
292
|
309
|
|
|
293
|
310
|
private void cancelTask(HttpPostTask task){
|
|
|
|
@@ -23,7 +23,7 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter
|
|
23
|
23
|
private SessionBean sessionBean;
|
|
24
|
24
|
private boolean isWorking;
|
|
25
|
25
|
|
|
26
|
|
-
|
|
|
26
|
+ private static final String TAG = "SessionPresenter";
|
|
27
|
27
|
|
|
28
|
28
|
public SessionPresenter(SessionBean sessionBean, SessionContract.View view) {
|
|
29
|
29
|
this.sessionView = view;
|
|
|
|
@@ -32,11 +32,14 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter
|
|
32
|
32
|
|
|
33
|
33
|
@Override
|
|
34
|
34
|
public void start() {
|
|
|
35
|
+ LogHelper.d(TAG,"SessionPresenter start "+sessionBean);
|
|
35
|
36
|
interactor = new SessionInteractor(sessionBean, this);
|
|
36
|
37
|
photoList = DBService.getInstance().getPhotoListBySessionId(sessionBean.sessionId);
|
|
37
|
38
|
if (photoList.size() == 0) {
|
|
|
39
|
+ LogHelper.d(TAG,"SessionPresenter start and found no old photos");
|
|
38
|
40
|
sessionView.showEmptyView();
|
|
39
|
41
|
} else {
|
|
|
42
|
+ LogHelper.d(TAG,"SessionPresenter start and found old photos, size = "+photoList.size());
|
|
40
|
43
|
sessionView.showPhotoRecyclerView();
|
|
41
|
44
|
for (PhotoBean photoBean : photoList) {
|
|
42
|
45
|
sessionView.addNewPhoto(photoBean);
|
|
|
|
@@ -51,12 +54,14 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter
|
|
51
|
54
|
interactor.endSession();
|
|
52
|
55
|
Preferences.getInstance().setCurrentSession("");
|
|
53
|
56
|
isWorking = false;
|
|
|
57
|
+ LogHelper.d(TAG,"stop");
|
|
54
|
58
|
}
|
|
55
|
59
|
|
|
56
|
60
|
@Override
|
|
57
|
61
|
public void onSessionStartSuccess(String session) {
|
|
58
|
62
|
isWorking = true;
|
|
59
|
63
|
sessionView.showToast("session启动成功");
|
|
|
64
|
+ LogHelper.d(TAG,"onSessionStartSuccess session启动成功"+session);
|
|
60
|
65
|
}
|
|
61
|
66
|
|
|
62
|
67
|
@Override
|
|
|
|
@@ -66,6 +71,7 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter
|
|
66
|
71
|
}
|
|
67
|
72
|
sessionView.showToast("session启动失败,自动重试中");
|
|
68
|
73
|
interactor.startSession();
|
|
|
74
|
+ LogHelper.d(TAG,"onSessionStartError session启动失败,自动重试中");
|
|
69
|
75
|
}
|
|
70
|
76
|
|
|
71
|
77
|
@Override
|
|
|
|
@@ -78,6 +84,7 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter
|
|
78
|
84
|
return;
|
|
79
|
85
|
}
|
|
80
|
86
|
}
|
|
|
87
|
+ LogHelper.d(TAG,"onSessionPhotoCaptured "+bean);
|
|
81
|
88
|
DBService.getInstance().addPhotoBean(bean);
|
|
82
|
89
|
sessionView.showPhotoRecyclerView();
|
|
83
|
90
|
sessionView.addNewPhoto(bean);
|
|
|
|
@@ -87,7 +94,7 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter
|
|
87
|
94
|
|
|
88
|
95
|
@Override
|
|
89
|
96
|
public void onSessionEnd(String session) {
|
|
90
|
|
-
|
|
|
97
|
+ LogHelper.d(TAG,"onSessionEnd "+session);
|
|
91
|
98
|
}
|
|
92
|
99
|
|
|
93
|
100
|
@Override
|
|
|
|
@@ -103,7 +110,7 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter
|
|
103
|
110
|
|
|
104
|
111
|
@Override
|
|
105
|
112
|
public void change2QRCodeSessionId(String sessionId) {
|
|
106
|
|
- LogHelper.d("czy","change2QRCodeSessionId ="+sessionId);
|
|
|
113
|
+ LogHelper.d(TAG,"change2QRCodeSessionId 使用新sessionId = "+sessionId);
|
|
107
|
114
|
this.sessionBean.sessionId = sessionId;
|
|
108
|
115
|
stop();
|
|
109
|
116
|
start();
|