-        ArrayList<PhotoBean> photoList = DBService.getInstance().getPhotoListBySessionId(sessionBean.sessionId);
46
-        if(photoList!=null && photoList.size()>0){
47
-            for(PhotoBean photoBean : photoList){
48
-                if(photoBean.photoId>maxId){
49
-                    maxId = photoBean.photoId;
50
-                }
67
+        int result = CameraJNIInterface.getInstance().mygpcamerainit();
68
+        if(result>=0){
69
+            listener.onSessionStartSuccess(sessionBean.sessionId);
70
+            isWorking = true;
71
+            startCapture();
72
+        }else{
73
+            if(cameraInitHandler!=null){
74
+                cameraInitHandler.removeCallbacksAndMessages(null);
75
+                cameraInitHandler = null;
51 76
             }
77
+            cameraInitHandler = new Handler(this);
78
+            cameraInitHandler.sendEmptyMessageDelayed(MSG_CAMERA_INIT_EVENT,1000);
79
+            listener.onSessionStartError(sessionBean.sessionId);
52 80
         }
53 81
 
54
-        listener.onSessionStartSuccess(sessionBean.sessionId);
55
-        isWorking = true;
56
-        startCapture();
57
-
58 82
         LogHelper.d(TAG,"startSession sessionStartTask execute");
59 83
     }
60 84
 
61 85
     public void startCapture() {
62
-        int result = CameraJNIInterface.getInstance().mygpcamerainit();
63
-        if(result>=0){
64
-            LogHelper.d(TAG,"相机信息--->\n"+CameraJNIInterface.getInstance().mygpcameragetsummary());
65
-            Toast.makeText(App.getAppContext(),CameraJNIInterface.getInstance().mygpcameragetsummary(),Toast.LENGTH_SHORT).show();
66
-
86
+        if(photoCaptureTimer !=null){
87
+            photoCaptureTimer.cancel();
88
+            photoCaptureTimer = null;
67 89
         }
68
-        if(timer!=null){
69
-            timer.cancel();
70
-            timer = null;
71
-        }
72
-        timer = new Timer();
73
-        timer.schedule(new TimerTask() {
90
+        photoCaptureTimer = new Timer();
91
+        photoCaptureTimer.schedule(new TimerTask() {
74 92
             @Override
75 93
             public void run() {
76 94
                 fetchPhotoTask();
77 95
             }
78
-        },5000,1000);
96
+        },2000,1000);
79 97
     }
80 98
 
81 99
     private void fetchPhotoTask(){
@@ -87,43 +105,50 @@ public class SessionInteractor {
87 105
             return;
88 106
         }
89 107
 
90
-        if(BuildConfig.isTestMode){
91
-            PhotoBean bean = new PhotoBean();
92
-            long milisec = System.currentTimeMillis();
93
-            bean.photoName = milisec+".jpg";
94
-            bean.photoId = milisec;
95
-
96
-            bean.captureTime = bean.photoId;
97
-            bean.isRawPhoto = false;
98
-            bean.uploadStatus = PhotoBean.UploadStatus.STATUS_NO_BEGIN;
99
-            bean.sessionId = sessionBean.sessionId;
100
-            bean.lensmanId = sessionBean.lensmanId;
101
-            bean.sessionSeq = sessionBean.sessionSeq;
102
-            bean.sessionDate = sessionBean.sessionDate;
103
-            bean.sessionCreateTime = sessionBean.createTime;
104
-            //TODO
105
-            return;
108
+        isLastQueryReturned = false;
109
+        String photoName = CameraJNIInterface.getInstance().mygpcamerawaitforevent(sessionWorkingDirPath);
110
+        if(photoName!=null && photoName.length()>0){
111
+            String sub = photoName.substring(0,1);
112
+            if(TextUtils.isDigitsOnly(sub)){
113
+                LogHelper.d(TAG,"fetchPhotoTask new photo found");
114
+                PhotoBean bean = new PhotoBean();
115
+                bean.photoName = photoName;
116
+                bean.photoId = Long.parseLong(photoName.substring(0,photoName.lastIndexOf(".")));
117
+                bean.captureTime = bean.photoId;
118
+                bean.isRawPhoto = true;
119
+                bean.uploadStatus = PhotoBean.UploadStatus.STATUS_NO_BEGIN;
120
+                bean.sessionId = sessionBean.sessionId;
121
+                bean.lensmanId = sessionBean.lensmanId;
122
+                bean.sessionSeq = sessionBean.sessionSeq;
123
+                bean.sessionDate = sessionBean.sessionDate;
124
+                bean.sessionCreateTime = sessionBean.createTime;
125
+                bean.photoPath = Constants.APP_IMAGE_DIR+File.separator+photoName;
126
+                listener.onSessionPhotoCaptured(bean);
127
+            }
106 128
         }
107 129
 
108
-        isLastQueryReturned = false;
109
-        LogHelper.d(TAG,"fetchPhotoTask starts");
130
+        isLastQueryReturned = true;
110 131
     }
111 132
 
112 133
 
113 134
 
114 135
     public void endSession(){
115 136
         isWorking = false;
116
-        if(timer!=null){
117
-            timer.cancel();
118
-            timer = null;
137
+        if(photoCaptureTimer !=null){
138
+            photoCaptureTimer.cancel();
139
+            photoCaptureTimer = null;
119 140
         }
120
-        //TODO
141
+        CameraJNIInterface.getInstance().mygpcameraexit();
121 142
         listener.onSessionEnd(sessionBean.sessionId);
143
+        if(cameraInitHandler!=null){
144
+            cameraInitHandler.removeCallbacksAndMessages(null);
145
+            cameraInitHandler = null;
146
+        }
122 147
     }
123 148
 
124 149
     public void deletePhoto(PhotoBean photoBean){
125
-        //TODO
126 150
         LogHelper.d(TAG,"deletePhoto execute "+photoBean);
151
+        new File(photoBean.photoPath).delete();
127 152
     }
128 153
 
129 154
 }

+ 3 - 2
app/src/main/java/ai/pai/lensman/session/SessionPresenter.java

@@ -10,6 +10,7 @@ import java.util.TimerTask;
10 10
 
11 11
 import ai.pai.lensman.App;
12 12
 import ai.pai.lensman.BuildConfig;
13
+import ai.pai.lensman.R;
13 14
 import ai.pai.lensman.bean.PhotoBean;
14 15
 import ai.pai.lensman.bean.SessionBean;
15 16
 import ai.pai.lensman.db.DBService;
@@ -72,13 +73,13 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter
72 73
 
73 74
     @Override
74 75
     public void onSessionStartSuccess(String session) {
75
-        sessionView.showToast("session启动成功");
76
+        sessionView.showToast(App.getAppContext().getString(R.string.session_start_success));
76 77
         LogHelper.d(TAG,"onSessionStartSuccess session启动成功"+session);
77 78
     }
78 79
 
79 80
     @Override
80 81
     public void onSessionStartError(String session) {
81
-        sessionView.showToast("session启动失败");
82
+        sessionView.showToast(App.getAppContext().getString(R.string.session_start_success));
82 83
     }
83 84
 
84 85
     @Override

+ 4 - 0
app/src/main/res/values/strings.xml

@@ -134,4 +134,8 @@
134 134
 
135 135
     <string name="check_box_time">请检查手机时间设置是否正确</string>
136 136
 
137
+    <string name="session_start_success">拍摄启动成功</string>
138
+
139
+    <string name="session_start_error">拍摄启动失败,请检查相机及连接线</string>
140
+
137 141
 </resources>

Kodo/kodosale - Gogs: Go Git Service

21 Commits (ad4a1544a083afe549e871e1633a21a1de6fd69c)

Author SHA1 Message Date
  FFIB cecb9c9913 add live relation 5 years ago
  FFIB 5bc4da0014 add pay/wx/order/cancel 5 years ago
  FFIB 482b94dc17 update verify inventory 5 years ago
  FFIB 6fbade4618 Merge branch 'master' of http://git.xfoto.com.cn/Kodo/kodosale 5 years ago
  FFIB a6445da699 先销库存 5 years ago
  huangqimin 5aabafb40e :art: Remove u 5 years ago
  huangqimin 7923ca72e4 :art: Format Codes 5 years ago
  huangqimin ecae93df3f :bug: Fix Bug: error.message was deprecated in Python 2.6 and removed in Python 3 5 years ago
  FFIB 97513e9edd :art: Support consigness relation 5 years ago
  FFIB 31a1347ca9 update 5 years ago
  FFIB 85a1e557c5 r 5 years ago
  FFIB 74ad829b8a update 5 years ago
  FFIB 8cb1966a10 art: Support PackGoodsInfo inventory and has_sale_num related 5 years ago
  FFIB 6cabed04da update check amount 5 years ago
  huangqimin 83f79792d4 :art: Format Codes 5 years ago
  FFIB d1b83c39d0 update 5 years ago
  FFIB f9f759921d Merge branch 'master' of http://git.xfoto.com.cn/Kodo/kodosale 5 years ago
  FFIB bf09b11e80 after pay update PackGoodsSaleInfo 5 years ago
  huangqimin a329bd00d4 :art: Format Codes 5 years ago
  FFIB 8ca2aa51e3 add pay/wx/notify_url 5 years ago
  FFIB ad5c8304d1 :art: Support mini pay relative 5 years ago