Skip to content

Commit

Permalink
[fix] some copy error
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangdg committed Aug 30, 2022
1 parent fd38e64 commit 60d34c3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-feature android:name="android.hardware.camera"/>
<uses-feature android:name="android.hardware.cacamera.autofocus"/>
<uses-feature android:name="android.hardware.camera.autofocus"/>

<!--bugly permission need-->
<uses-permission android:name="android.permission.INTERNET" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,15 @@ abstract class MultiCameraActivity: BaseActivity() {
private val mCameraMap = hashMapOf<Int, MultiCameraClient.Camera>()

override fun initData() {
mCameraClient = MultiCameraClient(requireContext(), object : IDeviceConnectCallBack {
mCameraClient = MultiCameraClient(this, object : IDeviceConnectCallBack {
override fun onAttachDev(device: UsbDevice?) {
device ?: return
context?.let {
if (mCameraMap.containsKey(device.deviceId)) {
return
}
MultiCameraClient.Camera(it, device).apply {
mCameraMap[device.deviceId] = this
onCameraAttached(this)
}
if (isAutoRequestPermission()) {
mCameraClient?.requestPermission(device)
}
MultiCameraClient.Camera(this@MultiCameraActivity, device).apply {
mCameraMap[device.deviceId] = this
onCameraAttached(this)
}
if (isAutoRequestPermission()) {
mCameraClient?.requestPermission(device)
}
}

Expand All @@ -56,10 +51,9 @@ abstract class MultiCameraActivity: BaseActivity() {
override fun onConnectDev(device: UsbDevice?, ctrlBlock: USBMonitor.UsbControlBlock?) {
device ?: return
ctrlBlock ?: return
context ?: return
mCameraMap[device.deviceId]?.apply {
setUsbControlBlock(ctrlBlock)
onCameraConnected(this)
onCameraDisConnected(this)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,8 @@ class CameraUvcStrategy(ctx: Context) : ICameraStrategy(ctx) {

override fun startPreviewInternal() {
try {
createCamera() ?: return
realStartPreview() ?: return
val dev = mDevSettableFuture?.get().apply {
mDevConnectCallBack?.onConnectDev(this)
}
if (Utils.debugCamera) {
Logger.i(TAG, " start preview success!!!, id(${dev?.deviceId})$dev")
}
createCamera()
realStartPreview()
} catch (e: Exception) {
stopPreview()
Logger.e(TAG, " preview failed, err = ${e.localizedMessage}", e)
Expand Down Expand Up @@ -212,6 +206,12 @@ class CameraUvcStrategy(ctx: Context) : ICameraStrategy(ctx) {
)
)
}
val dev = mDevSettableFuture?.get().apply {
mDevConnectCallBack?.onConnectDev(this)
}
if (Utils.debugCamera) {
Logger.i(TAG, " start preview success!!!, id(${dev?.deviceId})$dev")
}
} catch (e: Exception) {
postCameraStatus(CameraStatus(CameraStatus.ERROR, e.localizedMessage))
Logger.e(TAG, " startPreview failed. err = ${e.localizedMessage}", e)
Expand Down

0 comments on commit 60d34c3

Please sign in to comment.