@@ -78,13 +78,9 @@ class ChecklistAdapter(
78
78
79
79
override fun getItemKeyPosition (key : Int ) = items.indexOfFirst { it.id == key }
80
80
81
- override fun onActionModeCreated () {
82
- notifyDataSetChanged()
83
- }
81
+ override fun onActionModeCreated () {}
84
82
85
- override fun onActionModeDestroyed () {
86
- notifyDataSetChanged()
87
- }
83
+ override fun onActionModeDestroyed () {}
88
84
89
85
override fun prepareActionMode (menu : Menu ) {
90
86
val selectedItems = getSelectedItems()
@@ -161,27 +157,35 @@ class ChecklistAdapter(
161
157
162
158
private fun moveSelectedItemsToTop () {
163
159
activity.config.sorting = SORT_BY_CUSTOM
160
+ val movedPositions = mutableListOf<Int >()
164
161
selectedKeys.reversed().forEach { checklistId ->
165
162
val position = items.indexOfFirst { it.id == checklistId }
166
163
val tempItem = items[position]
167
164
items.removeAt(position)
165
+ movedPositions.add(position)
168
166
items.add(0 , tempItem)
169
167
}
170
168
171
- notifyDataSetChanged()
169
+ movedPositions.forEach {
170
+ notifyItemMoved(it, 0 )
171
+ }
172
172
listener?.saveChecklist()
173
173
}
174
174
175
175
private fun moveSelectedItemsToBottom () {
176
176
activity.config.sorting = SORT_BY_CUSTOM
177
+ val movedPositions = mutableListOf<Int >()
177
178
selectedKeys.forEach { checklistId ->
178
179
val position = items.indexOfFirst { it.id == checklistId }
179
180
val tempItem = items[position]
180
181
items.removeAt(position)
182
+ movedPositions.add(position)
181
183
items.add(items.size, tempItem)
182
184
}
183
185
184
- notifyDataSetChanged()
186
+ movedPositions.forEach {
187
+ notifyItemMoved(it, items.size - 1 )
188
+ }
185
189
listener?.saveChecklist()
186
190
}
187
191
0 commit comments