示例#1
0
    public bool OnDrag(View view, DragEvent dragEvent)
    {
      if (dragEvent.LocalState is SpeechDragData)
      {
        if (((SpeechDragData)dragEvent.LocalState).dragHandler != this)
        {
          // Not this object
          return false;
        }
      }
      else
      {
        if (Successor != null)
        {
          if (Successor is View.IOnDragListener)
          {
            return (Successor as View.IOnDragListener).OnDrag(view, dragEvent);
          }
        }
      }

      bool result = true;

      switch (dragEvent.Action)
      {
        case DragEvent.ACTION_DRAG_STARTED:
          //view.Alpha = (0.3f);
          inDrag = true;
          break;
        case DragEvent.ACTION_DRAG_ENDED:
          //view.Alpha = (1.00f);
          inDrag = false;
          break;
        case DragEvent.ACTION_DRAG_EXITED:
          inDrag = false;
          break;
        case DragEvent.ACTION_DROP:
          break;
        case DragEvent.ACTION_DRAG_LOCATION:
          break;
        default:
          break;
      }

      return result;
    }
示例#2
0
    public bool OnDrag(View view, DragEvent dragEvent)
    {
      bool result = true;

      MoveDragData dragData = null;
      if (dragEvent.LocalState is MoveDragData)
      {
        dragData = dragEvent.LocalState as MoveDragData;
      }
      else
      {
        if (Successor is View.IOnDragListener)
        {
          return (Successor as View.IOnDragListener).OnDrag(view, dragEvent);
        }
      }

      switch (dragEvent.Action)
      {
        case DragEvent.ACTION_DRAG_STARTED:
          break;
        case DragEvent.ACTION_DRAG_ENTERED:

          view.SetBackgroundColor(view.Context.Resources.GetColor(R.Color.accent_blue));
          //float[] single = { 1.0F, 0.5F };
          //anim = ObjectAnimator.OfFloat((Object)view, "alpha", single);
          //anim.SetInterpolator(new CycleInterpolator(40));
          //anim.SetDuration(30 * 1000); // 30 seconds
          //anim.Start();
          break;
        case DragEvent.ACTION_DRAG_ENDED:
        case DragEvent.ACTION_DRAG_EXITED:
          view.SetBackgroundColor(view.Context.Resources.GetColor(R.Color.light_blue));
          //if (anim != null)
          //{
          //  anim.End();
          //  anim = null;
          //}
          break;
        case DragEvent.ACTION_DROP:
          view.SetBackgroundColor(view.Context.Resources.GetColor(R.Color.light_blue));
          //if (anim != null)
          //{
          //  anim.End();
          //  anim = null;
          //}

          // Dropped, reassign View to ViewGroup
          var dragedView = dragData.draggedView;
          ViewGroup owner = (ViewGroup)dragedView.Parent;
          owner.RemoveView(dragedView);
          //LinearLayout container = (LinearLayout)view;
          HorizontalFlowLayout container = (HorizontalFlowLayout)view;
          container.AddView(dragedView);
          dragedView.Visibility = (View.VISIBLE);

          // Inform all listeners
          OnMoveDropAccepted(dragData.dragHandler.CurrentContainer, Id, (dragData as MoveDragData).dragHandler.CheckerData);
          // Set as currentContainer
          dragData.dragHandler.CurrentContainer = Id;

          break;
        case DragEvent.ACTION_DRAG_LOCATION:
          break;
        default:
          break;
      }

      return result;
    }
示例#3
0
        public bool OnDrag(AViews.View view, AViews.DragEvent e)
        {
            switch (e.Action)
            {
            case AViews.DragAction.Started:
                break;

            case AViews.DragAction.Entered:
                System.Diagnostics.Debug.WriteLine($"DragAction.Entered from {view.GetType()}");

                if (!(view is AWidget.ListView))
                {
                    var dragItem = (DragItem)e.LocalState;

                    var targetPosition = InsertOntoView(view, dragItem);

                    dragItem.Index = targetPosition;

                    // Keep a list of items that has translation so we can reset
                    // them once the drag'n'drop is finished.
                    translatedItems.Add(view);
                    listView.Invalidate();
                }
                break;

            case AViews.DragAction.Location:
                break;

            case AViews.DragAction.Exited:
                System.Diagnostics.Debug.WriteLine($"DragAction.Entered from {view.GetType()}");

                if (!(view is AWidget.ListView))
                {
                    var positionEntered = GetListPositionForView(view);

                    System.Diagnostics.Debug.WriteLine($"DragAction.Exited index {positionEntered}");
                }
                break;

            case AViews.DragAction.Drop:
                System.Diagnostics.Debug.WriteLine($"DragAction.Drop from {view.GetType()}");
                break;

            case AViews.DragAction.Ended:
                System.Diagnostics.Debug.WriteLine($"DragAction.Ended from {view.GetType()}");

                if (!(view is AWidget.ListView))
                {
                    return(false);
                }

                var mobileItem = (DragItem)e.LocalState;

                mobileItem.View.Visibility = AViews.ViewStates.Visible;

                foreach (var v in translatedItems)
                {
                    v.TranslationY = 0;
                }

                translatedItems.Clear();

                if (element.ItemsSource is IOrderableCollection orderable)
                {
                    orderable.ChangeOrder(mobileItem.OriginalIndex, mobileItem.Index);
                }

                break;
            }

            return(true);
        }