Guest User

Untitled

a guest
Oct 19th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. pickerHours.setOnValueChangedListener { picker, oldVal, newVal ->
  2. timerString = pickerHours.value.toString() + ":" + pickerMinutes.value.toString() + ":" + newVal
  3. }
  4.  
  5. pickerMinutes.setOnValueChangedListener { picker, oldVal, newVal ->
  6. timerString1 = pickerHours.value.toString() + ":" + newVal + ":" + pickerSeconds.value
  7. }
  8. pickerSeconds.setOnValueChangedListener { picker, oldVal, newVal ->
  9. timerString2 = pickerHours.value.toString() + ":" + pickerMinutes.value.toString() + ":" + newVal
  10.  
  11. calculateBtn.setOnClickListener {
  12. when {
  13.  
  14. timerString.isEmpty() && timerString1.isEmpty() && timerString2.isEmpty() && (distance.text.isNotEmpty() && pace.text.isNotEmpty()) ->
  15. calculatePace(null, distance.text.toString().toDouble(), pace.text.toString())
  16.  
  17. distance.text.isEmpty() && (timerString.isNotEmpty() && timerString1.isNotEmpty() && timerString2.isNotEmpty() && pace.text.isNotEmpty()) ->
  18. calculatePace(time.text.toString(), null, pace.text.toString())
  19.  
  20. (timerString.isNotEmpty() && timerString1.isNotEmpty() && timerString2.isNotEmpty() && distance.text.isNotEmpty()) ->
  21. calculatePace(time.text.toString(), distance.text.toString().toDouble(), null)
  22.  
  23.  
  24. else -> {
  25. Toast.makeText(this, "Please check fields",
  26. Toast.LENGTH_SHORT).show()
  27. }
  28. }
  29.  
  30. }
Add Comment
Please, Sign In to add comment