Skip to content

Instantly share code, notes, and snippets.

View platramos's full-sized avatar

Justin platramos

View GitHub Profile
@danherrera
danherrera / View.kt
Last active April 16, 2020 13:25
Android Pin/Code Entry Hack
// Within onViewCreated
fun updateViewBasedOnPin(pin: String) {
binding.digit1.text = pin.getOrNull(0)?.toString()
binding.digit2.text = pin.getOrNull(1)?.toString()
binding.digit3.text = pin.getOrNull(2)?.toString()
binding.digit4.text = pin.getOrNull(3)?.toString()
binding.digit1Underline.setBackgroundColor(if (pin.isNotEmpty()) Color.YELLOW else Color.DKGRAY)
binding.digit2Underline.setBackgroundColor(if (pin.length > 1) Color.YELLOW else Color.DKGRAY)
binding.digit3Underline.setBackgroundColor(if (pin.length > 2) Color.YELLOW else Color.DKGRAY)
binding.digit4Underline.setBackgroundColor(if (pin.length > 3) Color.YELLOW else Color.DKGRAY)