Skip to content

Instantly share code, notes, and snippets.

@berteodosio
Last active June 15, 2019 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save berteodosio/4628c60dff93a8e97213294e9e5bab55 to your computer and use it in GitHub Desktop.
Save berteodosio/4628c60dff93a8e97213294e9e5bab55 to your computer and use it in GitHub Desktop.
private fun blockBuilder(initializeAction: BBInitializer.() -> Unit) {
val blockBuilderInitializer = BBInitializer()
blockBuilderInitializer.initializeAction()
val jsonResource = blockBuilderInitializer.jsonResource
?: throw NullPointerException("jsonResource must be set")
val remoteFileUrl = blockBuilderInitializer.remoteFileUrl
?: throw NullPointerException("remoteFileUrl must be set")
val context = blockBuilderInitializer.context
?: throw NullPointerException("context must be set")
BlockBuilder
.configuration(ConfigurationParameters(jsonResource, remoteFileUrl))
.init(context)
}
private class BBInitializer {
var context: Context? = null
@RawRes
var jsonResource: Int? = null
var remoteFileUrl: String? = null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment