mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-08-11 18:50:58 +00:00
Disable drag long press for search playlists.
This commit is contained in:
parent
48052b88db
commit
21c2ab21b2
2 changed files with 7 additions and 4 deletions
|
@ -10,10 +10,11 @@ class ItemMoveCallback : ItemTouchHelper.Callback {
|
||||||
var onRowMoved = Event2<Int, Int>();
|
var onRowMoved = Event2<Int, Int>();
|
||||||
var onRowSelected = Event1<ViewHolder>();
|
var onRowSelected = Event1<ViewHolder>();
|
||||||
var onRowClear = Event1<ViewHolder>();
|
var onRowClear = Event1<ViewHolder>();
|
||||||
|
var canEdit = true
|
||||||
|
|
||||||
constructor() : super() { }
|
constructor() : super() { }
|
||||||
|
|
||||||
override fun isLongPressDragEnabled(): Boolean { return true; }
|
override fun isLongPressDragEnabled(): Boolean { return canEdit; }
|
||||||
override fun isItemViewSwipeEnabled(): Boolean { return false; }
|
override fun isItemViewSwipeEnabled(): Boolean { return false; }
|
||||||
|
|
||||||
override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int {
|
override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int {
|
||||||
|
|
|
@ -26,6 +26,7 @@ class VideoListEditorView : FrameLayout {
|
||||||
val onVideoOptions = Event1<IPlatformVideo>();
|
val onVideoOptions = Event1<IPlatformVideo>();
|
||||||
val onVideoClicked = Event1<IPlatformVideo>();
|
val onVideoClicked = Event1<IPlatformVideo>();
|
||||||
val isEmpty get() = _videos.isEmpty();
|
val isEmpty get() = _videos.isEmpty();
|
||||||
|
val itemMoveCallback: ItemMoveCallback
|
||||||
|
|
||||||
constructor(context: Context, attrs: AttributeSet? = null) : super(context, attrs) {
|
constructor(context: Context, attrs: AttributeSet? = null) : super(context, attrs) {
|
||||||
val recyclerPlaylist = RecyclerView(context, attrs);
|
val recyclerPlaylist = RecyclerView(context, attrs);
|
||||||
|
@ -34,14 +35,14 @@ class VideoListEditorView : FrameLayout {
|
||||||
recyclerPlaylist.layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
recyclerPlaylist.layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
||||||
addView(recyclerPlaylist);
|
addView(recyclerPlaylist);
|
||||||
|
|
||||||
val callback = ItemMoveCallback();
|
itemMoveCallback = ItemMoveCallback();
|
||||||
val touchHelper = ItemTouchHelper(callback);
|
val touchHelper = ItemTouchHelper(itemMoveCallback);
|
||||||
val adapterVideos = VideoListEditorAdapter(touchHelper);
|
val adapterVideos = VideoListEditorAdapter(touchHelper);
|
||||||
recyclerPlaylist.adapter = adapterVideos;
|
recyclerPlaylist.adapter = adapterVideos;
|
||||||
recyclerPlaylist.layoutManager = LinearLayoutManager(context);
|
recyclerPlaylist.layoutManager = LinearLayoutManager(context);
|
||||||
touchHelper.attachToRecyclerView(recyclerPlaylist);
|
touchHelper.attachToRecyclerView(recyclerPlaylist);
|
||||||
|
|
||||||
callback.onRowMoved.subscribe { fromPosition, toPosition ->
|
itemMoveCallback.onRowMoved.subscribe { fromPosition, toPosition ->
|
||||||
synchronized(_videos) {
|
synchronized(_videos) {
|
||||||
if (fromPosition < toPosition) {
|
if (fromPosition < toPosition) {
|
||||||
for (i in fromPosition until toPosition)
|
for (i in fromPosition until toPosition)
|
||||||
|
@ -94,6 +95,7 @@ class VideoListEditorView : FrameLayout {
|
||||||
synchronized(_videos) {
|
synchronized(_videos) {
|
||||||
_videos.clear();
|
_videos.clear();
|
||||||
_videos.addAll(videos ?: listOf());
|
_videos.addAll(videos ?: listOf());
|
||||||
|
itemMoveCallback.canEdit = canEdit
|
||||||
_adapterVideos?.setVideos(_videos, canEdit);
|
_adapterVideos?.setVideos(_videos, canEdit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue