본문 바로가기
반응형

Android36

FragmentResult 상황은 이렇다. FragmentA에서 어떤 리스트를 보여주고 있다. 그리고 그 리스트에서 한 아이템을 클릭하면 그 아이템에 대한 상세 설명을 보여주는 FragmentB를 보여준다. FragmentB에서 그 아이템을 삭제한다는 액션을 선택하고 FragmentB가 닫히고 FragmentA가 나타난다. FragmentA로 돌아왔을 때 삭제한 항목없이 리스트가 보여진다. 위와 같은 상황을 처리할때 데이터는 ViewModel을 사용하여 처리하면된다. 하지만 UI이 그리는데 어려움이 있었다. 지우고 돌아 왔을 때 FragmentA가 따로 반응하지 않기 때문이다. (만일 onResume을 강제로 불러주었으면 반응 했을지도 모른다... ) 아무튼 이럴때 사용하는 방법이 FragmentResult API이다. 이 API.. 2021. 12. 5.
IllegalArgumentException :cannot add the same observer with different lifecycles & viewLifecycleOwner 참고 https://uchun.dev/caution-when-using-a-fragment-viewLifecycleOwner/ Fragment 에서 ViewLifecycleOwner 사용 시 주의점 시작하기에 앞서 uchun.dev Android 개발을 하다가 다음과 같은 exception Log를 보게 되었습니다. java.lang.IllegalArgumentException: Cannot add the same observer with different lifecycles 발생한 이유는 LiveData의 Observer가 다른 owner에 포함이 되어 있다면 , LiveData는 위의 exception을 반환합니다. 즉, 하나의 activity에 있는 viewModel의 LiveData를 가져다 사용.. 2021. 12. 5.
Corutine callbackFlow sendBlocking Deprecated 코루틴의 callbackFlow 에서 sendBlocking 이 Deprecated가 되었다. 그럼 어떻게 써야하는가? trySendBlocking 로 변경해서 사용하면 된다. 그럼 무슨 차이가 있을까? 코드에 적혀있는 설명을 보면 trySendBlocking은 Adds element into to this channel, blocking the caller while this channel is full, and returning either successful result when the element was added, or failed result representing closed channel with a corresponding exception. This is a way to call Ch.. 2021. 12. 5.
A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction Android 에서 사용하는 라이브러리들의 버전을 높이다가 위와 같은 error를 보게 되었습니다. 제가 해결한 방법은 버전을 다 최신으로 바꾼다. annotationProcessor → kapt 로 바꾼다. layout에 있는 android:addTextChangeListener 가 사라졌으니 BindingAdapter에 추가해준다. @BindingAdapter("addTextChangedListener") fun addTextChangeListener(editText: EditText, textWatcher: TextWatcher){ editText.addTextChangedListener(textWatcher) } Impl class에 있는 @Single을 지우고 Module 에있는 Activity.. 2021. 12. 5.
반응형