๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

์ „์ฒด ๊ธ€

(374)
[Programming] ๋ฉฑ๋“ฑ(ๅ†ช็ญ‰, idempotent) ko.wikipedia.org/wiki/%EB%A9%B1%EB%93%B1%EB%B2%95%EC%B9%99 ๋ฉฑ๋“ฑ๋ฒ•์น™ - ์œ„ํ‚ค๋ฐฑ๊ณผ, ์šฐ๋ฆฌ ๋ชจ๋‘์˜ ๋ฐฑ๊ณผ์‚ฌ์ „ ์œ„ํ‚ค๋ฐฑ๊ณผ, ์šฐ๋ฆฌ ๋ชจ๋‘์˜ ๋ฐฑ๊ณผ์‚ฌ์ „. ๋ฉฑ๋“ฑ๋ฒ•์น™(ๅ†ช็ญ‰ๆณ•ๅ‰‡) ๋˜๋Š” ๋ฉฑ๋“ฑ์„ฑ(ๅ†ช็ญ‰ๆ€ง, ์˜์–ด: idempotent)์€ ์ˆ˜ํ•™์ด๋‚˜ ์ „์‚ฐํ•™์—์„œ ์—ฐ์‚ฐ์˜ ํ•œ ์„ฑ์งˆ์„ ๋‚˜ํƒ€๋‚ด๋Š” ๊ฒƒ์œผ๋กœ, ์—ฐ์‚ฐ์„ ์—ฌ๋Ÿฌ ๋ฒˆ ์ ์šฉํ•˜๋”๋ผ๋„ ๊ฒฐ๊ณผ๊ฐ€ ๋‹ฌ๋ผ ko.wikipedia.org ๋ฉฑ๋“ฑ๋ฒ•์น™, ๋ฉฑ๋“ฑ์„ฑ ์—ฐ์‚ฐ์„ ์—ฌ๋Ÿฌ๋ฒˆ ์ ์šฉํ•ด๋„ ๊ฒฐ๊ณผ๋Š” ๊ฐ™์€ ์„ฑ์งˆ ๋ฉฑ๋“ฑ์„ฑ์ด ์žˆ๋Š” ํ•จ์ˆ˜๋Š” ๋ฉฑ๋“ฑ ํ•จ์ˆ˜(idempotent function)๋ผ๊ณ  ๋ถ€๋ฆ„ ๋‹จํ•ญ์—ฐ์‚ฐ ๋‹จํ•ญ์—ฐ์‚ฐ f, ์–ด๋–ค ์ง‘ํ•ฉ S์˜ ๋ชจ๋“  ์›์†Œ๋Š” x f(f(x)) = f(x) ์ดํ•ญ์—ฐ์‚ฐ ์ดํ•ญ์—ฐ์‚ฐ โ˜…, ์–ด๋–ค ์ง‘ํ•ฉ S์˜ ๋ชจ๋“  ์›์†Œ x xโ˜…x = x ํ”„๋กœ๊ทธ๋ž˜๋ฐ์—์„œ ๋ฉฑ๋“ฑ์„ฑ ํ•จ์ˆ˜๋ฅผ ์—ฌ๋Ÿฌ๋ฒˆ ํ˜ธ์ถœํ•ด..
[Library] Moshi Converter github.com/square/retrofit/tree/master/retrofit-converters/moshi square/retrofit A type-safe HTTP client for Android and the JVM. Contribute to square/retrofit development by creating an account on GitHub. github.com ์˜ˆ์ œ private fun getRetrofit() = Retrofit.Builder() .baseUrl(BASE_URL) .addConverterFactory(MoshiConverterFactory.create()) .build() Gson ๋ณด๋‹ค Moshi๊ฐ€ ๋‚˜์€ ์  : www.reddit.com/r/androiddev/..
[Java] Class.java public boolean isAssignableFrom(Class<?> cls) java.lang.Class public boolean isAssignableFrom(Class cls) ํ•ด๋‹น ํด๋ž˜์Šค(๋˜๋Š” ์ธํ„ฐํŽ˜์ด์Šค)์˜ Class object ๊ฐ€ ํŒŒ๋ผ๋ฏธํ„ฐ cls(ํด๋ž˜์Šค ๋˜๋Š” ์ธํ„ฐํŽ˜์ด์Šค) Class์™€ ๋™์ผํ•˜๊ฑฐ๋‚˜ cls์˜ superclass ๋˜๋Š” superinterface์ผ ๊ฒฝ์šฐ true๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค. ์•„๋‹ ๊ฒฝ์šฐ false ๋ฐ˜ํ™˜. ์ฆ‰, ํ•ด๋‹น ํด๋ž˜์Šค/์ธํ„ฐํŽ˜์ด์Šค๊ฐ€ ๋งค๊ฐœ๋ณ€์ˆ˜์˜ ํด๋ž˜์Šค/์ธํ„ฐํŽ˜์Šค์™€ ๊ฐ™๊ฑฐ๋‚˜, ๋งค๊ฐœ๋ณ€์ˆ˜์˜ ํด๋ž˜์Šค์˜ ๋ถ€๋ชจ ํด๋ž˜์Šค/์ธํ„ฐํŽ˜์ด์Šค์ธ์ง€ ์—ฌ๋ถ€๋ฅผ ๋ฐ˜ํ™˜. {์ž์‹ ํด๋ž˜์Šค}.isAssignableFrom({์ž์‹ ํด๋ž˜์Šค}) -> true {์ž์‹ ํด๋ž˜์Šค}.isAssignableFrom({๋ถ€๋ชจ ํด๋ž˜์Šค}) -> false {๋ถ€๋ชจ ํด๋ž˜์Šค}.isAssignableFrom({์ž์‹ ํด๋ž˜์Šค}) -> fals..
[Kotlin] ::class.java ์ฝ”ํ‹€๋ฆฐ์—์„œ ์ž๋ฐ” ๋ฆฌํ”Œ๋ ‰์…˜ ์‚ฌ์šฉํ•˜๋„๋ก ํ•จ. kotlinlang.org/docs/java-interop.html#java-reflection
[Android ์‚ฝ์งˆ ๊ตํ›ˆ] ์ด๋ชจ์ง€ ํ•˜๋‚˜๋ฅผ ํ•œ ๊ธ€์ž๋กœ ์„ธ๊ธฐ ์œ„ํ•ด ์ปค์Šคํ…€ InputFilter๋ฅผ ๋งŒ๋“ค์—ˆ์–ด์š”. ์š”์•ฝ ์•ˆ๋“œ๋กœ์ด๋“œ ์ž…๋ ฅ์ฐฝ์—์„œ ์ด๋ชจ์ง€ ํ•˜๋‚˜๋ฅผ ํ•œ ๊ธ€์ž๋กœ ์ธ์‹ํ•˜์ง€ ๋ชปํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์–ด์š”. ๊ทธ๋ž˜์„œ ์ด๋ชจ์ง€ ํ•˜๋‚˜๋ฅผ ํ•œ ๊ธ€์ž๋กœ ์—ฌ๊ธฐ๊ณ  ๊ธ€์ž ์ˆ˜๋ฅผ ์„ธ๊ธฐ ์œ„ํ•ด์„œ๋Š” ์ž‘์—…์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ์ €๋Š” ์ปค์Šคํ…€ InputFilter๋ฅผ ๋งŒ๋“ค์—ˆ์–ด์š”. ๊ธฐํš์ƒ ์ž…๋ ฅ์ฐฝ์— ๊ธ€์ž์ˆ˜ ์ œํ•œ์ด ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. ์ผ๋ฐ˜ ๊ธ€์ž, ์ˆซ์ž, ๊ธฐํ˜ธ, ์ด๋ชจ์ง€๋ฅผ ํฌํ•จํ•ด์„œ ๊ธ€์ž์ˆ˜ ์ œํ•œ์ด ์žˆ์—ˆ๊ณ , ๋‹น์—ฐํžˆ ์ง๊ด€์ ์œผ๋กœ ์ด๋ชจ์ง€ ํ•˜๋‚˜๋Š” ํ•œ ๊ธ€์ž ์•„๋‹ˆ๊ฒ ์Šต๋‹ˆ๊นŒ. ๋„ˆ๋ฌด๋‚˜ ์‰ฝ๊ฒŒ ์ƒ๊ฐํ•˜๊ณ  ๊ธฐํš๋Œ€๋กœ ์ž‘์—…ํ–ˆ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๋Š”๋ฐ, ํ…Œ์ŠคํŠธ๋ฅผ ํ•ด๋ณด๋‹ˆ ์ด๋ชจ์ง€๋ฅผ ๊ธ€์ž ํ•˜๋‚˜ ์ด์ƒ์œผ๋กœ ์„ธ๋”๊ตฐ์š”.๐Ÿ˜ณ ๋Œ€๊ฐœ ์ œ๊ฐ€ ํ…Œ์ŠคํŠธํ–ˆ๋˜ ์ด๋ชจ์ง€๋“ค์€ ํ•œ ์ด๋ชจ์ง€๋‹น 2๊ธ€์ž ์ •๋„๋กœ ์ธ์‹ํ–ˆ์Šต๋‹ˆ๋‹ค. iOS์—์„œ๋Š” ์ด๋ชจ์ง€ ํ•˜๋‚˜๋ฅผ ํ•œ ๊ธ€์ž๋กœ ์ธ์‹ํ•ด์„œ ์ด๊ฒƒ๊ณผ ๊ด€๋ จํ•ด ๋ฌธ์ œ๊ฐ€ ์—†์ด ์‰ฝ๊ฒŒ ๊ฐ€๋Š”๋ฐ, ์•ˆ๋“œ๋กœ์ด๋“œ๋Š” ๊ทธ๋ ‡์ง€ ๋ชปํ•ด์„œ ์†์œผ๋กœ ํˆดํˆด๊ฑฐ๋ฆฌ๊ณ ๐Ÿคจ๐Ÿคจ์™œ ๊ทธ๋Ÿฐ์ง€,..
[Android ์‚ฝ์งˆ ๊ตํ›ˆ] RecyclerView์— RxJava๋Š” ์“ฐ์ง€ ๋ง์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋ฆฌ์‚ฌ์ดํด๋Ÿฌ๋ทฐ์˜ ๋ฆฌ์ŠคํŠธ ์•„์ดํ…œ์— ์—ฐ์†๋˜๋Š” ํด๋ฆญ ์ด๋ฒคํŠธ๋ฅผ ๋ง‰๊ณ ์ž RxJava์˜ throttleFirst๋ฅผ ํ™œ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค. (์ €๋Š” ์ด ์ž‘์—…์ด RxJava์˜ ์‘์šฉ์— ์ œ๊ฐ€ ํ•œ ๋ฐœ์ง ๋” ๋‚˜์•„๊ฐ”๋‹ค๋Š” ์ƒ๊ฐ์— ์‚ฌ๋ฌด์‹ค์—์„œ ๋‚ด์  ๊ธฐ์จ์„ ๋ˆ„๋ ธ์–ด์š”.) ๋ฉ”๋ชจ๋ฆฌ ๋ˆ„์ˆ˜๋„ ์žŠ์ง€ ๋ง๊ณ  ๋ง‰์•„์•ผ์ง€๐Ÿ˜‰ ์ด๋Ÿฌ๊ณ  RecyclerView์—์„œ RxJava์˜ dispose๋ฅผ ์ง„ํ–‰ํ•  ์ ๋‹นํ•œ ์ฝœ๋ฐฑ ํ•จ์ˆ˜๊ฐ€ ์žˆ๋‚˜ ๊ตฌ๊ธ€์—๊ฒŒ ๋ฌผ์–ด๋ดค์Šต๋‹ˆ๋‹ค. StackOverFlow์—์„œ ์–ด๋Œ‘ํ„ฐ ์•ˆ์˜ onViewDetachedFromWindow๋ฅผ ์ด์šฉํ•˜๋ฉด ๋œ๋‹ค๋Š” ๊ธ€์„ ํ™•์ธํ–ˆ๊ตฌ์š”. ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ฝ”๋“œ๋ฅผ ์งฐ์–ด์š”. override fun onViewDetachedFromWindow(holder: RecyclerView.ViewHolder) { if (holder is ViewHolder) {..