Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- 알고리즘
- onLayout
- sqlite
- HTTP
- View
- onMeasure
- LiveData
- 안드로이드
- activity
- 백준
- BOJ
- CustomView
- 코틀린
- Algorithm
- AppBarLayout
- 알림
- recyclerview
- CollapsingToolbarLayout
- hilt
- ViewModel
- Behavior
- DataBinding
- kotlin
- notification
- Navigation
- CoordinatorLayout
- room
- Android
- lifecycle
- Coroutine
Archives
- Today
- Total
개발일지
Android in A..Z - RecyclerView (AdapterDataObserver) 본문
Android (안드로이드)/RecyclerView
Android in A..Z - RecyclerView (AdapterDataObserver)
강태종 2021. 1. 10. 17:34AdapterDataObserver
RecyclerView.Adapter에서 notifyItem~ 함수를 사용할 때 콜백을 받을 수 있는 Observer이다.
private val adapterDataObserver = object : RecyclerView.AdapterDataObserver() {
override fun onChanged() {
super.onChanged()
Log.d("PASS", "onChanged")
}
override fun onItemRangeChanged(positionStart: Int, itemCount: Int) {
super.onItemRangeChanged(positionStart, itemCount)
Log.d("PASS", "onItemRangeChanged START: $positionStart, COUNT : $itemCount")
}
override fun onItemRangeInserted(positionStart: Int, itemCount: Int) {
super.onItemRangeInserted(positionStart, itemCount)
Log.d("PASS", "onItemRangeInserted POS : $positionStart, COUNT : $itemCount")
}
override fun onItemRangeMoved(fromPosition: Int, toPosition: Int, itemCount: Int) {
super.onItemRangeMoved(fromPosition, toPosition, itemCount)
Log.d("PASS", "onItemRangeMoved FROM : $fromPosition, TO : $toPosition, COUNT : $itemCount")
}
override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) {
super.onItemRangeRemoved(positionStart, itemCount)
Log.d("PASS", "onItemRangeRemoved POS : $positionStart, COUNT : $itemCount")
}
}
ToDoAdapter
private val adapter by lazy { ToDoAdapter().apply { registerAdapterDataObserver(adapterDataObserver) } }
Git (예제코드)
github.com/KangTaeJong98/Example/tree/main/Android/RecyclerView
'Android (안드로이드) > RecyclerView' 카테고리의 다른 글
Android in A..Z - RecyclerView (setHasStableIds) (0) | 2021.01.10 |
---|---|
Android in A..Z - RecyclerView (ItemDecoration) (0) | 2021.01.10 |
Android in A..Z - Recyclerview (ItemTouchHelper) (0) | 2021.01.10 |
Android in A..Z - RecyclerView (Layout Manager) (0) | 2021.01.10 |
Android in A..Z - RecyclerView (기본) (0) | 2021.01.10 |
Comments