Upgrade to Pro — share decks privately, control downloads, hide ads and more …

retty-tech-cafe-8

Yuya Kaido
December 09, 2016

 retty-tech-cafe-8

Yuya Kaido

December 09, 2016
Tweet

More Decks by Yuya Kaido

Other Decks in Programming

Transcript

  1. BindingΫϥε͕ࢀরͰ͖ͳ͍ • Kotlin͔ΒBindingΫϥεΛࢀর͢Δͱ • ίϯύΠϧॱɿKotlin → Java  Unresolved reference:

    databinding Unresolved reference: ItemArticleBinding Unresolved reference: ItemArticleBinding
  2. kotlin-kaptΛ࢖͏ • KotlinʹΑΔAnnotation Processing࣮૷ • apply plugin: ‘kotlin-kapt' • ؆୯ͳαϯϓϧ͸ಈ࡞͠·ͨ͠

     The new annotation processing still has known issues and may not be compatible with all annotation processors. You should enable it only if you’ve run into problems with the default kapt annotation processing implementation.
  3. ΧελϜόΠϯσΟϯά͕ಈ͔ͳ͍ • Glide΍PicassoΛ࢖ͬͯImageViewʹURLΛό Πϯυ͢Δ  public class CustomBinder {
 @BindingAdapter("app:imageUrl")


    public static void imageUrl(ImageView imageView, String url) {
 Glide.with(imageView.getContext()).load(url).into(imageView);
 }
 } class CustomBinder {
 companion object {
 @BindingAdapter("app:imageUrl")
 fun imageUrl(imageView: ImageView, url: String) {
 Glide.with(imageView.context).load(url).into(imageView)
 }
 }
 }
  4. JvmStaticΞϊςʔγϣϯΛ෇༩͢Δ  class CustomBinder {
 companion object {
 @JvmStatic
 @BindingAdapter("app:imageUrl")


    fun imageUrl(imageView: ImageView, url: String) {
 Glide.with(imageView.context).load(url).into(imageView)
 }
 }
 } object CustomBinder {
 @JvmStatic
 @BindingAdapter("app:imageUrl")
 fun imageUrl(imageView: ImageView, url: String?) {
 Glide.with(imageView.context).load(url).into(imageView)
 }
 }