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.7k
Android MVVM 패턴의 접근법 - 2023 드로이드 나이츠
taehwandev
1
1.8k
안드로이드의 변화 - IO Extended 2023 - 송도
taehwandev
0
610
What’s new in Android?(Google IO ex 23-GDG Pangyo)
taehwandev
0
880
Jetpack Compose 상태 및 사이드 효과
taehwandev
0
1.2k
GDG DevFest2022 Songdo - KMM(Kotlin Multiplatform Mobile)
taehwandev
0
610
Kotlin Night 2022 - 코틀린 어노테이션으로 할 수 있는 것(GDG Seoul)
taehwandev
2
1.6k
Android module 개발 - Now in android 참고
taehwandev
3
17k
Android Compose Component - mapping.
taehwandev
2
4.8k
Other Decks in Education
See All in Education
Data Processing and Visualisation Frameworks - Lecture 6 - Information Visualisation (4019538FNR)
signer
PRO
1
2.4k
Sponsor the Conference | VizChitra 2025
vizchitra
0
550
データ分析
takenawa
0
5.8k
IMU-00 Pi
kanaya
0
370
技術勉強会 〜 OAuth & OIDC 入門編 / 20250528 OAuth and OIDC
oidfj
5
1.2k
Pydantic(AI)とJSONの詳細解説
mickey_kubo
0
100
生成AI
takenawa
0
5.8k
Tutorial: Foundations of Blind Source Separation and Its Advances in Spatial Self-Supervised Learning
yoshipon
1
120
新卒研修に仕掛ける 学びのサイクル / Implementing Learning Cycles in New Graduate Training
takashi_toyosaki
1
150
社外コミュニティと「学び」を考える
alchemy1115
2
170
アウトプット0のエンジニアが半年でアウトプットしまくった話 With JAWS-UG
masakiokuda
2
310
2025.05.10 技術書とVoicyとわたし #RPALT
kaitou
1
220
Featured
See All Featured
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
A designer walks into a library…
pauljervisheath
207
24k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
281
13k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Fireside Chat
paigeccino
37
3.5k
Designing Experiences People Love
moore
142
24k
The Pragmatic Product Professional
lauravandoore
35
6.7k
BBQ
matthewcrist
89
9.7k
What's in a price? How to price your products and services
michaelherold
246
12k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.7k
GraphQLとの向き合い方2022年版
quramy
49
14k
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 ӂకജ ޙೞप ѱ թਵ࣑ݶ,