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
Taehwan-IO18_Extended_in_Suwon.pdf
Search
TaeHwan
June 25, 2018
Education
2
14k
Taehwan-IO18_Extended_in_Suwon.pdf
GDG Google I/O Extended in Suwon.
TaeHwan
June 25, 2018
Tweet
Share
More Decks by TaeHwan
See All by TaeHwan
Compose 함수 나누는 조건은?
taehwandev
0
1.2k
Android MVVM 패턴의 접근법 - 2023 드로이드 나이츠
taehwandev
1
1.6k
안드로이드의 변화 - IO Extended 2023 - 송도
taehwandev
0
520
What’s new in Android?(Google IO ex 23-GDG Pangyo)
taehwandev
0
810
Jetpack Compose 상태 및 사이드 효과
taehwandev
0
1.1k
GDG DevFest2022 Songdo - KMM(Kotlin Multiplatform Mobile)
taehwandev
0
550
Kotlin Night 2022 - 코틀린 어노테이션으로 할 수 있는 것(GDG Seoul)
taehwandev
2
1.6k
Android module 개발 - Now in android 참고
taehwandev
3
16k
Android Compose Component - mapping.
taehwandev
2
4.5k
Other Decks in Education
See All in Education
cbt2324
cbtlibrary
0
110
MLH Hackcon: Keynote (2024)
theycallmeswift
0
180
開発終了後こそ成長のチャンス!プロダクト運用を見送った先のアクションプラン
ohmori_yusuke
2
160
オープンソース防災教育ARアプリの開発と地域防災での活用
nro2daisuke
0
170
Introduction - Lecture 1 - Human-Computer Interaction (1023841ANR)
signer
PRO
0
1.7k
Padlet opetuksessa
matleenalaakso
4
12k
お仕事図鑑pitchトーク
tetsuyaooooo
0
2.3k
【COPILOT無料セミナー】エンゲージメントと自律性の高いプロジェクト型人材育成に向けて~プロジェクト・ベースド・ラーニング(PBL)という選択肢~
copilot
PRO
0
130
技術を楽しもう/enjoy_engineering
studio_graph
1
420
Repaso electricidade e electrónica
irocho
0
200
JavaScript - Lecture 6 - Web Technologies (1019888BNR)
signer
PRO
0
2.5k
Canva
matleenalaakso
0
430
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
720
Fireside Chat
paigeccino
34
3k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
Six Lessons from altMBA
skipperchong
27
3.5k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Transcript
Kotlin / Android KTX Android Jetpack Tae-hwan
ࣗѐ ! GDG Seoul ! RGP Korea ਃӝਃ উ٘۽٘
ѐߊ ! Է ݆ ѐߊо غ ࠶۽Ӓ http://thdev.tech / http://thdev.net ! Udemy ౣܽ ъ
Android Jetpack Foundation, Architecture, Behavior, UI
Android Jetpack Jetpack Android ѐߊী ਃೠ ߈ੋ ۄ࠳۞ܻ ݽ
о٘ - Foundation, Architecture, Behavior, UI Jetpack : https://developer.android.com/jetpack/
Android Jetpack Jetpack
Android Jetpack AndroidX ӝઓ ۄ࠳۞ܻٜ Package name ా Jetpackীࢲח androidx.*
ಁఃܳ ࢎਊ Compile version 28ࠗఠ ࢎਊ оמ AndroidX Release Note AndroidX convert ܻ Ӗ - thdev Google Jetpack Sample - Android Sunflower (alpha)
New Project ࢤࢿ Target API 28۽ ࢸೡ ҃
Android Jetpack ViewModel - AS 3.2 Previewীࢲ ࢤࢿೞӝ
Android Jetpack ViewModel - AS 3.2 Previewীࢲ ࢤࢿೞӝ
Android Jetpack ViewModel - ViewModel ਊ package ҳઑ
Android Jetpack New androidx package compileSdkVersion Android 28 ࢚ ࢎਊ
оמ dependencies { implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.0.0-alpha1' implementation 'androidx.constraintlayout:constraintlayout:1.1.0' implementation ‘androidx.lifecycle:lifecycle-extensions:2.0.0-alpha1' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.1.0-alpha3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3' }
Android Jetpack Jetpack - MainFragment.kt class MainFragment : Fragment() {
companion object { fun newInstance() = MainFragment() } private lateinit var viewModel: MainViewModel override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) viewModel = ViewModelProviders.of(this).get(MainViewModel::class.java) // TODO: Use the ViewModel } }
Android Jetpack Jetpack - ViewModel.kt class MainViewModel : ViewModel() {
// TODO: Implement the ViewModel override fun onCleared() { super.onCleared() // todo release } }
Kotlin Kotlin णೞח ߑߨ
Kotlin Kotlin णೞח ߑߨ? Reference ଵҊೞӝ : https://kotlinlang.org/docs/reference/ ଼ Kotlin
in Action - ೠӖ/ޙ ழפ ౣܽ: ରࣁ উ٘۽٘ ѐߊܳ ਤೠ ৡۄੋ ъ Kotlin Bootcamp for Programmers - Udacity ઁ ъ ౣܽ दೞӝ - Udemy
Kotlin Kotlin णೞח ߑߨ? - Java ࢿ - Kotlin ஶߡ
ೞӝ(بҳীࢲ ઁҕೞח ஶߡఠ/Kotlin ࢎীࢲ ઁҕೞח ஶߡఠ ഝਊ) - Java۽ ࢿೞҊ, ࠂࢎ ࠢৈ֍ӝܳ ా೧ ஶߡఠೞҊ, ઑӘঀ ࣻ೧ ࠄ - Kotlin ӝࠄ ޙߨ(Lambda, fun, class ١) ࣼ റ ೞաঀ ਊ೧ࠄ Repeat. ࣼ೧ ݅ఀ ٘ ח ߑߨਸ णٙೞҊ, Extension ࢎਊ ١ਸ ӓ ഝਊ೧ࠄ
Kotlin ഥࢎী ਊ? ѐੋ ࠶۽Ӓ ࣗѐ https://thdev.tech/kotlin/android/2018/01/02/Kotlin-Learning-and-Introduction.html ഥࢎ ࠶۽Ӓ ࣗѐ
https://rgpkorea.github.io/posts/yogiyo-kotlin/
Kotlin Android KTX ঌইࠁӝ ী
Kotlin Android KTX ঌইࠁӝ ী - ҳࢿ Lambdas അ Kotlin
Extension Higher-Order Function
Kotlin Lambdas Button button = findViewById(R.id.btn); button.setOnClickListener(new View.OnClickListener() { @Override
public void onClick(View view) { // TODO } });
Kotlin Lambdas Button button = findViewById(R.id.btn); button.setOnClickListener(new View.OnClickListener() { @Override
public void onClick(View view) { // TODO } }); // kotlin val button = findViewById<Button>(R.id.btn) button.setOnClickListener { // TODO } ଵҊ : https://thdev.tech/kotlin/2018/03/17/Kotlin-Lambdas.html
Kotlin Kotlin Extension Extension ਗې ېझীࢲ ઁҕೞח ӝמੋ Ѫۢ ഛ
ೣࣻܳ ٜ݅ ࣻ .
Kotlin Kotlin Extension val name: String? = null if (name.isNullOrEmpty())
{ // ... } val name ߸ࣻо null ژח “”ੋ ҃ܳ ഛੋೞৈ ߹ب ܻܳ ೠ. ೞ݅ String class/CharSequence class উীח isNullOrEmpty() ݫࣗ٘ח ઓೞ ঋח. @kotlin.internal.InlineOnly public inline fun CharSequence?.isNullOrEmpty(): Boolean { contract { returns(false) implies (this@isNullOrEmpty != null) } return this == null || this.length == 0 } ଵҊ : https://kotlinlang.org/docs/reference/extensions.html
Kotlin Higher-Order Function Higher-Order Functions ೣࣻܳ ߸ࣻ۽ ֈѹѢա, ܳ ߈ജೞח
Ѫਸ ݈פ.
Kotlin Higher-Order Function Higher-Order Functions ೣࣻܳ ߸ࣻ۽ ֈѹѢա, ܳ ߈ജೞח
Ѫਸ ݈פ. fun print(body: () -> String) { println(body()) } print { “Ѣ ۱೧” } >> body: () -> T body : ߸ࣻ ܴ () -> String : () ۄݫఠо হח ݫࢲ٘ܳ ೞҊ, -> String return ఋੑਸ פ. ଵҊ : https://thdev.tech/kotlin/2017/10/02/Kotlin-Higher-Order-Function.html
Kotlin Android KTX
Kotlin Android KTX What is Android KTX? Jetpack family Android
- Kotlin ࢎਊ ಞܳ ذח extensions AndroidX ಁః۽ ઁҕ implementation ‘androidx.core:core-ktx:1.0.0-alpha1’ Android Open Source Project Apache License, Version 2.0 API : https://github.com/android/android-ktx API reference documentation : https://android.github.io/android-ktx/core-ktx/ Android Jetpack: sweetening Kotlin development with Android KTX (Google I/O '18)
Kotlin Android KTX Modules androidx.core:core-ktx androidx.fragment:fragment-ktx androidx.sqlite:sqlite-ktx androidx.lifecycle:lifecycle-viewmodel-ktx android.arch.navigation:navigation-common-ktx android.arch.work:work-runtime-ktx
More modules : https://developer.android.com/kotlin/ktx
Kotlin Android KTX ਃ٘ > kotlin sharedPreferences.edit() .putBoolean("key", value) .apply()
> Android KTX sharedPreferences.edit { putBoolean("key", value) }
Kotlin Android KTX ਃ٘ > Android KTX sharedPreferences.edit { putBoolean("key",
value) } > ղࠗ ٘ @SuppressLint("ApplySharedPref") inline fun SharedPreferences.edit( commit: Boolean = false, action: SharedPreferences.Editor.() -> Unit ) { val editor = edit() action(editor) if (commit) { editor.commit() } else { editor.apply() } }
Kotlin Android KTX ٘ ୷ড જ Ѫ݅ ইפ Kotlinਸ ೞݶ
٘ ୷ডਸ ݆ ೠ Ӓѱ ޖઑѤ જ Ѫ ইפ
Kotlin Android KTX ٘ ୷ড if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
{ // Something } ਤ ٘ܳ ۰ ݅ٚ ഛ ೣࣻ inline fun onApi(level: Int, body: () -> Unit) { if (Build.VERSION.SDK_INT >= level) { body() } } onApi(Build.VERSION_CODES.P) { // Something }
Kotlin Android KTX ٘ ୷ড if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
{ // Something } else { // Something } ਤ ٘ܳ ۰ ݅ٚ ഛ ೣࣻ inline fun onApi(level: Int, body: () -> Unit, bodyElse: () -> Unit) { if (Build.VERSION.SDK_INT >= level) { body() } else { bodyElse() } }
Kotlin Android KTX ٘ ୷ড onApi(Build.VERSION_CODES.P, { // if
Something }) { // else Something } ਤ ٘ܳ ۰ ݅ٚ ഛ ೣࣻ inline fun onApi(level: Int, body: () -> Unit, bodyElse: () -> Unit) { if (Build.VERSION.SDK_INT >= level) { body() } else { bodyElse() } }
Kotlin Android KTX ٘ ୷ড if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
{ // Something } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // Something } else { // Something } ਤ ٘ܳ ۰ ݅ٚ ഛ ೣࣻ inline fun onApi(level: Int, body: () -> Unit, levelTwo: Int, bodyTwo: () -> Unit, bodyElse: () -> Unit) { if (Build.VERSION.SDK_INT >= level) { body() } else if (Build.VERSION.SDK_INT >= levelTwo) { bodyTwo() } else { bodyElse() } }
Kotlin Android KTX ٘ ୷ড onApi(Build.VERSION_CODES.P, { // if
Something }, Build.VERSION_CODES.KITKAT, { // else if Something }) { // else Something } ਤ ٘ܳ ۰ ݅ٚ ഛ ೣࣻ inline fun onApi(level: Int, body: () -> Unit, levelTwo: Int, bodyTwo: () -> Unit, bodyElse: () -> Unit) { if (Build.VERSION.SDK_INT >= level) { body() } else if (Build.VERSION.SDK_INT >= levelTwo) { bodyTwo() } else { bodyElse() } }
Kotlin Android KTX KEEP-110 KEEP > Kotlin Evolution Enhancement Process
KEEP-110 ۽ંܳ ా೧ Javaীࢲب Kotlin ಞࢿਸ ֫ @ExtensionFunction/@ExtensionProperty - Kotlin ഛ ೣࣻܳ ઁҕ @DefaultValue - Kotlin ٣ಫ ۄݫఠ ӝמ ઁҕ @KtName - function ۄݫఠী Kotlinীࢲ ࠗܳ ܴਸ ߹ب оמ > ই ֤ੋ ઁ۽ য֢ప࣌ ܴ ߸҃ؼ ࣻ GitHub : https://github.com/Kotlin/KEEP
KEEP-110 @ExtensionFunction/@ExtensionProperty @ExtensionFunction public static String getNonNullName(@Nullable String name) {
return name != null ? name : ""; } Kotlin ഐ val name: String? = null println(name.getNonNullName()) > Kotlinীࢲח ইې৬ э ࢿ fun String?.getNonNullName() = this?.takeIf { it.isNotEmpty() } ?: ""
KEEP-110 @KtName - ۄݫఠ ܴ public static void setPadding(
@KtName("left") int left, @KtName("top") int top, @KtName("right") int right, @KtName("bottom") int bottom) { /* todo... */ } Kotlinীࢲ ࠗܳٸ setPadding(left = 0, top = 15, right = 0, bottom = 0) > ࣽࢲо ߸҃غযب ޙઁо হ setPadding(right = 0, bottom = 0, left = 0, top = 15)
KEEP-110 @DefaultValue - ӝࠄч public static void setPadding( @KtName("left")
@DefaultValue("paddingLeft") int left, @KtName("top") @DefaultValue("paddingTop") int top, @KtName("right") @DefaultValue("paddingRight") int right, @KtName("bottom") @DefaultValue("paddingBottom") int bottom) { /* todo... */ } Kotlinীࢲ ࠗܳٸ setPadding(top = 15) left, right, bottom = defaultValue۽ ୡӝച
хࢎפ http://thdev.tech
[email protected]
GDG Seoul ӂకജ ޙೞप ѱ թਵ࣑ݶ,