Last active
May 9, 2017 00:28
-
-
Save umetsu/6a708b7b4113a374e03c to your computer and use it in GitHub Desktop.
Kotlin + DataBindingでハマったこと
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
dependencies { | |
// ... 略 | |
kapt 'com.android.databinding:compiler:1.0-rc5' | |
} | |
kapt { | |
generateStubs = true | |
} |
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
public class ImageViewBindingAdapter { | |
@BindingAdapter("bind:imageUrl") | |
public static void loadImage(view: ImageView, url: String) { | |
Glide.with(view.context).load(url).into(view) | |
} | |
} |
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
class ImageViewBindingAdapter { | |
companion object { | |
@BindingAdapter("bind:imageUrl") | |
fun loadImage(view: ImageView, url: String) { | |
Glide.with(view.context).load(url).into(view) | |
} | |
} | |
} |
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
object ImageViewBindingAdapter { | |
@BindingAdapter("bind:imageUrl") | |
@JvmStatic | |
fun loadImage(view: ImageView, url: String) { | |
Glide.with(view.context).load(url).into(view) | |
} | |
} |
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
@BindingMethods({ | |
@BindingMethod(type = SwipeRefreshLayout.class, attribute = "bind:onRefresh", method = "setOnRefreshListener"), | |
}) | |
public class SwipeRefreshLayoutBindingAdapter { | |
} |
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
@BindingMethods(@BindingMethod(type = SwipeRefreshLayout.class, attribute = "bind:onRefresh" , method = "setOnRefreshListener")) | |
class SwipeRefreshLayoutBindingAdapter |
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
@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