Skip to content

Instantly share code, notes, and snippets.

@lukelorusso
Created August 27, 2019 15:21
Show Gist options
  • Save lukelorusso/0907c6b8b9b27a66685830d5009be6f2 to your computer and use it in GitHub Desktop.
Save lukelorusso/0907c6b8b9b27a66685830d5009be6f2 to your computer and use it in GitHub Desktop.
renderCode()
private fun renderCode() {
for (i in 0 until llCodeWrapper.childCount) {
val itemContainer = llCodeWrapper.getChildAt(i)
itemContainer.findViewById<TextView>(R.id.tvCode).text =
if (text.length > i)
(if (maskTheCode) codeMaskChar else text[i])
.toString()
else ""
if (i == text.length - 1 && !itemContainer.isFullyVisibleInside(hsvCodeWrapperScroller))
hsvCodeWrapperScroller.focusOnView(itemContainer)
}
notifyCodeChanged()
}
private fun notifyCodeChanged(): Boolean = (text.length == maxLength).apply {
onCodeChangedListener?.invoke(Pair(text.toString(), this))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment