Florian
12/29/2019, 8:45 AMMatteo Mirk
12/29/2019, 8:52 AMBiometricManager
constants into an enum you won’t need an else branch.
Turns out that you won’t need a “when” either, since the text matches the constant name:
val message = biometricManager.canAuthenticate().toString()
Florian
12/29/2019, 9:20 AMMatteo Mirk
12/29/2019, 10:09 AMFlorian
12/29/2019, 10:43 AMBiometricManager
is a class of the Android systemMatteo Mirk
12/29/2019, 10:48 AMFlorian
12/29/2019, 2:32 PMcodeslubber
12/29/2019, 6:54 PMHullaballoonatic
01/01/2020, 8:48 PMDaniel
01/02/2020, 8:01 PMwhen(...) {
... -> showToast.value = "Success"
... -> showToast.value = "Error"
}
showToast is a live data and the toast is shown by the viewshowToast(message: String)
method insteadshowToast.value = R.string.success
darkmoon_uk
03/21/2020, 1:15 PMToast
in every branch then returning doesn't fully enforce this. Working with an uninititalised message
first means the compiler will fail fast if you leave any branches uncovered e.g. in case you introduce a new enum value later on.