ld"> 226 255
     @Override
227 256
     public void onStorageFound(final int handle, String label) {
228 257
         adapter.addInfo("找到相机存储卡位置,句柄=" + handle + " label = " + label);
229
-//        photoIv.post(new Runnable() {
230
-////            @Override
231
-////            public void run() {
232
-////                camera.retrieveImageHandles(MyTestActivity.this, handle, PtpConstants.ObjectFormat.EXIF_JPEG);
233
-////            }
234
-////        });
235 258
     }
236 259
 
237 260
     @Override
@@ -241,19 +264,44 @@ public class MyTestActivity extends Activity implements Camera.CameraListener, C
241 264
 
242 265
     @Override
243 266
     public void onImageHandlesRetrieved(final int[] handles) {
244
-        adapter.addInfo("找到相机存储图像文件,共" + handles.length + "张");
245
-        photoIv.post(new Runnable() {
267
+        mainHandler.post(new Runnable() {
246 268
             @Override
247 269
             public void run() {
248
-                photoGridAdapter.addPhotos(handles);
270
+                if (handles.length != photoHandles.length) {
271
+                    adapter.addInfo("找到相机存储图像文件,共" + handles.length + "张");
272
+                }
273
+                ArrayList<Integer> diff = new ArrayList<>();
274
+                for (int i = 0; i < handles.length; i++) {
275
+                    boolean isMatch = false;
276
+                    for (int j = 0; j < photoHandles.length; j++) {
277
+                        if (photoHandles[j] == handles[i]) {
278
+                            isMatch = true;
279
+                            break;
280
+                        }
281
+                    }
282
+                    if (!isMatch) {
283
+                        diff.add(handles[i]);
284
+                    }
285
+                }
286
+                if (diff.size() > 0) {
287
+                    int[] diffArray = new int[diff.size()];
288
+                    for (int k = 0; k < diff.size(); k++) {
289
+                        diffArray[k] = diff.get(k);
290
+                    }
291
+                    if ((mode == 0 && initHandlesBeforeCapture) || mode == 1) {
292
+                        photoGridAdapter.addPhotos(diffArray);
293
+                    }
294
+                }
295
+                photoHandles = handles;
296
+                initHandlesBeforeCapture = true;
249 297
             }
250 298
         });
251 299
     }
252 300
 
253 301
     @Override
254 302
     public void onImageInfoRetrieved(final int objectHandle, final ObjectInfo objectInfo, final Bitmap thumbnail) {
255
-        adapter.addInfo("找到相机存储图像文件,句柄=" + objectHandle + " 文件名 = " + objectInfo.filename + " 拍摄日期 = "+ objectInfo.captureDate);
256
-        photoIv.post(new Runnable() {
303
+        adapter.addInfo("找到相机存储图像文件,句柄=" + objectHandle + " 文件名 = " + objectInfo.filename + " 拍摄日期 = " + objectInfo.captureDate);
304
+        mainHandler.post(new Runnable() {
257 305
             @Override
258 306
             public void run() {
259 307
                 Photo photo = new Photo();
@@ -267,7 +315,7 @@ public class MyTestActivity extends Activity implements Camera.CameraListener, C
267 315
     }
268 316
 
269 317
     public void retrieveImageInfo(final int handle) {
270
-        photoIv.post(new Runnable() {
318
+        mainHandler.post(new Runnable() {
271 319
             @Override
272 320
             public void run() {
273 321
                 if (camera != null) {

+ 6 - 1
app/src/main/java/ai/pai/ptp/test/TestPhotoGridAdapter.java

@@ -57,15 +57,20 @@ public class TestPhotoGridAdapter extends BaseAdapter {
57 57
         gridView.post(new Runnable() {
58 58
             @Override
59 59
             public void run() {
60
+                boolean isFound = false;
60 61
                 for(int k = 0; k < photos.size();k++){
61 62
                     if(photos.get(k).handle == newPhoto.handle){
62 63
                         photos.get(k).captureTime = newPhoto.captureTime;
63 64
                         photos.get(k).thumb = newPhoto.thumb;
64 65
                         photos.get(k).origin = newPhoto.origin;
65 66
                         photos.get(k).fileName = newPhoto.fileName;
67
+                        isFound = true;
66 68
                         break;
67 69
                     }
68 70
                 }
71
+                if(!isFound){
72
+                    photos.add(0,newPhoto);
73
+                }
69 74
                 notifyDataSetChanged();
70 75
             }
71 76
         });
@@ -81,7 +86,7 @@ public class TestPhotoGridAdapter extends BaseAdapter {
81 86
                     photo.handle = handles[k];
82 87
                     tmp.add(photo);
83 88
                 }
84
-                photos.addAll(tmp);
89
+                photos.addAll(0,tmp);
85 90
                 notifyDataSetChanged();
86 91
             }
87 92
         });

+ 2 - 0
app/src/main/java/com/remoteyourcam/usb/ptp/Camera.java

@@ -145,6 +145,8 @@ public interface Camera {
145 145
 
146 146
     void capture();
147 147
 
148
+    void openCapture();
149
+
148 150
     boolean isLiveViewSupported();
149 151
 
150 152
     boolean isLiveViewAfAreaSupported();

+ 6 - 0
app/src/main/java/com/remoteyourcam/usb/ptp/PtpCamera.java

@@ -28,6 +28,7 @@ import com.remoteyourcam.usb.ptp.commands.GetDevicePropValueCommand;
28 28
 import com.remoteyourcam.usb.ptp.commands.GetObjectHandlesCommand;
29 29
 import com.remoteyourcam.usb.ptp.commands.GetStorageInfosAction;
30 30
 import com.remoteyourcam.usb.ptp.commands.InitiateCaptureCommand;
31
+import com.remoteyourcam.usb.ptp.commands.InitiateOpenCaptureCommand;
31 32
 import com.remoteyourcam.usb.ptp.commands.OpenSessionCommand;
32 33
 import com.remoteyourcam.usb.ptp.commands.RetrieveImageAction;
33 34
 import com.remoteyourcam.usb.ptp.commands.RetrieveImageInfoAction;
@@ -804,6 +805,11 @@ public abstract class PtpCamera implements Camera {
804 805
     }
805 806
 
806 807
     @Override
808
+    public void openCapture() {
809
+        queue.add(new InitiateOpenCaptureCommand(this));
810
+    }
811
+
812
+    @Override
807 813
     public boolean isAutoFocusSupported() {
808 814
         return autoFocusSupported;
809 815
     }

+ 44 - 0
app/src/main/java/com/remoteyourcam/usb/ptp/commands/InitiateOpenCaptureCommand.java

@@ -0,0 +1,44 @@
1
+/**
2
+ * Copyright 2013 Nils Assbeck, Guersel Ayaz and Michael Zoech
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+package com.remoteyourcam.usb.ptp.commands;
17
+
18
+import com.remoteyourcam.usb.ptp.PtpCamera;
19
+import com.remoteyourcam.usb.ptp.PtpCamera.IO;
20
+import com.remoteyourcam.usb.ptp.PtpConstants.Operation;
21
+import com.remoteyourcam.usb.ptp.PtpConstants.Response;
22
+
23
+import java.nio.ByteBuffer;
24
+
25
+public class InitiateOpenCaptureCommand extends Command {
26
+
27
+    public InitiateOpenCaptureCommand(PtpCamera camera) {
28
+        super(camera);
29
+    }
30
+
31
+    @Override
32
+    public void exec(IO io) {
33
+        io.handleCommand(this);
34
+        if (responseCode == Response.DeviceBusy) {
35
+            camera.onDeviceBusy(this, true); // TODO when nikon live view is enabled this stalls
36
+            return;
37
+        }
38
+    }
39
+
40
+    @Override
41
+    public void encodeCommand(ByteBuffer b) {
42
+        encodeCommand(b, Operation.InitiateOpenCapture, 0, 0);
43
+    }
44
+}

kodo - Gogs: Go Git Service

Nav apraksta

rshot.py 485B

    # -*- coding: utf-8 -*- from utils.redis.connect import r from utils.redis.rkeys import MEMBER_SHOT_DATA def update_member_shot_data(): from member.models import ShotTypeInfo shots_types = ShotTypeInfo.objects.filter(status=True).order_by('position', '-pk') shots_types = [st.data for st in shots_types] r.setjson(MEMBER_SHOT_DATA, shots_types) return shots_types def get_member_shot_data(): return r.getjson(MEMBER_SHOT_DATA) or update_member_shot_data()