From 2ef7285764f3d4c52daa0bb0944e784ff6bac5db Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 7 Mar 2018 20:07:32 +0100 Subject: [PATCH] show the Lap button only when appropriate --- .../simplemobiletools/clock/fragments/StopwatchFragment.kt | 7 +++++++ app/src/main/res/layout/fragment_stopwatch.xml | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/fragments/StopwatchFragment.kt b/app/src/main/kotlin/com/simplemobiletools/clock/fragments/StopwatchFragment.kt index 1b53277d..49a81914 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/fragments/StopwatchFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/fragments/StopwatchFragment.kt @@ -10,6 +10,7 @@ import android.view.ViewGroup import com.simplemobiletools.clock.R import com.simplemobiletools.clock.extensions.config import com.simplemobiletools.clock.extensions.formatStopwatchTime +import com.simplemobiletools.commons.extensions.beVisibleIf import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor import com.simplemobiletools.commons.extensions.updateTextColors @@ -49,6 +50,11 @@ class StopwatchFragment : Fragment() { setupStopwatch() } + override fun onDestroy() { + super.onDestroy() + updateHandler.removeCallbacksAndMessages(null) + } + private fun setupStopwatch() { stopwatch_time.text = currMS.formatStopwatchTime() setupViews() @@ -71,5 +77,6 @@ class StopwatchFragment : Fragment() { private fun togglePlayPause() { isRunning = !isRunning updatePlayPauseIcon() + view.stopwatch_lap.beVisibleIf(isRunning) } } diff --git a/app/src/main/res/layout/fragment_stopwatch.xml b/app/src/main/res/layout/fragment_stopwatch.xml index 1dd1123c..d5578928 100644 --- a/app/src/main/res/layout/fragment_stopwatch.xml +++ b/app/src/main/res/layout/fragment_stopwatch.xml @@ -11,10 +11,10 @@ android:id="@+id/stopwatch_time" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/medium_margin" + android:layout_marginTop="@dimen/normal_margin" android:background="?attr/selectableItemBackground" android:gravity="center_horizontal" - android:padding="@dimen/normal_margin" + android:padding="@dimen/small_margin" android:textSize="@dimen/stopwatch_text_size" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -30,6 +30,7 @@ android:layout_toLeftOf="@+id/stopwatch_play_pause" android:padding="@dimen/normal_margin" android:src="@drawable/ic_reset" + android:visibility="gone" app:layout_constraintBottom_toBottomOf="@+id/stopwatch_play_pause" app:layout_constraintEnd_toStartOf="@+id/stopwatch_play_pause" app:layout_constraintStart_toStartOf="parent" @@ -62,6 +63,7 @@ android:text="@string/lap" android:textAllCaps="true" android:textSize="@dimen/bigger_text_size" + android:visibility="gone" app:layout_constraintBottom_toBottomOf="@+id/stopwatch_play_pause" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@+id/stopwatch_play_pause"