Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
retty-tech-cafe-8
Yuya Kaido
December 09, 2016
Programming
0
150
retty-tech-cafe-8
Yuya Kaido
December 09, 2016
Tweet
Share
More Decks by Yuya Kaido
See All by Yuya Kaido
droidkaigi-2019
yuyakaido
7
3.6k
matching-dev-meetup-1
yuyakaido
1
170
minami-aoyama-night-6
yuyakaido
1
990
eureka-meetup-10
yuyakaido
0
660
droidkaigi-2018
yuyakaido
4
4.2k
navitime-eureka-1
yuyakaido
0
48
droidkaigi-2017
yuyakaido
12
5.9k
mti-eureka-tech-beer
yuyakaido
0
380
potatotips-33
yuyakaido
2
530
Other Decks in Programming
See All in Programming
データ分析やAIの "運用" について考える
mmorito
0
150
How we run a Realtime Puzzle Fighting Game on AWS Serverless
falken
0
250
プロダクトのタイプ別 GraphQL クライアントの選び方
shozawa
0
5.8k
What's new in Android development tools まとめ
mkeeda
0
410
From Java through Scala to Clojure
lagenorhynque
0
250
engineer
spacemarket
0
4.9k
エンジニアによる事業指標計測のススメ
doyaaaaaken
1
190
Gitlab CIでMRを自動生成する
forcia_dev_pr
0
120
Deep Dive Into Google Zanzibar and its Concepts for Authorization Scenarios
dschenkelman
1
150
社用PCのdotfiles管理 / dotfiles-in-company
yammerjp
0
230
Why Airflow? & What's new in Airflow 2.3?
kaxil
0
120
Node-RED 3.0 新機能紹介
utaani
0
140
Featured
See All Featured
Art Directing for the Web. Five minutes with CSS Template Areas
malarkey
196
9.4k
Testing 201, or: Great Expectations
jmmastey
21
5.4k
Debugging Ruby Performance
tmm1
65
10k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
181
15k
Git: the NoSQL Database
bkeepers
PRO
415
59k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
224
49k
The Illustrated Children's Guide to Kubernetes
chrisshort
15
36k
Fireside Chat
paigeccino
12
1.3k
A designer walks into a library…
pauljervisheath
196
16k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
5
510
Gamification - CAS2011
davidbonilla
75
3.9k
Visualization
eitanlees
125
11k
Transcript
Kotlin × Data Binding Retty Tech Cafe #8 yuyakaido
ࣗݾհ • ւ౻༏ʢ͔͍Ͳ͏Ώ͏ʣ • גࣜձࣾΤϨΧ • 1ͷΠϯλʔϯΛܦͯɺ20154݄ʹ৽ଔೖࣾ yuyakaido yuyakaido
None
࣍ • Kotlin͔ΒBindingΫϥεͷࢀর • BindingΫϥε͕ࢀরͰ͖ͳ͍ • BindingAdapter • ΧελϜόΠϯσΟϯά͕ಈ͔ͳ͍
BindingΫϥε͕ࢀরͰ͖ͳ͍ • Kotlin͔ΒBindingΫϥεΛࢀর͢Δͱ • ίϯύΠϧॱɿKotlin → Java Unresolved reference:
databinding Unresolved reference: ItemArticleBinding Unresolved reference: ItemArticleBinding
ղܾࡦ • generateStubsΛ༗ޮʹ͢Δ • kotlin-kaptΛ͏
generateStubsΛ༗ޮʹ͢Δ • Kotlin → Java • Stub → Kotlin →
Java kapt { generateStubs = true }
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.
ΧελϜόΠϯσΟϯά͕ಈ͔ͳ͍ • GlidePicassoΛͬͯ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) } } }
ղܾࡦ • JvmStaticΞϊςʔγϣϯΛ༩͢Δ • ֦ுؔͱ࣮ͯ͢͠Δ
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) } }
֦ுؔͱ࣮ͯ͢͠Δ @BindingAdapter("android:imageUrl") fun ImageView.imageUrl(url: String?) { Glide.with(context).load(url).into(this) }
·ͱΊ • BindingΫϥε͕Kotlin͔ΒࢀরͰ͖ͳ͍ • generateStubsΛ༗ޮʹ͢Δ • kotlin-kaptΛ͏ • ΧελϜόΠϯσΟϯά͕ಈ͔ͳ͍ •
JvmStaticΞϊςʔγϣϯΛ༩͢Δ • ֦ுؔͱ࣮ͯ͢͠Δ
ࢿྉɾαϯϓϧίʔυ • Kotlin×Data Bindingͷͱղܾ๏ • http://qiita.com/yuyakaido/items/ e5acf5f8ac31c4ed8c77 • https://github.com/yuyakaido/Flow-Android
Thank you :) Credit: NASA Earth Observatory/NOAA NGDC