Skip to content

Instantly share code, notes, and snippets.

@umetsu
Last active May 9, 2017 00:28
Show Gist options
  • Save umetsu/6a708b7b4113a374e03c to your computer and use it in GitHub Desktop.
Save umetsu/6a708b7b4113a374e03c to your computer and use it in GitHub Desktop.
Kotlin + DataBindingでハマったこと
dependencies {
// ... 略
kapt 'com.android.databinding:compiler:1.0-rc5'
}
kapt {
generateStubs = true
}
public class ImageViewBindingAdapter {
@BindingAdapter("bind:imageUrl")
public static void loadImage(view: ImageView, url: String) {
Glide.with(view.context).load(url).into(view)
}
}
class ImageViewBindingAdapter {
companion object {
@BindingAdapter("bind:imageUrl")
fun loadImage(view: ImageView, url: String) {
Glide.with(view.context).load(url).into(view)
}
}
}
object ImageViewBindingAdapter {
@BindingAdapter("bind:imageUrl")
@JvmStatic
fun loadImage(view: ImageView, url: String) {
Glide.with(view.context).load(url).into(view)
}
}
@BindingMethods({
@BindingMethod(type = SwipeRefreshLayout.class, attribute = "bind:onRefresh", method = "setOnRefreshListener"),
})
public class SwipeRefreshLayoutBindingAdapter {
}
@BindingMethods(@BindingMethod(type = SwipeRefreshLayout.class, attribute = "bind:onRefresh" , method = "setOnRefreshListener"))
class SwipeRefreshLayoutBindingAdapter
@BindingMethods(
BindingMethod(type = SwipeRefreshLayout::class, attribute = "bind:onRefresh", method = "setOnRefreshListener")
)
object SwipeRefreshLayoutBindingAdapter {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment