|
@ -62,6 +62,7 @@ public class USBCameraActivity extends AppCompatActivity implements CameraDialog |
|
|
private CameraViewInterface mUVCCameraView; |
|
|
private CameraViewInterface mUVCCameraView; |
|
|
|
|
|
|
|
|
private boolean isRequest; |
|
|
private boolean isRequest; |
|
|
|
|
|
private boolean isPreview; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* USB设备事件监听器 |
|
|
* USB设备事件监听器 |
|
@ -99,6 +100,9 @@ public class USBCameraActivity extends AppCompatActivity implements CameraDialog |
|
|
public void onConnectDev(UsbDevice device,boolean isConnected) { |
|
|
public void onConnectDev(UsbDevice device,boolean isConnected) { |
|
|
if(! isConnected) { |
|
|
if(! isConnected) { |
|
|
showShortMsg("连接失败,请检查分辨率参数是否正确"); |
|
|
showShortMsg("连接失败,请检查分辨率参数是否正确"); |
|
|
|
|
|
isPreview = false; |
|
|
|
|
|
}else{ |
|
|
|
|
|
isPreview = true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -125,10 +129,20 @@ public class USBCameraActivity extends AppCompatActivity implements CameraDialog |
|
|
@Override |
|
|
@Override |
|
|
protected void onStart() { |
|
|
protected void onStart() { |
|
|
super.onStart(); |
|
|
super.onStart(); |
|
|
|
|
|
if(mUSBManager == null) |
|
|
|
|
|
return; |
|
|
// 注册USB事件广播监听器
|
|
|
// 注册USB事件广播监听器
|
|
|
if(mUSBManager != null){ |
|
|
|
|
|
mUSBManager.registerUSB(); |
|
|
mUSBManager.registerUSB(); |
|
|
|
|
|
if(!isPreview && mUSBManager.isCameraOpened()) { |
|
|
|
|
|
mUSBManager.startPreview(mUVCCameraView, new AbstractUVCCameraHandler.OnPreViewResultListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onPreviewResult(boolean result) { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
isPreview = true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@ -138,6 +152,10 @@ public class USBCameraActivity extends AppCompatActivity implements CameraDialog |
|
|
if(mUSBManager != null){ |
|
|
if(mUSBManager != null){ |
|
|
mUSBManager.unregisterUSB(); |
|
|
mUSBManager.unregisterUSB(); |
|
|
} |
|
|
} |
|
|
|
|
|
if(isPreview && mUSBManager.isCameraOpened()) { |
|
|
|
|
|
mUSBManager.stopPreview(); |
|
|
|
|
|
isPreview = false; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@OnClick({ R.id.btn_contrast,R.id.btn_brightness,R.id.btn_capture_pic, R.id.btn_rec_video,R.id.btn_update_resolution,R.id.btn_restart_camera}) |
|
|
@OnClick({ R.id.btn_contrast,R.id.btn_brightness,R.id.btn_capture_pic, R.id.btn_rec_video,R.id.btn_update_resolution,R.id.btn_restart_camera}) |
|
|