show shutter animation along with sound
This commit is contained in:
parent
375bce1163
commit
ac3044f52b
|
@ -432,8 +432,6 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
||||||
toggleBottomButtons(true)
|
toggleBottomButtons(true)
|
||||||
change_resolution.isEnabled = true
|
change_resolution.isEnabled = true
|
||||||
mPreview?.tryTakePicture()
|
mPreview?.tryTakePicture()
|
||||||
shutter_animation.alpha = 1.0f
|
|
||||||
shutter_animation.animate().alpha(0f).setDuration(CAPTURE_ANIMATION_DURATION).start()
|
|
||||||
} else {
|
} else {
|
||||||
mPreview?.toggleRecording()
|
mPreview?.toggleRecording()
|
||||||
}
|
}
|
||||||
|
@ -648,6 +646,11 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun shutterAnimation() {
|
||||||
|
shutter_animation.alpha = 1.0f
|
||||||
|
shutter_animation.animate().alpha(0f).setDuration(CAPTURE_ANIMATION_DURATION).start()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onMediaSaved(uri: Uri) {
|
override fun onMediaSaved(uri: Uri) {
|
||||||
change_resolution.isEnabled = true
|
change_resolution.isEnabled = true
|
||||||
loadLastTakenMedia(uri)
|
loadLastTakenMedia(uri)
|
||||||
|
|
|
@ -423,6 +423,7 @@ class CameraXPreview(
|
||||||
val mediaOutput = mediaOutputHelper.getImageMediaOutput()
|
val mediaOutput = mediaOutputHelper.getImageMediaOutput()
|
||||||
imageCapture.takePicture(mainExecutor, object : OnImageCapturedCallback() {
|
imageCapture.takePicture(mainExecutor, object : OnImageCapturedCallback() {
|
||||||
override fun onCaptureSuccess(image: ImageProxy) {
|
override fun onCaptureSuccess(image: ImageProxy) {
|
||||||
|
listener.shutterAnimation()
|
||||||
playShutterSoundIfEnabled()
|
playShutterSoundIfEnabled()
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
image.use {
|
image.use {
|
||||||
|
|
|
@ -10,6 +10,7 @@ interface CameraXPreviewListener {
|
||||||
fun setFlashAvailable(available: Boolean)
|
fun setFlashAvailable(available: Boolean)
|
||||||
fun onChangeCamera(frontCamera: Boolean)
|
fun onChangeCamera(frontCamera: Boolean)
|
||||||
fun toggleBottomButtons(hide: Boolean)
|
fun toggleBottomButtons(hide: Boolean)
|
||||||
|
fun shutterAnimation()
|
||||||
fun onMediaSaved(uri: Uri)
|
fun onMediaSaved(uri: Uri)
|
||||||
fun onImageCaptured(bitmap: Bitmap)
|
fun onImageCaptured(bitmap: Bitmap)
|
||||||
fun onChangeFlashMode(flashMode: Int)
|
fun onChangeFlashMode(flashMode: Int)
|
||||||
|
|
Loading…
Reference in New Issue