From 05dee60cb7bb8eb7ffd65c7a333010687ee7d0f4 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 28 May 2018 11:35:36 +0200 Subject: [PATCH] add a helper function for toggling timer visibility in the activity --- .../camera/activities/MainActivity.kt | 18 +++++++++++++----- .../camera/views/PreviewCameraOne.kt | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt index 7c11c1dd..842474ac 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt @@ -411,11 +411,12 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LOW_PROFILE } - fun hideTimer() { - video_rec_curr_timer.text = 0.getFormattedDuration() - video_rec_curr_timer.beGone() - mCurrVideoRecTimer = 0 - mTimerHandler.removeCallbacksAndMessages(null) + fun toggleTimer(show: Boolean) { + if (show) { + showTimer() + } else { + hideTimer() + } } private fun showTimer() { @@ -423,6 +424,13 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave setupTimer() } + private fun hideTimer() { + video_rec_curr_timer.text = 0.getFormattedDuration() + video_rec_curr_timer.beGone() + mCurrVideoRecTimer = 0 + mTimerHandler.removeCallbacksAndMessages(null) + } + private fun setupTimer() { runOnUiThread(object : Runnable { override fun run() { diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/views/PreviewCameraOne.kt b/app/src/main/kotlin/com/simplemobiletools/camera/views/PreviewCameraOne.kt index a4f082c0..c6e06044 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/views/PreviewCameraOne.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/views/PreviewCameraOne.kt @@ -204,7 +204,7 @@ class PreviewCameraOne : ViewGroup, SurfaceHolder.Callback, MediaScannerConnecti if (setCamera(mCurrCameraId)) { setFlashlightState(FLASH_OFF) mActivity?.updateCameraIcon(mCurrCameraId == mCameraImpl!!.getFrontCameraId()) - mActivity?.hideTimer() + mActivity?.toggleTimer(false) } else { mActivity?.toast(R.string.camera_switch_error) }