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 7c4c2f5..2c2ee4b 100644 --- a/app/src/main/java/com/jiangdg/usbcamera/view/USBCameraActivity.java +++ b/app/src/main/java/com/jiangdg/usbcamera/view/USBCameraActivity.java @@ -48,6 +48,8 @@ public class USBCameraActivity extends AppCompatActivity implements CameraDialog public Button mBtnRecord; @BindView(R.id.btn_update_resolution) public Button mBtnUpdateResultion; + @BindView(R.id.btn_restart_camera) + Button mBtnRestartCamera; private USBCameraManager mUSBManager; private CameraViewInterface mUVCCameraView; @@ -130,10 +132,23 @@ public class USBCameraActivity extends AppCompatActivity implements CameraDialog } } - @OnClick({R.id.camera_view, R.id.btn_capture_pic, R.id.btn_rec_video,R.id.btn_update_resolution}) + @OnClick({R.id.camera_view, R.id.btn_capture_pic, R.id.btn_rec_video,R.id.btn_update_resolution,R.id.btn_restart_camera}) public void onViewClick(View view) { int vId = view.getId(); switch (vId) { + // 重启Camera + case R.id.btn_restart_camera: + if(mUSBManager == null) + return; + mUSBManager.restartUSBCamera(USBCameraActivity.this, mUVCCameraView, new USBCameraManager.OnPreviewListener() { + @Override + public void onPreviewResult(boolean isSuccess) { + if(isSuccess) { + showShortMsg("重启成功"); + } + } + }); + break; // 切换分辨率 case R.id.btn_update_resolution: if(mUSBManager == null) diff --git a/app/src/main/res/layout/activity_usbcamera.xml b/app/src/main/res/layout/activity_usbcamera.xml index b776f17..a737bc6 100644 --- a/app/src/main/res/layout/activity_usbcamera.xml +++ b/app/src/main/res/layout/activity_usbcamera.xml @@ -45,4 +45,14 @@ android:textSize="16sp" android:text="切换分辨率为320x240"/> +