본문 바로가기

빈 구멍 채우기

(342)
[프로그래밍] 주석 쓰기 팁 https://stackoverflow.blog/2021/07/05/best-practices-for-writing-code-comments/ Best practices for writing code comments - Stack Overflow Blog While there are many resources to help programmers write better code—such as books and static analyzers—there are few for writing better comments. While it's easy to measure the quantity of comments in a program, it's hard to measure the quality, and t st..
[Kotlin Coroutine] launch 안 hot flow와 suspend function 사용 / launch 안에서 api 호출 누락 launch안에 paging3의 adapter의 loadStateFlow를 따라 ui 및 에러처리를 하고, viewModel에서 api를 호출해 pager로 데이터를 flow로 가져오도록 했었다. 그런데 flow가 호출되지 않는 것을 이제야 확인했다. 문제의 코드 launch{ adapter.loadStateFlow.collectLatest { state -> when(state.refresh) { is LoadState.NotLoading -> { ... } is LoadState.Error -> { ... } else -> Unit } } // { ... } is LoadState.Error -> { ... } else -> Unit } } //이 로그는 호출되지 않는다. Log.d("Test", "..
[삽질][Android Studio]새 프로젝트 빌드 실패. / navigation.json (지정된 경로를 찾을 수 없습니다) 새 프로젝트 생성 시 항상 빌드 실패로 무언가 해보기 전에 낭패감을 맛보다가 이제야 방법을 찾았아. 로그 > Task :app:processDebugMainManifest FAILED Execution failed for task ':app:processDebugMainManifest'. > com.android.manifmerger.ManifestMerger2$MergeFailureException: java.io.FileNotFoundException: C:\경로\프로젝트명\app\build\intermediates\navigation_json\debug\navigation.json (������ ��θ� ã�� �� �����ϴ�) C:\경로\프로젝트명\app\build\intermediates\n..
[Kotlin] 폴더 지우기 폴더와 하위 파일까지 지우기 fun delete(directoryPath : String) { val dir = File(directoryPath) dir.deleteRecursively() } File.deleteRecursively()의 내부 코드를 살펴보았다. /** * Delete this file with all its children. * Note that if this operation fails then partial deletion may have taken place. * * @return `true` if the file or directory is successfully deleted, `false` otherwise. */ public fun File.deleteRecursivel..
[RxJava] io.reactivex.exceptions.OnErrorNotImplementedException 이슈를 확인했다. Fatal Exception: io.reactivex.exceptions.OnErrorNotImplementedException The exception was not handled due to missing onError handler in the subscribe() method call. Further reading: https://github.com/ReactiveX/RxJava/wiki/Error-Handling ReactiveX/RxJava RxJava – Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences f..
[Kotlin] Repository에서는 LiveData 보다는 Flow 가 적합하다. betterprogramming.pub/no-more-livedata-in-repositories-in-kotlin-85f5a234a8fe No More LiveData in Repositories in Kotlin Learn how to replace LiveData with Kotlin Flow betterprogramming.pub LiveData는 수명주기를 인식한다.(lifecycle-aware) LiveData의 주 목적은 data의 집합을 observe하는 것이다. 이 observe는 메인 쓰레드에서만 이뤄진다. Flow는 비동기적으로 연산들을 수행하고 필요할 때마다 여러번 값을 내보내도록 아예 설계되었다. channel과 다르게 cold stream이기 때문에 collect되어야지만 flo..
[Kotlin Coroutine] Flow - 1 kotlinlang.org/docs/flow.html#sequences Asynchronous Flow - Help | Kotlin kotlinlang.org Asynchronous Flow suspending 함수는 비동기적으로 하나의 값을 반환합니다. 비동기적으로 계산된 여러 값들을 어떻게 반환할 수 있을까요? Kotlin Flows는 여기서 등장합니다. 여러 값들을 표시하기 여러 값들은 Kotlin에서 collection을 이용해서 표현될 수 있습니다. 예를 들어서, simple() 함수는 세 개의 숫자들의 List를 반환하고 forEach를 이용해서 모든 숫자들을 출력합니다. fun simple(): List = listOf(1, 2, 3) fun main() { simple().forEach {..
[Kotlin Coroutines] Job kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-job/index.html Job - kotlinx-coroutines-core Job A background job. Conceptually, a job is a cancellable thing with a life-cycle that culminates in its completion. Jobs can be arranged into parent-child hierarchies where cancellation of a parent leads to immediate cancellation of all its children recu kotlin.github.io..