small cleanup at checking camera availability

This commit is contained in:
tibbi 2018-05-28 11:49:52 +02:00
parent 05dee60cb7
commit 86d13eaf54
1 changed files with 9 additions and 10 deletions

View File

@ -199,8 +199,10 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
mIsInPhotoMode = true mIsInPhotoMode = true
mTimerHandler = Handler() mTimerHandler = Handler()
mFadeHandler = Handler() mFadeHandler = Handler()
mPreview!!.setFlashlightState(if (config.turnFlashOffAtStartup) FLASH_OFF else config.flashlightState)
setupPreviewImage(true) setupPreviewImage(true)
val initialFlashlightState = if (config.turnFlashOffAtStartup) FLASH_OFF else config.flashlightState
mPreview!!.setFlashlightState(initialFlashlightState)
} }
private fun initButtons() { private fun initButtons() {
@ -214,11 +216,9 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
} }
private fun toggleCamera() { private fun toggleCamera() {
if (!checkCameraAvailable()) { if (checkCameraAvailable()) {
return mPreview!!.toggleCamera()
} }
mPreview!!.toggleCamera()
} }
private fun showLastMediaPreview() { private fun showLastMediaPreview() {
@ -229,11 +229,9 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
} }
private fun toggleFlash() { private fun toggleFlash() {
if (!checkCameraAvailable()) { if (checkCameraAvailable()) {
return mPreview?.toggleFlashlight()
} }
mPreview?.toggleFlashlight()
} }
fun updateFlashlightState(state: Int) { fun updateFlashlightState(state: Int) {
@ -311,8 +309,9 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
return return
} }
if (mIsVideoCaptureIntent) if (mIsVideoCaptureIntent) {
mPreview?.trySwitchToVideo() mPreview?.trySwitchToVideo()
}
mPreview?.setFlashlightState(FLASH_OFF) mPreview?.setFlashlightState(FLASH_OFF)
hideTimer() hideTimer()