This file contains 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
fun <T, K> Iterable<T>.multiDistinctBy(vararg selectors: (T) -> K): List<T> { | |
require(selectors.isNotEmpty()) | |
val set = HashSet<Int>() | |
val distinct = ArrayList<T>() | |
for (element in this) { | |
val key = selectors.fold(0) { sum, selector -> | |
sum.plus(selector(element)?.hashCode() ?: 0) } | |
if (set.add(key)) |
This file contains 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
fun View.visible() { | |
visibility = View.VISIBLE | |
} | |
fun View.invisible() { | |
visibility = View.INVISIBLE | |
} | |
fun View.gone() { | |
visibility = View.GONE |