From b0ac2d1c0c2a06bfb622606d5494cab30d2bebc0 Mon Sep 17 00:00:00 2001 From: jiangdongguo <765067602@qq.com> Date: Wed, 25 Oct 2017 10:15:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96USB=20Camera=E5=88=86?= =?UTF-8?q?=E8=BE=A8=E7=8E=87=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/jiangdg/usbcamera/view/USBCameraActivity.java | 4 ++-- .../java/com/jiangdg/usbcamera/USBCameraManager.java | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/jiangdg/usbcamera/view/USBCameraActivity.java b/app/src/main/java/com/jiangdg/usbcamera/view/USBCameraActivity.java index ec85d76..1f28e2d 100644 --- a/app/src/main/java/com/jiangdg/usbcamera/view/USBCameraActivity.java +++ b/app/src/main/java/com/jiangdg/usbcamera/view/USBCameraActivity.java @@ -89,15 +89,15 @@ public class USBCameraActivity extends AppCompatActivity implements CameraDialog if(! isConnected) { showShortMsg("连接失败,请检查分辨率参数是否正确"); } + showShortMsg("连接成功"); } // 与USB设备断开连接 @Override public void onDisConnectDev(UsbDevice device) { - + showShortMsg("连接失败"); } }; - private FileOutputStream fos; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { diff --git a/libusbcamera/src/main/java/com/jiangdg/usbcamera/USBCameraManager.java b/libusbcamera/src/main/java/com/jiangdg/usbcamera/USBCameraManager.java index d5c845a..9c72938 100644 --- a/libusbcamera/src/main/java/com/jiangdg/usbcamera/USBCameraManager.java +++ b/libusbcamera/src/main/java/com/jiangdg/usbcamera/USBCameraManager.java @@ -91,6 +91,8 @@ public class USBCameraManager{ if(listener != null){ listener.onDettachDev(device); } + // 释放资源 + release(); } // 当连接到USB Camera时,被回调 @@ -116,8 +118,6 @@ public class USBCameraManager{ if(listener != null){ listener.onDisConnectDev(device); } - // 关闭摄像头 - closeCamera(); } @Override @@ -131,9 +131,12 @@ public class USBCameraManager{ // 切换分辨率 public void updateResolution(Activity activity, CameraViewInterface cameraView, int width, int height, final OnPreviewListener mPreviewListener){ + // 如果分辨率无变化,则无需重启Camera + if(previewWidth == width && previewHeight == height){ + return; + } this.previewWidth = width; this.previewHeight = height; - // 关闭摄像头 closeCamera(); // 释放CameraHandler占用的相关资源