@@ -23,7 +23,7 @@ android { |
||
23 | 23 |
targetSdkVersion 24 |
24 | 24 |
versionCode 1 |
25 | 25 |
versionName "1.0" |
26 |
- buildConfigField "boolean", "isTestMode", "true" |
|
26 |
+ buildConfigField "boolean", "isTestMode", "false" |
|
27 | 27 |
} |
28 | 28 |
signingConfigs { |
29 | 29 |
releaseConfig { |
@@ -2,7 +2,7 @@ package ai.pai.lensman.box; |
||
2 | 2 |
|
3 | 3 |
public final class BoxUrlContainer { |
4 | 4 |
|
5 |
- private static final String BASE_URL = "http://192.168.1.190:8002/"; |
|
5 |
+ private static final String BASE_URL = "http://192.168.1.191:8002/"; |
|
6 | 6 |
|
7 | 7 |
public static final String SESSION_START_URL = BASE_URL+"session_start"; |
8 | 8 |
|
@@ -70,7 +70,7 @@ public class PhotoRecyclerAdapter extends RecyclerView.Adapter<PhotoRecyclerAdap |
||
70 | 70 |
lp.width = width; |
71 | 71 |
lp.height = height; |
72 | 72 |
holder.photo.setLayoutParams(lp); |
73 |
- if(item.uploadStatus!= PhotoBean.UploadStatus.STATUS_ERROR){ |
|
73 |
+ if(item.uploadStatus== PhotoBean.UploadStatus.STATUS_ERROR){ |
|
74 | 74 |
holder.errorLayout.setVisibility(View.VISIBLE); |
75 | 75 |
}else{ |
76 | 76 |
holder.errorLayout.setVisibility(View.GONE); |
@@ -75,17 +75,13 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie |
||
75 | 75 |
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(mCallback); |
76 | 76 |
itemTouchHelper.attachToRecyclerView(photosRecyclerView); |
77 | 77 |
|
78 |
- } |
|
79 |
- |
|
80 |
- @Override |
|
81 |
- protected void onResume() { |
|
82 |
- super.onResume(); |
|
83 | 78 |
presenter.start(); |
84 | 79 |
} |
85 | 80 |
|
81 |
+ |
|
86 | 82 |
@Override |
87 |
- protected void onStop() { |
|
88 |
- super.onStop(); |
|
83 |
+ protected void onDestroy() { |
|
84 |
+ super.onDestroy(); |
|
89 | 85 |
presenter.stop(); |
90 | 86 |
} |
91 | 87 |
|
@@ -33,6 +33,8 @@ public class SessionInteractor { |
||
33 | 33 |
private SessionListener listener; |
34 | 34 |
private HttpPostTask sessionStartTask; |
35 | 35 |
private HttpPostTask sessionEndTask; |
36 |
+ private String randomSessionId; |
|
37 |
+ private boolean isWorking; |
|
36 | 38 |
|
37 | 39 |
private static final String TAG = "SessionInteractor"; |
38 | 40 |
|
@@ -58,7 +60,8 @@ public class SessionInteractor { |
||
58 | 60 |
cancelTask(sessionStartTask); |
59 | 61 |
HashMap<String,String> params = new HashMap<>(); |
60 | 62 |
params.put("lensman",sessionBean.lensmanId); |
61 |
- params.put("session",sessionBean.sessionId+"_"+new Random().nextInt(123456)); |
|
63 |
+ randomSessionId = sessionBean.sessionId+"_"+new Random().nextInt(123456); |
|
64 |
+ params.put("session",randomSessionId); |
|
62 | 65 |
sessionStartTask = new HttpPostTask(params){ |
63 | 66 |
@Override |
64 | 67 |
protected boolean parseResponse(String response) { |
@@ -85,6 +88,7 @@ public class SessionInteractor { |
||
85 | 88 |
protected void onPostSuccess() { |
86 | 89 |
super.onPostSuccess(); |
87 | 90 |
listener.onSessionStartSuccess(sessionBean.sessionId); |
91 |
+ isWorking = true; |
|
88 | 92 |
startCapture(); |
89 | 93 |
} |
90 | 94 |
}; |
@@ -106,6 +110,9 @@ public class SessionInteractor { |
||
106 | 110 |
} |
107 | 111 |
|
108 | 112 |
private void fetchThumbnailTask(){ |
113 |
+ if(!isWorking){ |
|
114 |
+ return; |
|
115 |
+ } |
|
109 | 116 |
if(BuildConfig.isTestMode){ |
110 | 117 |
PhotoBean bean = new PhotoBean(); |
111 | 118 |
long milisec = System.currentTimeMillis(); |
@@ -134,7 +141,7 @@ public class SessionInteractor { |
||
134 | 141 |
} |
135 | 142 |
HashMap<String,String> params = new HashMap<>(); |
136 | 143 |
params.put("lensman",sessionBean.lensmanId); |
137 |
- params.put("session",sessionBean.sessionId); |
|
144 |
+ params.put("session",randomSessionId); |
|
138 | 145 |
HttpPostTask fetchThumbnailTask = new HttpPostTask(params){ |
139 | 146 |
ArrayList<PhotoBean> photoList = new ArrayList<>(); |
140 | 147 |
@Override |
@@ -255,16 +262,19 @@ public class SessionInteractor { |
||
255 | 262 |
|
256 | 263 |
|
257 | 264 |
public void endSession(){ |
265 |
+ isWorking = false; |
|
266 |
+ if(timer!=null){ |
|
267 |
+ timer.cancel(); |
|
268 |
+ timer = null; |
|
269 |
+ } |
|
270 |
+ |
|
258 | 271 |
cancelTask(sessionEndTask); |
259 | 272 |
HashMap<String,String> params = new HashMap<>(); |
260 | 273 |
params.put("lensman",sessionBean.lensmanId); |
261 |
- params.put("session",sessionBean.sessionId); |
|
274 |
+ params.put("session",randomSessionId); |
|
262 | 275 |
sessionEndTask = new HttpPostTask(params); |
263 | 276 |
sessionEndTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), BoxUrlContainer.SESSION_END_URL); |
264 |
- if(timer!=null){ |
|
265 |
- timer.cancel(); |
|
266 |
- timer = null; |
|
267 |
- } |
|
277 |
+ |
|
268 | 278 |
listener.onSessionEnd(sessionBean.sessionId); |
269 | 279 |
} |
270 | 280 |
|