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
Tangible, Embedded and Embodied Interaction - Lecture 7 - Next Generation User Interfaces (4018166FNR)
signer
PRO
0
1.7k
Pythonパッケージ管理 [uv] 完全入門
mickey_kubo
20
13k
Webリテラシー基礎
takenawa
0
3.8k
2025年度春学期 統計学 第10回 分布の推測とは ー 標本調査,度数分布と確率分布 (2025. 6. 12)
akiraasano
PRO
0
120
Gesture-based Interaction - Lecture 6 - Next Generation User Interfaces (4018166FNR)
signer
PRO
0
1.7k
日本の教育の未来 を考える テクノロジーは教育をどのように変えるのか
kzkmaeda
1
200
登壇未経験者のための登壇戦略~LTは設計が9割!!!~
masakiokuda
1
280
SkimaTalk Tutorial for Corporate Customers
skimatalk
0
280
仮説の取扱説明書/User_Guide_to_a_Hypothesis
florets1
4
290
小さなチャレンジが生んだチームの大きな変化 -私のふりかえり探求の原点
callas1900
0
520
Dashboards - Lecture 11 - Information Visualisation (4019538FNR)
signer
PRO
1
2k
SkimaTalk Teacher Guidelines Summary
skimatalk
0
780k
Featured
See All Featured
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
790
Side Projects
sachag
455
42k
Documentation Writing (for coders)
carmenintech
71
4.9k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
657
60k
Producing Creativity
orderedlist
PRO
346
40k
Site-Speed That Sticks
csswizardry
10
640
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
228
22k
The Cult of Friendly URLs
andyhume
79
6.4k
Rails Girls Zürich Keynote
gr2m
94
14k
4 Signs Your Business is Dying
shpigford
184
22k
Agile that works and the tools we love
rasmusluckow
329
21k
RailsConf 2023
tenderlove
30
1.1k
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 ӂకജ ޙೞप ѱ թਵ࣑ݶ,