Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
KotlinでRetrofitを使いやすくするちょっとした工夫
Search
Shinya Kumagai
February 26, 2016
Programming
610
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
KotlinでRetrofitを使いやすくするちょっとした工夫
2016/02/26 Kotlin Birthday Party #jkug
Shinya Kumagai
February 26, 2016
Other Decks in Programming
See All in Programming
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
4.8k
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
660
VibeCodingからAgenticWorkflowへ
starfish719
0
650
How I Won Prize Money at a Hackathon Using Codex and Symphony Alpha
yasei_no_otoko
0
110
Claude CodeとAgentCore Gatewayを繋ぐ際の認証認可 / Authentication and authorization when connecting Claude Code with AgentCore Gateway
har1101
2
330
Cloudflare is Agents
chimame
0
170
自動化したのに回らない テスト運用の壁―AI時代の品質責任と生産性
mfunaki
0
300
実装をデザインガイドラインに追従させるための取り組み / 260731-dip-mosh-design-system
dachi023
0
5.2k
テーブルをDELETEした
yuzneri
0
150
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
160
torikago - Ruby::Boxで照らすモジュラモノリスの実行境界
se4weed
1
390
freee が目指す データ マネジメント戦略 AI-Ready 時代を支える 攻めのガバナンスとは
freee
PRO
0
430
Featured
See All Featured
The Language of Interfaces
destraynor
162
27k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
440
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4.4k
Into the Great Unknown - MozCon
thekraken
41
2.7k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Mind Mapping
helmedeiros
PRO
1
320
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
940
Producing Creativity
orderedlist
PRO
348
40k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
Transcript
KotlinͰRetrofitΛ ͍͘͢͢Δ ͪΐͬͱͨ͠ 2015/02/26 Shinya Kumagai(@droibit)
About Me • Shinya Kumagai (۽୩ ৻) 25ࡀ • Twitter,
GitHub - @droibit • λΦιϑτΣΞגࣜձࣾ
Happy Birthday Kotlin!! (ɾ8ɾ)
֓ཁ • connpass API ༻ͷRetrofit ServiceΛର - JavaͰఆٛ͞ΕͨService - KotlinͰServiceΛఆٛ
KotlinͰ͏ͱ͖ͷͪΐͬͱͨ͠ IUUQTRVBSFHJUIVCJPSFUSPpU
Connpass API • ݕࡧΫΤϦ - keyword … Ωʔϫʔυ - order
… ݁Ռͷදࣔॱ (1:ߋ৽ॱ, 2…) - ymd … Πϕϯτ։࠵ (yyyymmdd) • ϨεϙϯεJSON ?keyword=kotlin&order=1&ymd=20150226 IUUQDPOOQBTTDPNBCPVUBQJ
JavaͰఆٛ͞ΕͨService public interface ConnpassService { // ※ @Get, @Query লུ
Response searchEvent(@NonNull String keyword, @Nullable Integer order, @Nullable String ymd); } // શΫΤϦΛࢦఆ service.searchEvent(“kotlin”, 1, "20160226"); // ΩʔϫʔυͷΈͷ߹ service.searchEvent("kotlin", null, null);
// ֦ுؔΛఆٛ + σϑΥϧτҾ fun ConnpassService.searchEventExt( keyword: String, order: Order?
= null, ymd: String? = null ) = searchEvent(keyword, order?.index, ymd) // ݕࡧ݁Ռͷදࣔॱͷྻڍମ enum class Order(val index: Int) { UPDATE(1), EVENT(2), NEW(3); override fun toString() = "$index" } // ΩʔϫʔυҎ֎ඞཁͳΫΤϦͷΈ service.searchEventExt("kotlin", order = Order.UPDATE) KotlinͰվળ
KotlinͰServiceΛఆٛ interface ConnpassService { // ※ @Get,@Query লུ fun searchEvent(keyword:
String, order: Order? = null, ymd: String? = null): Response } // ΩʔϫʔυҎ֎ඞཁͳΫΤϦͷΈ service.searchEvent(“kotlin”, order = Order.UPDATE)
// ༻్ʹ߹Θ֦ͤͨுؔΛఆٛ fun ConnpassService.searchEvent( keyword: String, order: Order? = null,
ymd: Date? = null ) = searchEvent(keyword, order, format(ymd)) // DateΛ yyyymmdd ϑΥʔϚοτͷStringʹม fun format(date: Date?): String? = … // ։࠵ʹDateΦϒδΣΫτΛࢦఆ service.searchEvent(“kotlin", ymd = dateFromTimesSquare) վળྫ
·ͱΊ • ൚༻తͳΠϯλʔϑΣʔεʹͳΔ͍͋ɺ σϑΥϧτҾɺ֦ுؔͰγϯϓϧͳ Service fabricͷΑ͏ʹͳΒͳ͍Α͏ʹؾΛ͚ͭ·͠ΐ͏
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠