mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2026-05-16 04:52:39 +02:00
Merge branch 'master' of gitlab.futo.org:videostreaming/grayjay
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user