
리사이클러뷰를 사용할 때 성능향상을 위해 DiffUtil을 이용할 것이다. 그런데, DiffUtil을 사용하면서 주의해야할 중의 하나는 ArrayList나 var 멤버가 포함된 mutable한 데이터 타입을 사용하는 것이다. 결론적으로 말하면, 이런 데이터 타입을 사용할 경우 데이터를 변경했음 해도 불구하고 리사이클러뷰가 업데이트 되지 않게 되는 현상에 직면하게 된다. 관련 코드를 통해 해당 증상을 살펴보자. 아래와 같이 ListAdapter를 이용해 사용자를 추가하는 간단한 앱이 있다. Add를 누르면 사용자를 리사이클러뷰에 추가할 것이다. 레이아웃과 관련코드이다. class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanc..
I have read about Liskov Substitute Principle(LSP, https://en.wikipedia.org/wiki/Liskov_substitution_principle) few times and tried to understand correctly but it's clear sometimes but ambiguous other times. I confess it's not still 100 clear. I might need to revisit when I have a problem. We can easily find long discussions about LSP(https://stackoverflow.com/questions/56860/what-is-an-example-..
It's cleaner and easier to handle not to throw Exception often in Kotlin. Particulary when we call Http call, we are like to use Coroutines. Coroutine has complicating cancellation and exception handling mechanism and it might not work well in caese if you use the same apporach to Java by throwing Exceptoin. Coroutine propagates Cancellation Exception to top most coroutine context and this makes..