Esempio n. 1
0
        public bool OnDrag(View view, DragEvent dragEvent)
        {
            if (dragEvent.GetLocalState() is SpeechDragData)
            {
                if (((SpeechDragData)dragEvent.GetLocalState()).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.GetAction())
            {
            case DragEvent.ACTION_DRAG_STARTED:
                //view.SetAlpha(0.3f);
                inDrag = true;
                break;

            case DragEvent.ACTION_DRAG_ENDED:
                //view.SetAlpha(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);
        }
Esempio n. 2
0
        public bool OnDrag(View view, DragEvent dragEvent)
        {
            bool result = true;

            MoveDragData dragData = null;

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

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

            case DragEvent.ACTION_DRAG_ENTERED:

                view.SetBackgroundColor(view.GetContext().GetResources().GetColor(R.Colors.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.GetContext().GetResources().GetColor(R.Colors.light_blue));
                //if (anim != null)
                //{
                //  anim.End();
                //  anim = null;
                //}
                break;

            case DragEvent.ACTION_DROP:
                view.SetBackgroundColor(view.GetContext().GetResources().GetColor(R.Colors.light_blue));
                //if (anim != null)
                //{
                //  anim.End();
                //  anim = null;
                //}

                // Dropped, reassign View to ViewGroup
                var       dragedView = dragData.draggedView;
                ViewGroup owner      = (ViewGroup)dragedView.GetParent();
                owner.RemoveView(dragedView);
                //LinearLayout container = (LinearLayout)view;
                HorizontalFlowLayout container = (HorizontalFlowLayout)view;
                container.AddView(dragedView);
                dragedView.SetVisibility(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);
        }