Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
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
【加筆修正版】Laravel のアプリケーションをどこにデプロイするか #phpcon_ehime
akase244
0
150
複雑なUIコンポーネントとの ⻑い付き合い⽅:波及するバグからテスト戦略を経て、安全な再設計へ
mixplace
0
410
AWS CDKのカスタムリソースでContinuum(旧Security Agent)を実装した話 | Implementing Continuum (formerly Security Agent) via AWS CDK Custom Resource
akihisaikeda
2
150
Vue Fes Japan の “作る側”に関わってみて
naokihaba
0
150
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
180
Jetpack Compose Mechanisms
skydoves
3
810
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
27
30k
Unity6 URPによる海底をテーマにしたVJシステムの解説 | Unity Shader 完全に理解した 勉強会
gam0022
0
370
外から家のPCの電源入れたい!をPHPで解決する
kawashimo0
1
130
Rでドレミ/Do-Re-Mi_with_R
florets1
0
130
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
120
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
990
Featured
See All Featured
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
930
RailsConf 2023
tenderlove
30
1.6k
The Cult of Friendly URLs
andyhume
79
7k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
Docker and Python
trallard
47
4.2k
Visualization
eitanlees
153
17k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
1
280
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
470
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
The Invisible Side of Design
smashingmag
301
52k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
330
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ͷΑ͏ʹͳΒͳ͍Α͏ʹؾΛ͚ͭ·͠ΐ͏
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠