Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit 4d9a0a1a authored by Dimitri Leurs's avatar Dimitri Leurs
Browse files

Bug concurent timer if you press Start many times

parent 63afe49a
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ package fr.dleurs.android.timerapp
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import androidx.core.text.isDigitsOnly
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import kotlinx.android.synthetic.main.activity_main.*
......@@ -16,7 +17,7 @@ class MainActivity : AppCompatActivity() {
bLaunchTimer.setOnClickListener {
var safeLengthTime: Long
if (etTimerInput.text.isNullOrEmpty()) {
if (etTimerInput.text.isNullOrEmpty() or !etTimerInput.text.isDigitsOnly()) {
etTimerInput.setText("10")
safeLengthTime = 10
} else {
......@@ -29,7 +30,8 @@ class MainActivity : AppCompatActivity() {
}
bStopTimer.setOnClickListener {
timerViewModel.stopTimer()
tvTimer.text = "-"
}
timerViewModel.finished.observe(this, Observer {
......
......@@ -11,7 +11,7 @@
android:id="@+id/tvTimer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:text="-"
android:textSize="100sp"
app:layout_constraintBottom_toTopOf="@+id/tvTimerInputLabel"
app:layout_constraintEnd_toEndOf="parent"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment