Last active
February 28, 2017 18:56
-
-
Save Judrummer/75cd51057f6139c7df5a79af264be058 to your computer and use it in GitHub Desktop.
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
inline fun jxAdapter(builder: __JxAdapterBuilder.() -> Unit): JxAdapter { | |
val jxBuilder = __JxAdapterBuilder() | |
jxBuilder.builder() | |
return jxBuilder.build() | |
} | |
class __JxAdapterBuilder { | |
val __jxHolderList = mutableListOf<JxViewHolder<*>>() | |
var __jxDiffUtil: JxDiffUtil? = null | |
fun build(): JxAdapter = JxAdapter(__jxHolderList, __jxDiffUtil) | |
} | |
inline fun <reified T : Any> __JxAdapterBuilder.holder(itemLayoutId: Int, noinline bindHolder: RecyclerView.ViewHolder.(position: Int, item: T) -> Unit) { | |
__jxHolderList.add(JxViewHolder(itemLayoutId, bindHolder)) | |
} | |
data class Task(val id: String) | |
fun test() { | |
jxAdapter { | |
holder<Task>(1) { position, item -> | |
} | |
holder<Task>(1) { position, item -> | |
} | |
holder<Task>(1) { position, item -> | |
} | |
holder<Task>(1) { position, item -> | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment