Created
September 5, 2019 03:58
-
-
Save alfianyusufabdullah/f918fe6f5c5c99c3249b6778fbfa45f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val inputLength = edtLength.text.toString().trim { it <= ' ' } | |
val inputWidth = edtWidth.text.toString().trim { it <= ' ' } | |
val inputHeight = edtHeight.text.toString().trim { it <= ' ' } | |
if (inputLength.isEmpty()) { | |
edtLength.error = "Field ini tidak boleh kosong" | |
return | |
} | |
if (inputWidth.isEmpty()) { | |
edtWidth.error = "Field ini tidak boleh kosong" | |
return | |
} | |
if (inputHeight.isEmpty()) { | |
edtHeight.error = "Field ini tidak boleh kosong" | |
return | |
} | |
val length = toDouble(inputLength) | |
val width = toDouble(inputWidth) | |
val height = toDouble(inputHeight) | |
if (length == null) { | |
edtLength.error = "Field ini harus berupa nomer yang valid" | |
return | |
} | |
if (width == null) { | |
edtWidth.error = "Field ini harus berupa nomer yang valid" | |
return | |
} | |
if (height == null) { | |
edtHeight.error = "Field ini harus berupa nomer yang valid" | |
return | |
} | |
val volume = length * width * height | |
tvResult.text = volume.toString() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment