show the Lap button only when appropriate

This commit is contained in:
tibbi 2018-03-07 20:07:32 +01:00
parent a54fe11821
commit 2ef7285764
2 changed files with 11 additions and 2 deletions

View File

@ -10,6 +10,7 @@ import android.view.ViewGroup
import com.simplemobiletools.clock.R import com.simplemobiletools.clock.R
import com.simplemobiletools.clock.extensions.config import com.simplemobiletools.clock.extensions.config
import com.simplemobiletools.clock.extensions.formatStopwatchTime import com.simplemobiletools.clock.extensions.formatStopwatchTime
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor
import com.simplemobiletools.commons.extensions.updateTextColors import com.simplemobiletools.commons.extensions.updateTextColors
@ -49,6 +50,11 @@ class StopwatchFragment : Fragment() {
setupStopwatch() setupStopwatch()
} }
override fun onDestroy() {
super.onDestroy()
updateHandler.removeCallbacksAndMessages(null)
}
private fun setupStopwatch() { private fun setupStopwatch() {
stopwatch_time.text = currMS.formatStopwatchTime() stopwatch_time.text = currMS.formatStopwatchTime()
setupViews() setupViews()
@ -71,5 +77,6 @@ class StopwatchFragment : Fragment() {
private fun togglePlayPause() { private fun togglePlayPause() {
isRunning = !isRunning isRunning = !isRunning
updatePlayPauseIcon() updatePlayPauseIcon()
view.stopwatch_lap.beVisibleIf(isRunning)
} }
} }

View File

@ -11,10 +11,10 @@
android:id="@+id/stopwatch_time" android:id="@+id/stopwatch_time"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin" android:layout_marginTop="@dimen/normal_margin"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:padding="@dimen/normal_margin" android:padding="@dimen/small_margin"
android:textSize="@dimen/stopwatch_text_size" android:textSize="@dimen/stopwatch_text_size"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
@ -30,6 +30,7 @@
android:layout_toLeftOf="@+id/stopwatch_play_pause" android:layout_toLeftOf="@+id/stopwatch_play_pause"
android:padding="@dimen/normal_margin" android:padding="@dimen/normal_margin"
android:src="@drawable/ic_reset" android:src="@drawable/ic_reset"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@+id/stopwatch_play_pause" app:layout_constraintBottom_toBottomOf="@+id/stopwatch_play_pause"
app:layout_constraintEnd_toStartOf="@+id/stopwatch_play_pause" app:layout_constraintEnd_toStartOf="@+id/stopwatch_play_pause"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
@ -62,6 +63,7 @@
android:text="@string/lap" android:text="@string/lap"
android:textAllCaps="true" android:textAllCaps="true"
android:textSize="@dimen/bigger_text_size" android:textSize="@dimen/bigger_text_size"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@+id/stopwatch_play_pause" app:layout_constraintBottom_toBottomOf="@+id/stopwatch_play_pause"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/stopwatch_play_pause" app:layout_constraintStart_toEndOf="@+id/stopwatch_play_pause"