adding some crashfixes
This commit is contained in:
parent
9734743705
commit
9928ed46c1
|
@ -57,6 +57,6 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:5.30.12'
|
||||
implementation 'com.simplemobiletools:commons:5.31.25'
|
||||
implementation 'androidx.documentfile:documentfile:1.0.1'
|
||||
}
|
||||
|
|
|
@ -448,7 +448,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener {
|
|||
}
|
||||
|
||||
private fun showToggleCameraIfNeeded() {
|
||||
toggle_camera?.beInvisibleIf(mCameraImpl.getCountOfCameras() <= 1)
|
||||
toggle_camera?.beInvisibleIf(mCameraImpl.getCountOfCameras() ?: 1 <= 1)
|
||||
}
|
||||
|
||||
private fun hasStorageAndCameraPermissions() = hasPermission(PERMISSION_WRITE_STORAGE) && hasPermission(PERMISSION_CAMERA)
|
||||
|
|
|
@ -9,8 +9,12 @@ class MyCameraImpl(val context: Context) {
|
|||
|
||||
fun getBackCameraId() = CameraCharacteristics.LENS_FACING_BACK
|
||||
|
||||
fun getCountOfCameras(): Int {
|
||||
val manager = context.getSystemService(Context.CAMERA_SERVICE) as CameraManager
|
||||
return manager.cameraIdList.size
|
||||
fun getCountOfCameras(): Int? {
|
||||
return try {
|
||||
val manager = context.getSystemService(Context.CAMERA_SERVICE) as CameraManager
|
||||
manager.cameraIdList.size
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -577,6 +577,10 @@ class CameraPreview : ViewGroup, TextureView.SurfaceTextureListener, MyPreview {
|
|||
mRotationAtCapture = mActivity.mLastHandledOrientation
|
||||
val jpegOrientation = (mSensorOrientation + compensateDeviceRotation(mRotationAtCapture)) % 360
|
||||
val captureBuilder = mCameraDevice!!.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE).apply {
|
||||
if (mImageReader!!.surface == null) {
|
||||
return
|
||||
}
|
||||
|
||||
addTarget(mImageReader!!.surface)
|
||||
setFlashAndExposure(this)
|
||||
set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE)
|
||||
|
@ -605,7 +609,7 @@ class CameraPreview : ViewGroup, TextureView.SurfaceTextureListener, MyPreview {
|
|||
abortCaptures()
|
||||
capture(captureBuilder.build(), captureCallback, null)
|
||||
}
|
||||
} catch (e: CameraAccessException) {
|
||||
} catch (e: Exception) {
|
||||
mActivity.showErrorToast("Capture picture $e")
|
||||
}
|
||||
}
|
||||
|
@ -845,7 +849,12 @@ class CameraPreview : ViewGroup, TextureView.SurfaceTextureListener, MyPreview {
|
|||
updatePreview()
|
||||
mIsRecording = true
|
||||
mActivity.runOnUiThread {
|
||||
mMediaRecorder?.start()
|
||||
try {
|
||||
mMediaRecorder?.start()
|
||||
} catch (e: Exception) {
|
||||
mActivity.showErrorToast(e)
|
||||
mCameraState = STATE_PREVIEW
|
||||
}
|
||||
}
|
||||
mActivity.setRecordingState(true)
|
||||
mCameraState = STATE_RECORDING
|
||||
|
|
|
@ -9,7 +9,7 @@ buildscript {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.0.1'
|
||||
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#Sat Sep 05 21:36:09 CEST 2020
|
||||
#Sat Nov 07 19:34:59 CET 2020
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
|
||||
|
|
Loading…
Reference in New Issue