Added PassPrefs dialog entered values sanity check

This commit is contained in:
Arty Bishop committed 2020-01-03 14:09:40 +00:00
1 parent 5737023389
commit ba7f3f432e
2 files changed
+17 -3

No files matched your search

@@ -132,8 +132,22 @@ class SkyFragment : Fragment() {
.setPositiveButton(getString(R.string.btn_ok)) { _, _ ->
val hoursAhead = etHoursAhead.text.toString().toInt()
val minEl = etMinEl.text.toString().toDouble()
viewModel.setPassPrefs(hoursAhead, minEl)
calculatePasses()
if (hoursAhead < 1 || hoursAhead > 168) {
Toast.makeText(
mainActivity,
"Value should be within 1-168 hours",
Toast.LENGTH_SHORT
).show()
} else if (minEl < 0 || minEl > 90) {
Toast.makeText(
mainActivity,
"Value should be within 0-90 deg",
Toast.LENGTH_SHORT
).show()
} else {
viewModel.setPassPrefs(hoursAhead, minEl)
calculatePasses()
}
}
.setNegativeButton(getString(R.string.btn_cancel)) { dialog, _ ->
dialog.cancel()
+1 -1
View File
@@ -42,7 +42,7 @@
android:layout_height="wrap_content"
android:hint="@string/pref_min_el_hint"
android:importantForAutofill="no"
android:inputType="number"
android:inputType="number|numberDecimal"
app:layout_constraintEnd_toEndOf="@+id/pref_min_el_tv"
app:layout_constraintStart_toStartOf="@+id/pref_min_el_tv"
app:layout_constraintTop_toBottomOf="@+id/pref_min_el_tv" />