simplify button drawable updating

This commit is contained in:
tibbi 2018-05-28 11:53:20 +02:00
parent 86d13eaf54
commit 18905792c0
1 changed files with 10 additions and 8 deletions

View File

@ -176,7 +176,7 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
} else if (intent?.action == MediaStore.ACTION_VIDEO_CAPTURE) { } else if (intent?.action == MediaStore.ACTION_VIDEO_CAPTURE) {
mIsVideoCaptureIntent = true mIsVideoCaptureIntent = true
hideToggleModeAbout() hideToggleModeAbout()
shutter.setImageDrawable(resources.getDrawable(R.drawable.ic_video_rec)) shutter.setImageResource(R.drawable.ic_video_rec)
} }
mPreview?.isImageCaptureIntent = isImageCaptureIntent() mPreview?.isImageCaptureIntent = isImageCaptureIntent()
} }
@ -191,7 +191,9 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
mPreview = PreviewCameraOne(this, camera_surface_view, this) mPreview = PreviewCameraOne(this, camera_surface_view, this)
view_holder.addView(mPreview) view_holder.addView(mPreview)
toggle_camera.setImageResource(if (config.lastUsedCamera == mCameraImpl.getBackCameraId()) R.drawable.ic_camera_front else R.drawable.ic_camera_rear)
val imageDrawable = if (config.lastUsedCamera == mCameraImpl.getBackCameraId()) R.drawable.ic_camera_front else R.drawable.ic_camera_rear
toggle_camera.setImageResource(imageDrawable)
mFocusCircleView = FocusCircleView(applicationContext) mFocusCircleView = FocusCircleView(applicationContext)
view_holder.addView(mFocusCircleView) view_holder.addView(mFocusCircleView)
@ -260,11 +262,11 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
mPreview?.tryTakePicture() mPreview?.tryTakePicture()
} else { } else {
if (mPreview?.toggleRecording() == true) { if (mPreview?.toggleRecording() == true) {
shutter.setImageDrawable(resources.getDrawable(R.drawable.ic_video_stop)) shutter.setImageResource(R.drawable.ic_video_stop)
toggle_camera.beInvisible() toggle_camera.beInvisible()
showTimer() showTimer()
} else { } else {
shutter.setImageDrawable(resources.getDrawable(R.drawable.ic_video_rec)) shutter.setImageResource(R.drawable.ic_video_rec)
showToggleCameraIfNeeded() showToggleCameraIfNeeded()
hideTimer() hideTimer()
} }
@ -330,8 +332,8 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
} }
private fun initPhotoMode() { private fun initPhotoMode() {
toggle_photo_video.setImageDrawable(resources.getDrawable(R.drawable.ic_video)) toggle_photo_video.setImageResource(R.drawable.ic_video)
shutter.setImageDrawable(resources.getDrawable(R.drawable.ic_shutter)) shutter.setImageResource(R.drawable.ic_shutter)
mPreview?.initPhotoMode() mPreview?.initPhotoMode()
setupPreviewImage(true) setupPreviewImage(true)
} }
@ -347,9 +349,9 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
} }
private fun initVideoButtons() { private fun initVideoButtons() {
toggle_photo_video.setImageDrawable(resources.getDrawable(R.drawable.ic_camera)) toggle_photo_video.setImageResource(R.drawable.ic_camera)
showToggleCameraIfNeeded() showToggleCameraIfNeeded()
shutter.setImageDrawable(resources.getDrawable(R.drawable.ic_video_rec)) shutter.setImageResource(R.drawable.ic_video_rec)
setupPreviewImage(false) setupPreviewImage(false)
mPreview?.checkFlashlight() mPreview?.checkFlashlight()
} }