Exemplo n.º 1
0
        private List <View> CreateSortContainers(Context context, Text2Speech tts)
        {
            var result = new List <View>();

            var l = new HorizontalFlowLayout(context);

            l.SetBackgroundColor(context.GetResources().GetColor(R.Colors.light_blue));
            var p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1);

            //var p = new RelativeLayout.MarginLayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
            p.SetMargins(7, 7, 7, 0);
            l.SetLayoutParams(p);
            var d = new MoveDropHandler {
                Id = "1"
            };

            d.OnMoveDropAccepted += sortObjects.ResultChecker.DropHandler;
            l.SetOnDragListener(d);
            result.Add(l);

            l = new HorizontalFlowLayout(context);
            l.SetBackgroundColor(context.GetResources().GetColor(R.Colors.light_blue));
            p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1);
            //p = new RelativeLayout.MarginLayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
            p.SetMargins(7, 7, 7, 7);
            l.SetLayoutParams(p);
            d = new MoveDropHandler {
                Id = "2"
            };
            d.OnMoveDropAccepted += sortObjects.ResultChecker.DropHandler;
            l.SetOnDragListener(d);
            result.Add(l);
            return(result);
        }
Exemplo n.º 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);
        }