bean.photoPath = file.getString("path");
+ bean.captureTime = bean.photoId;
+ bean.isRawPhoto = false;
+ bean.isUploaded = false;
+ bean.sessionId = sessionId;
+ photoList.add(bean);
+ }
+ }
+ return true;
+ }
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ @Override
+ protected void onPostFail() {
+ super.onPostFail();
+ }
+
+ @Override
+ protected void onPostSuccess() {
+ super.onPostSuccess();
+ listener.onSessionPhotoCaptured(photoList);
+ }
+ };
+ fetchThumbnailTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), BoxUrlContainer.FETCH_THUMBNAIL_URL);
}
public void endSession(){
+ cancelTask(sessionEndTask);
+ HashMap<String,String> params = new HashMap<>();
+ params.put("lensman",lensmanId);
+ params.put("session",sessionId);
+ sessionEndTask = new HttpPostTask(params);
+ sessionEndTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), BoxUrlContainer.SESSION_END_URL);
if(timer!=null){
timer.cancel();
timer = null;
}
+ listener.onSessionEnd(sessionId);
+ }
+ private void cancelTask(HttpPostTask task){
+ if(task==null){
+ return;
+ }
+ if(task.getStatus()== AsyncTask.Status.RUNNING){
+ task.cancel(true);
+ }
}
}
@@ -1,23 +1,19 @@ |
||
| 1 | 1 |
package ai.pai.lensman.session; |
| 2 | 2 |
|
| 3 |
-import android.content.Context; |
|
| 4 |
- |
|
| 5 | 3 |
import java.util.ArrayList; |
| 6 | 4 |
|
| 7 | 5 |
import ai.pai.lensman.bean.PhotoBean; |
| 8 | 6 |
|
| 9 | 7 |
public class SessionPresenter implements SessionContract.Presenter,SessionInteractor.SessionListener{
|
| 10 | 8 |
|
| 11 |
- private Context context; |
|
| 12 | 9 |
private SessionInteractor interactor; |
| 13 | 10 |
private ArrayList<PhotoBean> photoList; |
| 14 | 11 |
private SessionContract.View sessionView; |
| 15 | 12 |
|
| 16 |
- public SessionPresenter(Context context, String sessionId, SessionContract.View view){
|
|
| 17 |
- this.context = context; |
|
| 13 |
+ public SessionPresenter(String lensmanId, String sessionId, SessionContract.View view){
|
|
| 18 | 14 |
this.sessionView = view; |
| 19 | 15 |
photoList = new ArrayList<>(); |
| 20 |
- interactor = new SessionInteractor(context,sessionId,this); |
|
| 16 |
+ interactor = new SessionInteractor(lensmanId,sessionId,this); |
|
| 21 | 17 |
} |
| 22 | 18 |
|
| 23 | 19 |
@Override |
@@ -37,18 +33,21 @@ public class SessionPresenter implements SessionContract.Presenter,SessionIntera |
||
| 37 | 33 |
|
| 38 | 34 |
@Override |
| 39 | 35 |
public void onSessionStartSuccess(String session) {
|
| 40 |
- |
|
| 36 |
+ sessionView.showToast("session启动成功");
|
|
| 41 | 37 |
} |
| 42 | 38 |
|
| 43 | 39 |
@Override |
| 44 | 40 |
public void onSessionStartError(String session) {
|
| 45 |
- |
|
| 41 |
+ sessionView.showToast("session启动失败");
|
|
| 46 | 42 |
} |
| 47 | 43 |
|
| 48 | 44 |
@Override |
| 49 |
- public void onSessionPhotoCaptured(final PhotoBean bean) {
|
|
| 45 |
+ public void onSessionPhotoCaptured(final ArrayList<PhotoBean> beans) {
|
|
| 50 | 46 |
sessionView.showPhotoRecyclerView(); |
| 51 |
- sessionView.addNewPhoto(bean); |
|
| 47 |
+ sessionView.showToast("发现新增照片"+beans.size()+"张");
|
|
| 48 |
+ for (PhotoBean bean : beans){
|
|
| 49 |
+ sessionView.addNewPhoto(bean); |
|
| 50 |
+ } |
|
| 52 | 51 |
} |
| 53 | 52 |
|
| 54 | 53 |
@Override |