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
開発 4 年目のアプリへの Kotlin 導入
Search
Ryutaro Miyashita
July 12, 2017
Programming
1
2.5k
開発 4 年目のアプリへの Kotlin 導入
2017/07/12 Kotlin 開発 Tech Talks
Ryutaro Miyashita
July 12, 2017
Tweet
Share
More Decks by Ryutaro Miyashita
See All by Ryutaro Miyashita
Java で書かれた Android アプリを Kotlin で書き直すまでの話 / Talk of rewrite Android app for Java to Kotlin
ryugoo
0
1.6k
開発 4 年目のアプリへの Kotlin 導入
ryugoo
0
400
チーム開発と Android アプリの構成
ryugoo
5
1.1k
Either で想定内のエラーと想定外のエラーを別ものにしたい!
ryugoo
2
1.6k
全て S になる -RxJava と LWS を持ち込む楽しさ-
ryugoo
4
710
Transition at RxJava 1.x to 2.x
ryugoo
0
510
Kotlin さんと誕生日が近いだけの男の話
ryugoo
2
500
Android エンジニアになって 2 年の学び
ryugoo
1
2.6k
年末だしお掃除をしよう!
ryugoo
0
760
Other Decks in Programming
See All in Programming
最新TCAキャッチアップ
0si43
0
140
TypeScriptでライブラリとの依存を限定的にする方法
tutinoko
2
660
ローコードSaaSのUXを向上させるためのTypeScript
taro28
1
610
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1.1k
Realtime API 入門
riofujimon
0
150
よくできたテンプレート言語として TypeScript + JSX を利用する試み / Using TypeScript + JSX outside of Web Frontend #TSKaigiKansai
izumin5210
6
1.7k
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
120
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
190
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
1
110
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
350
Click-free releases & the making of a CLI app
oheyadam
2
110
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Gamification - CAS2011
davidbonilla
80
5k
Building Your Own Lightsaber
phodgson
103
6.1k
4 Signs Your Business is Dying
shpigford
180
21k
Building Adaptive Systems
keathley
38
2.3k
Fireside Chat
paigeccino
34
3k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
The Language of Interfaces
destraynor
154
24k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
Transcript
涪䎃湡ך،فٔפך,PUMJO㼪Ⰵ
㹧♴畆㣐龤 $IBU8PSL吳䒭⠓爡 ،فٔ؛٦ءّٝ涪鿇ث٦ئ٦ت٦ !SZVHPP@
$IBU8PSLחאְג
$IBU8PSL 㕂欵ךؽآطأثٍحز؟٦ؽأ 䎃剢ַ䲿⣘㨣 㼪Ⰵ爡侧 爡 䎃剢劣傈儗挿
䎃劣ח4DBMB㼪Ⰵ 1)1⢘欽׃גְֹתׅ
ؒٝآص،꧊⚥ J04"OESPJEؒٝآص،꧊⚥ 匌❨ؔؿ؍أ㣐ꢻؔؿ؍أ 匌❨ؔؿ؍أכ剢ח匌❨ةٙ٦לח獳鯄 IUUQDPSQDIBUXPSLDPNKBSFDSVJUFOHJOFFS
$IBU8PSLךٌغ؎ٕ،فٔ 剑ⴱכ5JUBOJVN醡 +BWB4DSJQUדط؎ذ؍ـ6*䭯א،فָٔ⡲ 3FBDU/BUJWFְזװאך饥 "OESPJE晛
䎃剢ַط؎ذ؍ـ⻉ J04晛 䎃剢ַط؎ذ؍ـ⻉
䎃剢 ➂ד"OESPJEط؎ذ؍ـ晛ך涪㨣 䎃剢 ,PUMJO⹈䓼⠓ח겣⳿ׅ 䎃剢
"OESPJEط؎ذ؍ـ晛ٔٔ٦أ 䎃 せ̔せ⡤ⵖח 䎃剢 ,PUMJO醡ך傈㜠،فٔ爡ⰻ麊欽㨣 䎃剢 ,PUMJOفٗتؙءّٝח㼪Ⰵ
ז,PUMJO㼪Ⰵׅךַ
,PUMJO㼪Ⰵ䚈ּ䗳銲כַ֮ 䚈ָזֽלזזְ椚歋כזְ ,PUMJOׄׯזְה"OESPJE،فָٔ⡲זֻז ˘˘ֽדכזְ ֻ֮תדⰕ䒭؟ه٦ز鎉铂ָ㟓ִֽ ؟ه٦زָ竰竲ׁ㸜䗰䠬䩛חⰅ
ד,PUMJO㼪Ⰵׅ椚歋 ؒٝآص،涸ז嚂׃ׁ 倜׃ְךח鍗ٌثك٦ءّٝ ؒٝسِ٦ؠ٦ךًٔحزחז鎉铂堣腉 涪ח꧊⚥׃װְׅ
ن؎ٓ٦فٖ٦ز㼰זֻדֹ 膷ⰻךⳢ椚؎ً٦آ؝٦سח僥׃װְׅ "OESPJE涪鎉铂ה׃גⰕ䒭ח؟ه٦ز 涪ך䩛ָ姺תג׃תֲ〳腉䚍ָ嶊ִ
,PUMJOך㴍׃ְהֿ
ن؎ٓ٦فٖ٦ز幾ֿׅהָדֹ -BNCEB䒭 ًاحسאֽ䭯א؎ٝة٦ؿؑ٦أ 4JOHMF"CTUSBDU.FUIPE5ZQF -BNCEB䒭⢪גⱔꞿז鎸鶢ָ♶銲חז
+BWBךךה嫰鯰׃ג 䒷侧ָאד♶銲ז㜥さכ剅ַזֻג葺ְ ⢪זְ䒷侧כˑ@˒ד邌植 وآحؙؗ٦ٙ٦سˑJU˒
Button b = (Button) findViewById(R.id.button); b.setOnClickListener(new View.OnClickListener() { @Override public
void onClick(View view) { // Your business logic } }); "OESPJE+BWB %FGBVMU ⼡せؙٓأ⢪גٔأش٦إحزׅךדن؎ٓ٦فٖ٦زָ㢳ְ
Button b = (Button) findViewById(R.id.button); b.setOnClickListener(view —> { // Your
business logic }); "OESPJE+BWB -BNCEB 4JOHMF"CTUSBDU.FUIPEכ-BNCEB䒭⢪ֲֿהדأحؗٔה剅ֽ
val b = findViewById(R.id.button) as Button b.setOnClickListener { view ->
// Your business logic } b.setOnClickListener { _ -> // No use args } b.setOnClickListener { //“it” is View } ,PUMJO ,PUMJOדずׄ״ֲח剅ֽ ⢪זְ䒷侧כ@ד邌ׅ 䒷侧ָאזל ˑJU˒ؗ٦ٙ٦سד撑 ֿׅהדֹ
䙼罋僥׃װְׅ鎉铂堣腉 أ؝٦فꟼ侧 知患ז鎸鶢ך䩛⸔ֽ׃גֻ ؎ً٦آ鸐ך؎ٝأةٝأך欰䧭ח⤑ⵃ 䭁䓸ꟼ侧
ְאךⳢ椚ًاحسך״ֲח䪔ִ 傀㶷ךؙٓأח،سنحؙחًاحس鷄⸇ JG䒭 USZ䒭 XIFO䒭 ⦼鵤ֿׅהָדֹ
public static MyFragment newInstance(String str) { MyFragment fragment = new
MyFragment(); Bundle args = fragment.getArguments(); if (args == null) { args = new Bundle(); } args.putString(KEY_TEXT, str); fragment.setArguments(args); return fragment; } +BWB 葺ֻ֮ؿ؋ؙزٔػة٦ٝ
,PUMJO أ؝٦فꟼ侧 fun newInstance(str: String) = MyFragment().apply { arguments =
(arguments ?: Bundle()).apply { putString(KEY_TEXT, str) } } ˑBQQMZ˒כٖء٦غ「ֽ《גٖء٦غ鵤ׅ ➭חMFU SVO XJUI BMTPָ֮䕵ⶴָ殯ז
,PUMJO أ؝٦فꟼ侧 var test: String? = null var result: String
= text ?: run { // Some processing "Hello, world" } ٕؒؽأ怴皾㶨ה穈さׇג䊩鴟ָOVMMך㜥さך⦼ ⡦ַךⳢ椚ה穈さׇג《䖤דֹ ˟+BWB4DSJQUך⽯儗ꟼ侧䠬鋙
+BWB public class StringUtils { public static boolean isNothing(String text)
{ return text == null || text.isEmpty(); } } OVMMתכ瑞俑㶵ַוֲַثؑحؙ׃ְ
,PUMJO DMBTT PCKFDU class StringUtils { companion object { fun
isNothing(text: String?): Boolean { return text == null || text.isEmpty() } } } object StringUtils { fun isNothing(text: String?): Boolean { return text == null || text.isEmpty() } } TUBUJDًاحسך״ֲח鋅ׇ ˑPCKFDU˒⢪גءؚٕٝزٝד㹀纏ׅ
,PUMJO 䭁䓸ꟼ侧 fun String.isNothing(): Boolean = this == null ||
this.isEmpty() var test: String? = null test.isNothing() // true 㢌侧ך⚥魦ָˑOVMM˒ד/1&搀׃חثؑحָؙדֹ
תכծؽٕز؎ׁٝגְך⢪ֲ @kotlin.internal.InlineOnly public inline fun CharSequence?.isNullOrEmpty(): Boolean = this ==
null || this.length == 0 俑㶵ךOVMMתכˑ瑞˒俑㶵ثؑحָؙדֹ @kotlin.internal.InlineOnly public inline fun CharSequence?.isNullOrBlank(): Boolean = this == null || this.isBlank() 俑㶵ךOVMMתכˑ瑞涯˒俑㶵ثؑحָؙדֹ
+BWB JG俑 String text = "This is java"; String result;
if (text.length % 2 == 0) { result = "Even"; } else { result = "Odd"; } JGˑ俑˒ 㢌侧㹀纏ךة؎ىؚٝד ⦼然㹀דֹזְ
,PUMJO JG䒭 val text = "This is Kotlin" val result
= if (text.length % 2 == 0) { "Even" } else { "Odd" } JGˑ䒭˒ה׃ג⦼鵤⽱ֿׅהָדֹךד 㢌侧㹑鎉儗ח⦼然㹀ׇׁ JGFMTFぐـٗحؙך剑䖓ך遤ָ鐰⣣ׁ
+BWB TXJUDI俑 public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) {
case android.R.id.home: finish(); return true; default: return super.onOptionsItemSelected(); } } ⢽ִלًصُ٦鼅䫛儗ךⳢ椚כ+BWBדכTXJUDI俑ד剅ֻֿהָ㢳ְ TXJUDI俑דכ⦼鵤ֿׅהָדֹזְךד؝٦سָ撕꧟חזװְׅ
,PUMJO XIFO䒭 fun onOptionsItemSelected(item: MenuItem?): Boolean = when(item?.itemId) { android.R.id.home
-> { finish() true } else -> super.onOptionsItemSelected() } ,PUMJOחTXJUDI俑כזֻծ➿חXIFO䒭⢪ֲ XIFO䒭כ⽃秪ז瘝⣣嫰鯰⟃㢩ח侧⦼ךٖٝآ䭷㹀װ㘗ثؑحؙ〳腉
㴍׃ְהָֿˑث٦ي˒חוֲ⸬ְגַֻ ِ٦أ؛٦أ邌׃؝٦سחזװְׅ 搀꼽ָזְךד؝٦سٖؽُ٦ָװװְׅ 然钠ה䭷䶯ך怩ָ㼰זֻז 涪ה然钠ךٕ٦ف넝鸞⻉ֿׅהָדֹ
ِ٦ؠ٦פך⣣⦼䲿⣘ח꧊⚥דֹ
孡אְֽהֿ
,PUMJOח蕱ְהָֿ֮ ًاحس侧 ًاحسקו㟓ִ Lًاحسⵖꣲחעאַ〳腉䚍ָ넝ת "OOPUBUJPO1SPDFTTPS
BQQCVJMEHSBEMF BOOPUBUJPO1SPDFTTPS̔LBQUח㢌ִ LBQUָ欰䧭ׅ؝٦سח㉏겗ָֿ֮ה֮
וֲ㼪Ⰵ鹌גְַֻ
$IBU8PSL،فٔך植朐 ،فٔך؝٦سك٦أכ䎃湡ח瑱Ⰵ ⢪גְ⚺זٓ؎ـٓٔ䪮遭 3FUSPMBNCEB 3Y+BWB
-JHIUXFJHIU4USFBN"1* "OOPUBUJPO1SPDFTTPS .VMUJEFY
וַֿ,PUMJO⢪ְ㨣ַ Ⰻגך؝٦س,PUMJOחׅךכ⯓ָ黅ְ 鿇ⴓ涸ח,PUMJO⻉׃גְֻ $IBU8PSLדכאך%JBMPH'SBHNFOUַ הג⽃秪זت؎،ؚٗ
如ח傀㶷ך؝٦سא,PUMJO⻉ ثٍحزٕ٦يך⡲䧭٥刿倜ך"DUJWJUZ ׁחך䖓ծ倜鋉堣腉؝٦س,PUMJOד鷄⸇ 醱꧟זٗآحؙⰅגְ
וֲװגث٦يח嵴鷲ׇׁגְַֻ ,PUMJOأة٦زـحؙ ˑ鸐獥饔ץֿ劤˒Ⰻ㆞飑Ⰵ׃ג䩛⯋ח縧ֻ 爡ⰻך,PUMJOثٍحزד㉔褏崞⹛ +BWBה,PUMJOד剅ְ㜥さך䊴䫎珲
فؙٕٔؒأزח铡僇؝ًٝز♨㻝ח鎸鶢 +BWBדְֲהֿך⡦ַ ,PUMJOך؎ر؍ؔيך铡僇 ٖؽُ٦䖓ثٍحزד椚鍑דַֹ然钠
None
None
ث٦ي㼪Ⰵך铬겗
ث٦يך稆㖑ה׃ג כַׄ+BWBד؝٦س剅ְגְ -BNCEB䒭䫺䫑זֻ「ֽⰅֿהָדֹ -JHIUXFJHIU4USFBN"1*⢪גְ 0QUJPOBMך罋ִ倯ָ㕼〴ח֮ךדծ /VMMBCMFUZQFT
/PO/VMMUZQFT أحה麩ㄤ䠬זֻ《鴥ֿהָדֹ 穠卓ה׃ג ,PUMJOך؝٦سٖؽُ٦כ㉏겗זַ
ד ث٦يⰋ㆞ָ,PUMJOغٔغٔ剅ֽגכְזְ 植㖈䩛ָֽגְ鿇ⴓך麩ְֽ֮ו ⡦וֿתד,PUMJOד剅ַֻכ㹀תגְזְ ꬊず劍Ⳣ椚דBTZODBXBJU⢪גְַֻהַ
Ⰻ㆞ָ駈⚛䲧ִַוֲַ 铩ַ➂ָֽ,PUMJOח枠鹌׃גְֻ朐屣ָ ث٦يחהגծמְגכِ٦ؠ٦ך⣣⦼חזַ ,PUMJOך؝٦س頾⫈ח׃גכְֽזְ
䩛ָֽכׄה׃ג ,PUMJO㼪Ⰵךח+BWBַ㨣ג葺ְַ "OESPJE4UVEJPַכ㢩鿇خ٦ָٕ♶銲חז "OESPJE(SBEMF1MVHJO EFTVHBSخ٦ٕثؑ٦ٝ
-BNCEB䒭װًاحسٔؿ؋ٖٝأָ⢪ִ 傀㶷فٗآؙؑزח,PUMJO㼪Ⰵׅזל 㼭ֻׁ㨣 +BWBך؝٦سָ؎ً٦آדְֹּ㼭ׁזך
ֶ׃תְ