Michael Bichlmeier
10/15/2023, 11:38 AMprefix
in each icon element?
object Icons {
private const val PREFIX = "drawable/"
const val LOGO = PREFIX + "icon.xml"
const val AGAIN = PREFIX + "again.xml"
}
Is there a better way and how can I reduce the prefix redundancy?
I want to call Icons.LOGO
which represents drawable/icon.xml
and this with many other types.Youssef Shoaib [MOD]
10/15/2023, 2:24 PMinterface Prefixing {
val prefix: String
operator fun String.getValue(thisRef: Prefixing, property: KProperty<*>) = prefix + this
}
object Icons: Prefixing {
override val prefix = "drawable/"
val LOGO by "icon.xml"
val AGAIN by "again.xml"
}
Loney Chou
10/15/2023, 3:32 PM