Skip to content

Instantly share code, notes, and snippets.

@mbobiosio
Last active November 4, 2021 00:26
Show Gist options
  • Save mbobiosio/86c8d32314970fe601da02c3969bd065 to your computer and use it in GitHub Desktop.
Save mbobiosio/86c8d32314970fe601da02c3969bd065 to your computer and use it in GitHub Desktop.
Every other useful Kotlin Extension useful for daily stuff
/**
* Converts milliseconds to formatted mm:ss
*
* @param value, time in milliseconds.
*/
@BindingAdapter("elapsedTime")
fun TextView.setElapsedTime(value: Long) {
val seconds = value / 1000
text = if (seconds < 60) seconds.toString()
else DateUtils.formatElapsedTime(seconds)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment