728x90

Android 17

[Android] Kotlin Delegates in Android: Android ๊ฐœ๋ฐœ์— Properties Delegate ํ™œ์šฉํ•˜๊ธฐ

์ž‘์„ฑ์ผ: 2019.12.02 ์›๋ฌธ Kotlin Delegates in Android: Utilizing the power of Delegated Properties in Android development์„ ๋ฒˆ์—ญํ•œ ๊ธ€์ž…๋‹ˆ๋‹ค. Delegate์— ๋Œ€ํ•œ ์„ค๋ช…๊ณผ ํ•จ๊ป˜ Android ๊ฐœ๋ฐœ์—์„œ ์ž์ฃผ ์‚ฌ์šฉ๋˜๋Š” ์ฝ”๋“œ๋“ค์„ ์˜ˆ์ œ๋กœ ์‰ฝ๊ฒŒ ์„ค๋ช…ํ•ด์ค๋‹ˆ๋‹ค. ์ค‘๋ณต๋˜๋Š” ์ฝ”๋“œ๋“ค์„ Delegate๋ฅผ ํ†ตํ•ด ๊ฐœ์„ ํ•ด๋ณผ ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™๋„ค์š” ๐Ÿ™‚ Kotlin์€ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ฐœ๋ฐœ์— ๋„์›€์ด ๋˜๋Š” ๊ธฐ๋Šฅ์„ ๊ฐ€์ง„ ์•„์ฃผ ๋ฉ‹์ง„ ์–ธ์–ด์ž…๋‹ˆ๋‹ค. ๊ทธ ์ค‘ ํ•˜๋‚˜๊ฐ€ Delegate Propertis์ž…๋‹ˆ๋‹ค. ์ด ๊ธ€์—์„œ Delegate๊ฐ€ ์•ˆ๋“œ๋กœ์ด๋“œ ๊ฐœ๋ฐœ์— ์–ด๋–ค ๋„์›€์ด ๋˜๋Š”์ง€ ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. Basics Fragment arguments SharedPreferences del..

[Android] Kotlin Extension Function์„ ์‚ฌ์šฉํ•˜์—ฌ ๋”๋ธ” ํด๋ฆญ ๋ฐฉ์ง€ํ•˜๊ธฐ

์ž‘์„ฑ์ผ: 2019.11.28 ์ฝ”ํ‹€๋ฆฐ ํ™•์žฅ ํ•จ์ˆ˜๋ฅผ ํ†ตํ•ด View ๋”๋ธ” ํด๋ฆญ ๋ฐฉ์ง€๋ฅผ ์‰ฝ๊ฒŒ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ณดํ†ต ๋”๋ธ” ํด๋ฆญ ๋ฐฉ์ง€๋ฅผ ์œ„ํ•ด ํŠน์ • ์‹œ๊ฐ„์„ ์ •ํ•ด๋‘๊ณ  ํ•œ ๋ฒˆ ํด๋ฆญ ํ›„ ํ•ด๋‹น ์‹œ๊ฐ„ ์ด๋‚ด์˜ ํด๋ฆญ ์ด๋ฒคํŠธ๋Š” ๋ฌด์‹œํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ง์ ‘ ์ „์—ญ Util ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“ค์–ด ์‚ฌ์šฉํ•˜๊ฑฐ๋‚˜ RxBinding์˜ throttle์„ ์ด์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ ์žˆ์Šต๋‹ˆ๋‹ค. Util ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์€ onClick()๋งˆ๋‹ค boilerplate๊ฐ€ ์ƒ๊ธฐ๊ฒŒ ๋˜๊ณ , ๊นœ๋นกํ•˜๊ณ  ์ถ”๊ฐ€๋ฅผ ํ•˜์ง€ ์•Š์€ ๊ฒฝ์šฐ๋„ ์ƒ๊ธฐ๊ธฐ ์‰ฝ์Šต๋‹ˆ๋‹ค. backButton.setOnClickListener { if (ExampleUtils.isDoubleClick()) return@setOnClickListener onBackPressed() } RxBinding ์‚ฌ์šฉ ๋˜ํ•œ ..

[Android] Jetpack - LiveData

์ž‘์„ฑ์ผ: 2019.07.01 LiveData๋ฅผ ํ”„๋กœ์ ํŠธ์— importํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ํ”„๋กœ์ ํŠธ์— ์ปดํฌ๋„ŒํŠธ ์ถ”๊ฐ€ํ•˜๊ธฐ ์ฐธ๊ณ  LiveData Observable Data Holder Class Lifecycle-aware Activity, Fragment, Service ๊ฐ™์€ ์•ฑ ์ปดํฌ๋„ŒํŠธ์˜ Lifecycle๊ณผ ์—ฐ๊ด€ ํ™œ์„ฑํ™”(active) ์ƒํƒœ(STARTED ๋˜๋Š” RESUMED)์ธ Observer์—๊ฒŒ๋งŒ ์—…๋ฐ์ดํŠธ๋ฅผ ์•Œ๋ฆผ LifecycleOwner์˜ Lifecycle์ด DESTROYED ์ƒํƒœ๊ฐ€ ๋˜๋ฉด Observer๋ฅผ ์ œ๊ฑฐ leak์— ๋Œ€ํ•œ ๊ฑฑ์ •์—†์ด ์•ˆ์ „ํ•˜๊ฒŒ LiveData๋ฅผ observe ๊ฐ€๋Šฅ Activity์™€ Fragment์—์„œ ํŠนํžˆ ์œ ์šฉ LiveData ์‚ฌ์šฉ๋ฒ•์— ๋Œ€ํ•œ ๋” ๋งŽ์€ ์ •๋ณด๋Š” Work with LiveData o..

[Android] 100% ์ดˆ๋ณด์ž๋ฅผ ์œ„ํ•œ RxJava(RxJava for 100% beginners)-part 1

์ž‘์„ฑ์ผ: 2018.03.07 ์ด ๊ธ€์€ ์›๋ฌธ์„ ๋ฒˆ์—ญํ•œ ๊ธ€์ž…๋‹ˆ๋‹ค. RxJava for 100% beginners(part 1) ์š”์ฆˆ์Œ ๋งŽ์€ Android ๊ฐœ๋ฐœ์ž๋“ค์ด “Reactive Programming/RxJava”์˜ ์กด์žฌ๋ฅผ ์ž˜ ์•Œ๊ณ  ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ์ตœ๊ทผ Android Weekly์—๋Š” ๋งค ์ฃผ RxJava์™€ ๊ด€๋ จ๋œ ๋ธ”๋กœ๊ทธ ํฌ์ŠคํŠธ๊ฐ€ ํ•ญ์ƒ ์žˆ๊ธฐ๋„ ํ–ˆ์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ, RxJava์˜ ๋ฌธ๋ฒ•์— ์‚ฌ์šฉ๋œ ํ•จ์ˆ˜ํ˜• ํ”„๋กœ๊ทธ๋ž˜๋ฐ์— ๋Œ€ํ•ด ์ž˜ ๋ชจ๋ฅด๋Š” ์ดˆ๋ณด์ž์—๊ฒŒ๋Š” ์กฐ๊ธˆ ์–ด๋ ค์šธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Scala์—์„œ๋Š”, RxJava์˜ map(), filter(), flatmap() ๋“ฑ๊ณผ ์œ ์‚ฌํ•œ ์˜คํผ๋ ˆ์ดํ„ฐ๋“ค์ด ์žˆ์Šต๋‹ˆ๋‹ค. ๋งŒ์•ฝ ์ด์ „์— Scalar๋‚˜ (RxJava๊ฐ€ ๊ฐœ๋…๊ณผ ๋ฌธ๋ฒ•์„ ์ฐจ์šฉํ•œ) ๋‹ค๋ฅธ ํ•จ์ˆ˜ํ˜• ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋ฅผ ์‚ฌ์šฉํ•ด๋ดค๋‹ค๋ฉด, ์•„์˜ˆ ์จ๋ณด์ง€ ์•Š..

[Android] ๋ ˆ์ด์•„์›ƒ ๊ณ„์ธต ์„ฑ๋Šฅ ์ตœ์ ํ™”(Optimizing Layout Hierarchies)

์ž‘์„ฑ์ผ: 2018.03.07 ์›๋ฌธ: Optimizing Layout Hierarchies์„ ๋ฒˆ์—ญํ•œ ๊ธ€์ž…๋‹ˆ๋‹ค. ๋ฒ ์ด์ง ๋ ˆ์ด์•„์›ƒ ๊ตฌ์กฐ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ๊ฐ€์žฅ ํšจ๊ณผ์ ์ธ ๋ ˆ์ด์•„์›ƒ์ด ๋œ๋‹ค๋Š” ๊ฒƒ์€ ํ”ํ•œ ์˜คํ•ด์ž…๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜, ๋‹น์‹ ์ด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— ์ถ”๊ฐ€ํ•œ ๊ฐ ์œ„์ ฏ๊ณผ ๋ ˆ์ด์•„์›ƒ์€ ์ดˆ๊ธฐํ™”, ๋ฐฐ์น˜, ๊ทธ๋ ค์ง€๋Š” ๊ณผ์ •์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ์ค‘์ฒฉ๋œ LinearLayout์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์€ ์ง€๋‚˜์น˜๊ฒŒ ๊นŠ์€ ๋ทฐ ๊ณ„์ธต์„ ์ดˆ๋ž˜ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ฒŒ๋‹ค๊ฐ€, layout_weight๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ช‡ ๊ฐœ์˜ LinearLayout์„ ์ค‘์ฒฉํ•˜๋Š” ๊ฒƒ์€ ๊ฐ child๊ฐ€ ํ•œ๋ฒˆ ๋” ์ธก์ •๋˜๊ธฐ ๋•Œ๋ฌธ์— ํŠนํžˆ ๋น„์šฉ์ด ๋†’์Šต๋‹ˆ๋‹ค. ListView๋‚˜ GridView๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ์ฒ˜๋Ÿผ inflate๊ฐ€ ๋ฐ˜๋ณต๋˜๋Š” ๊ฒฝ์šฐ ํŠนํžˆ ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค. ์ด ๊ธ€์„ ํ†ตํ•ด ๋ ˆ์ด์•„์›ƒ์„ ๊ฒ€ํ† ํ•˜๊ณ  ์ตœ์ ํ™”ํ•˜๊ธฐ..

[Android] Bitmap์— ์ƒ‰์ƒ ์ž…ํžˆ๊ธฐ

์ž‘์„ฑ์ผ: 2017.12.10 ๋น„ํŠธ๋งต์— ์ƒ‰์ƒ์„ ๋ฎ์–ด ์”Œ์šฐ๋Š” ๋ฐฉ๋ฒ• -> ๊ฐ™์€ ์ด๋ฏธ์ง€๋ฅผ ์—ฌ๋Ÿฌ ์ƒ‰์œผ๋กœ ์‚ฌ์šฉํ•ด์•ผ ํ•  ๋•Œ ์œ ์šฉํ•˜๋‹ค. ์˜ˆ์‹œ๋Š”, ํฐ์ƒ‰ ์•„์ด์ฝ˜์„ ๋‹ค๋ฅธ ์ƒ‰์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ. (์•„์ด์ฝ˜์ด ํฐ์ƒ‰์ด๋ผ ์ž„์‹œ๋กœ ๋ฐฐ๊ฒฝ์ƒ‰์„ ์คŒ.) //1. Drawable -> Bitmap Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.email_xxl).copy(Bitmap.Config.ARGB_8888, true); //2. ColorFilter ๋งŒ๋“ค๊ธฐ Paint paint = new Paint(); ColorFilter colorFilter = new PorterDuffColorFilter(Color.DKGRAY, PorterDuff.Mode.SRC..

[Android] Live Data

์ž‘์„ฑ์ผ: 2017.07.09 LiveData ๋Š” ๊ฐ’์„ ์œ ์ง€ํ•˜๊ณ , ์ด ๊ฐ’์ด observed ์ƒํƒœ๋ฅผ ๊ฐ–๊ฒŒ ํ•ด์ฃผ๋Š” data holder ํด๋ž˜์Šค์ด๋‹ค. ์ผ๋ฐ˜์ ์ธ Observerble๊ณผ ๋‹ฌ๋ฆฌ LiveData๋Š” ์•ฑ ์ปดํฌ๋„ŒํŠธ์˜ ๋ผ์ดํ”„ ์‚ฌ์ดํด์„ ๋”ฐ๋ฅธ๋‹ค. LiveData๋ฅผ ์•ˆ๋“œ๋กœ์ด๋“œ ํ”„๋กœ์ ํŠธ์— importํ•˜๋Š” ๋ฐฉ๋ฒ•์€ adding components to your project LiveData๋Š” Observer์˜ ๋ผ์ดํ”„ ์‚ฌ์ดํด์ด STARTED ๋˜๋Š” RESUMED ์ƒํƒœ์ผ ๋•Œ๋งŒ Observer๋ฅผ ํ™œ์„ฑํ™” ์ƒํƒœ๋กœ ์—ฌ๊ธด๋‹ค. Location Sample public class LocationLiveData extends LiveData { private LocationManager locationManager; private Simp..