[Android] Fix drag&drop reordering regression
Geoffrey Métais
git at videolan.org
Thu Mar 12 09:39:38 CET 2020
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Mar 11 17:48:49 2020 +0100| [06249db4f82d27482fe971aee1838400f620770e] | committer: Nicolas Pomepuy
Fix drag&drop reordering regression
Fix #1221
> https://code.videolan.org/videolan/vlc-android/commit/06249db4f82d27482fe971aee1838400f620770e
---
.../src/org/videolan/vlc/gui/audio/PlaylistAdapter.kt | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.kt
index b41a24766..179ee2b5c 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.kt
@@ -61,6 +61,9 @@ import org.videolan.vlc.util.MediaItemDiffCallback
import org.videolan.vlc.viewmodels.PlaylistModel
import java.util.*
+private const val ACTION_MOVE = 0
+private const val ACTION_MOVED = 1
+
@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
class PlaylistAdapter(private val player: IPlayer) : DiffUtilAdapter<MediaWrapper, PlaylistAdapter.ViewHolder>(), SwipeDragHelperAdapter {
@@ -164,7 +167,7 @@ class PlaylistAdapter(private val player: IPlayer) : DiffUtilAdapter<MediaWrappe
override fun onItemMove(fromPosition: Int, toPosition: Int) {
Collections.swap(dataset, fromPosition, toPosition)
notifyItemMoved(fromPosition, toPosition)
- mHandler.obtainMessage(PlaylistHandler.ACTION_MOVE, fromPosition, toPosition).sendToTarget()
+ mHandler.obtainMessage(ACTION_MOVE, fromPosition, toPosition).sendToTarget()
}
override fun onItemMoved(dragFrom: Int, dragTo: Int) {
@@ -227,7 +230,6 @@ class PlaylistAdapter(private val player: IPlayer) : DiffUtilAdapter<MediaWrappe
}
ACTION_MOVED -> {
val model = owner?.model ?: return
- if (from != -1 && to != -1) return
if (to > from) ++to
model.move(from, to)
to = -1
@@ -235,12 +237,6 @@ class PlaylistAdapter(private val player: IPlayer) : DiffUtilAdapter<MediaWrappe
}
}
}
-
- companion object {
-
- const val ACTION_MOVE = 0
- const val ACTION_MOVED = 1
- }
}
override fun createCB(): DiffCallback<MediaWrapper> = MediaItemDiffCallback()
More information about the Android
mailing list