add a helper function for toggling timer visibility in the activity

This commit is contained in:
tibbi 2018-05-28 11:35:36 +02:00
parent b8db893c1c
commit 05dee60cb7
2 changed files with 14 additions and 6 deletions

View File

@ -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() {

View File

@ -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)
}