Esempio n. 1
0
            public override void OnSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState)
            {
                base.OnSelectedChanged(viewHolder, actionState);

                if (actionState == ItemTouchHelper.ActionStateDrag)
                {
                    _horizontalList.IsDragAndDropping = true;
                    if (((ViewHolder)viewHolder).ViewCell is DraggableViewCell draggableViewCell)
                    {
                        // System.Diagnostics.Debug.WriteLine($">>>>> OnSelectedChanged( {draggableViewCell.BindingContext} IsDragAndDropping: true )");
                        draggableViewCell.IsDragAndDropping = true;
                        _draggedViewCell = draggableViewCell;
                    }
                }
                else if (actionState == ItemTouchHelper.ActionStateIdle)
                {
                    _horizontalList.IsDragAndDropping = false;
                    if (_draggedViewCell != null)
                    {
                        // System.Diagnostics.Debug.WriteLine($">>>>> OnSelectedChanged( {_draggedViewCell.BindingContext} IsDragAndDropping: false )");
                        _draggedViewCell.IsDragAndDropping = false;
                        _draggedViewCell = null;
                    }
                }
            }
            public override void OnSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState)
            {
                base.OnSelectedChanged(viewHolder, actionState);

                if (actionState == ItemTouchHelper.ActionStateDrag)
                {
                    _collection.IsDragAndDropping = true;
                    if (_collection.IsInPullToRefresh() && _collection.Parent is ContentView refreshView)
                    {
                        _isRefreshViewUserEnabled = refreshView.IsEnabled;
                        refreshView.IsEnabled     = false;
                    }

                    if (((ViewHolder)viewHolder).ViewCell is DraggableViewCell draggableViewCell)
                    {
                        // System.Diagnostics.Debug.WriteLine($">>>>> OnSelectedChanged( {draggableViewCell.BindingContext} IsDragAndDropping: true )");
                        draggableViewCell.IsDragAndDropping = true;
                        _draggedViewCell = draggableViewCell;
                    }

                    _onDragAndDropStart?.Execute(new DragAndDropInfo(
                                                     viewHolder.AdapterPosition,
                                                     -1,
                                                     ((ViewHolder)viewHolder).BindingContext));
                }
                else if (actionState == ItemTouchHelper.ActionStateIdle)
                {
                    _collection.IsDragAndDropping = false;
                    if (_collection.IsInPullToRefresh() && _collection.Parent is ContentView refreshView && _isRefreshViewUserEnabled)
                    {
                        refreshView.IsEnabled = true;
                    }

                    if (_draggedViewCell != null)
                    {
                        // System.Diagnostics.Debug.WriteLine($">>>>> OnSelectedChanged( {_draggedViewCell.BindingContext} IsDragAndDropping: false )");
                        _draggedViewCell.IsDragAndDropping = false;
                        _draggedViewCell = null;
                    }
                }
            }