This commit is contained in:
Horis 2024-08-27 16:51:59 +08:00
parent 233a6f01b2
commit 85e10a72a9
2 changed files with 3 additions and 4 deletions

View File

@ -86,8 +86,8 @@ class ItemTouchCallback(private val callback: Callback) : ItemTouchHelper.Callba
srcViewHolder: RecyclerView.ViewHolder,
targetViewHolder: RecyclerView.ViewHolder
): Boolean {
val fromPosition: Int = srcViewHolder.adapterPosition
val toPosition: Int = targetViewHolder.adapterPosition
val fromPosition: Int = srcViewHolder.bindingAdapterPosition
val toPosition: Int = targetViewHolder.bindingAdapterPosition
if (fromPosition < toPosition) {
for (i in fromPosition until toPosition) {
callback.swap(i, i + 1)
@ -101,7 +101,7 @@ class ItemTouchCallback(private val callback: Callback) : ItemTouchHelper.Callba
}
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
callback.onSwiped(viewHolder.adapterPosition)
callback.onSwiped(viewHolder.bindingAdapterPosition)
}
override fun onSelectedChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) {

View File

@ -22,7 +22,6 @@ android.enableJetifier=false
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
kotlin.incremental.useClasspathSnapshot=true
kotlin.experimental.tryK2=true
android.enableResourceOptimizations=true
# android.enableNewResourceShrinker' is deprecated.
# It was removed in version 8.0 of the Android Gradle plugin.