lines-num-new">
-            }
104
-        },1000,10);
105
-        LogHelper.d("czy","startCapture ,schedule fetchPhotoTask ");
106
-    }
107
-
108
-    private void fetchPhotoTask(){
109
-        if(!isWorking){
110
-            return;
111
-        }
80
+        Intent intent = new Intent(App.getAppContext(), CameraService.class);
81
+        intent.putExtra(EXTRA_CMD,CMD_START_CAPTURE_PHOTO);
82
+        App.getAppContext().startService(intent);
112 83
 
113
-        if(!isLastQueryReturned){
114
-            LogHelper.d("czy","fetchPhotoTask last query not finished,return ");
115
-            return;
116
-        }
117
-
118
-        isLastQueryReturned = false;
119
-        String eventMsg = CameraJNIInterface.getInstance().java_mygpcamerawaitforevent(sessionWorkingDirPath);
120
-        listener.onCameraStatusChanged("mygpcamerawaitforevent return "+eventMsg);
121
-        LogHelper.d("czy","mygpcamerawaitforevent return result = "+eventMsg);
122
-        if(eventMsg!=null && eventMsg.length()>0){
123
-            if(MSG_TYPE_NOT_INIT.equalsIgnoreCase(eventMsg)||MSG_TYPE_CAMERA_ERROR.equalsIgnoreCase(eventMsg)){
124
-                endSession();
125
-                startSession();
126
-            }else if(MSG_TYPE_TIME_OUT.equalsIgnoreCase(eventMsg)){
127
-
128
-            }else{
129
-                String sub = eventMsg.substring(0,1);
130
-                if(TextUtils.isDigitsOnly(sub)){
131
-                    LogHelper.d(TAG,"fetchPhotoTask new photo found");
132
-                    PhotoBean bean = new PhotoBean();
133
-                    bean.photoName = eventMsg;
134
-                    bean.photoId = Long.parseLong(eventMsg.substring(0,eventMsg.lastIndexOf(".")));
135
-                    bean.captureTime = bean.photoId;
136
-                    bean.isRawPhoto = true;
137
-                    bean.uploadStatus = PhotoBean.UploadStatus.STATUS_NO_BEGIN;
138
-                    bean.sessionId = sessionBean.sessionId;
139
-                    bean.lensmanId = sessionBean.lensmanId;
140
-                    bean.sessionSeq = sessionBean.sessionSeq;
141
-                    bean.sessionDate = sessionBean.sessionDate;
142
-                    bean.sessionCreateTime = sessionBean.createTime;
143
-                    bean.photoPath = sessionWorkingDirPath+File.separator+eventMsg;
144
-                    listener.onSessionPhotoCaptured(bean);
145
-                }
146
-            }
147
-        }
148
-
149
-        isLastQueryReturned = true;
150 84
     }
151 85
 
152 86
 
153
-
154 87
     public void endSession(){
155
-        isWorking = false;
156
-        if(photoCaptureTimer !=null){
157
-            photoCaptureTimer.cancel();
158
-            photoCaptureTimer = null;
159
-        }
160
-        int result = CameraJNIInterface.getInstance().java_mygpcameraexit();
161
-        listener.onCameraStatusChanged("mygpcameraexit return "+result);
162
-        listener.onSessionEnd(sessionBean.sessionId);
163
-        if(cameraInitHandler!=null){
164
-            cameraInitHandler.removeCallbacksAndMessages(null);
165
-            cameraInitHandler = null;
88
+        if(mHandler!=null){
89
+            mHandler.removeCallbacksAndMessages(null);
90
+            mHandler = null;
166 91
         }
92
+        Intent intent = new Intent(App.getAppContext(), CameraService.class);
93
+        intent.putExtra(EXTRA_CMD,CMD_EXIT_CAMERA_CONNECTION);
94
+        App.getAppContext().startService(intent);
95
+        App.getAppContext().unregisterReceiver(cameraReceiver);
167 96
         LogHelper.d("czy","endSession ");
97
+        listener.onSessionEnd(sessionBean.sessionId);
168 98
     }
169 99
 
170 100
     public void deletePhoto(PhotoBean photoBean){
@@ -172,4 +102,41 @@ public class SessionInteractor implements Callback{
172 102
         new File(photoBean.photoPath).delete();
173 103
     }
174 104
 
105
+    private BroadcastReceiver cameraReceiver = new BroadcastReceiver() {
106
+        @Override
107
+        public void onReceive(Context context, Intent intent) {
108
+            if(!ACTION_CAMERA_SERVICE_STATUS_CHANGE.equals(intent.getAction())){
109
+                return;
110
+            }
111
+            int status = intent.getIntExtra(EXTRA_STATUS_PART,0);
112
+            if(status==MSG_CAMERA_INIT_SUCCESS){
113
+                listener.onSessionStartSuccess(sessionBean.sessionId);
114
+                listener.onCameraStatusChanged("camera init success");
115
+                startCapture();
116
+            }else if(status == MSG_CAMERA_CONN_ERROR){
117
+                listener.onCameraStatusChanged("camera connection error");
118
+                listener.onSessionStartError(sessionBean.sessionId);
119
+                mHandler.sendEmptyMessageDelayed(MSG_RETRY_INIT_CAMERA,3000);
120
+            }else if(status == MSG_CAMERA_NEW_PHOTO_FOUND){
121
+                String eventMsg = intent.getStringExtra(EXTRA_DATA_PART);
122
+                LogHelper.d(TAG,"fetchPhotoTask new photo found");
123
+                listener.onCameraStatusChanged("camera new Photo found "+eventMsg);
124
+                PhotoBean bean = new PhotoBean();
125
+                bean.photoName = eventMsg;
126
+                bean.photoId = Long.parseLong(eventMsg.substring(0,eventMsg.lastIndexOf(".")));
127
+                bean.captureTime = bean.photoId;
128
+                bean.isRawPhoto = true;
129
+                bean.uploadStatus = PhotoBean.UploadStatus.STATUS_NO_BEGIN;
130
+                bean.sessionId = sessionBean.sessionId;
131
+                bean.lensmanId = sessionBean.lensmanId;
132
+                bean.sessionSeq = sessionBean.sessionSeq;
133
+                bean.sessionDate = sessionBean.sessionDate;
134
+                bean.sessionCreateTime = sessionBean.createTime;
135
+                bean.photoPath = sessionWorkingDirPath+File.separator+eventMsg;
136
+                listener.onSessionPhotoCaptured(bean);
137
+            }
138
+
139
+        }
140
+    };
141
+
175 142
 }

pai2 - Gogs: Go Git Service

拍爱

Brightcells: 904fabf2d0 modify join policy in api group_join_api преди 10 години
account 454f8cd8ec change some info store in redis & remove some unnecessary params check & add some return for some api преди 10 години
api 537bd9bd41 add api group_quit_api преди 10 години
group 904fabf2d0 modify join policy in api group_join_api преди 10 години
message ff0a63215f Fix Bug: redis .replace(microsecond=0) преди 10 години
operation ebaa78d5ad add api feedback_api преди 10 години
page 8b7c49ddb9 add app to add page user_agreement/contact_us преди 10 години
pai2 8493e9949f add pagination for group_list_api преди 10 години
pay ff0a63215f Fix Bug: redis .replace(microsecond=0) преди 10 години
photo 454f8cd8ec change some info store in redis & remove some unnecessary params check & add some return for some api преди 10 години
utils 537bd9bd41 add api group_quit_api преди 10 години
.editorconfig 4defb80fdc gogs first init преди 10 години
.gitignore 4defb80fdc gogs first init преди 10 години
manage.py 4defb80fdc gogs first init преди 10 години
pep8.sh 4defb80fdc gogs first init преди 10 години
requirements.txt 7a17d0fb90 add api wxpay & add redis relative преди 10 години