public void roll(Android.Widget.NumberPicker picker, int scrollX, int scrollY, long actionTime)
        {
            // Execute dummy touch to scroll specified length
            long      now          = SystemClock.UptimeMillis();
            int       touchX       = picker.Width / 2;
            int       scrollStartY = (picker.Height - scrollY) / 2;
            int       scrollEndY   = scrollStartY + scrollY;
            const int metaState    = 0;

            MotionEvent e = MotionEvent.Obtain(
                now,
                now + actionTime / 2,
                MotionEventActions.Down,
                touchX,
                scrollStartY,
                metaState);

            picker.DispatchTouchEvent(e);

            Android.Util.Log.Error("Motion", scrollStartY.ToString());

            e = MotionEvent.Obtain(
                now + actionTime / 2,
                now + actionTime,
                MotionEventActions.Move,
                touchX,
                scrollEndY,
                metaState);
            picker.DispatchTouchEvent(e);

            e.Action = MotionEventActions.Up;
            picker.DispatchTouchEvent(e);

            Android.Util.Log.Error("Motion", scrollEndY.ToString());
        }
Example #2
0
        void CreateDialog()
        {
            if (_TextPickerCell.Items == null || _TextPickerCell.Items.Count == 0)
            {
                return;
            }

            var displayValues = _TextPickerCell.Items.Cast <object>().Select(x => x.ToString()).ToArray();

            _picker = new APicker(_context);
            _picker.DescendantFocusability = DescendantFocusability.BlockDescendants;
            _picker.MinValue = 0;
            _picker.MaxValue = _TextPickerCell.Items.Count - 1;
            _picker.SetDisplayedValues(displayValues);
            _picker.Value             = Math.Max(_TextPickerCell.Items.IndexOf(_TextPickerCell.SelectedItem), 0);
            _picker.WrapSelectorWheel = _TextPickerCell.IsCircularPicker;

            if (_dialog == null)
            {
                using (var builder = new AlertDialog.Builder(_context)) {
                    builder.SetTitle(_title);

                    Android.Widget.FrameLayout parent = new Android.Widget.FrameLayout(_context);
                    parent.AddView(_picker, new Android.Widget.FrameLayout.LayoutParams(
                                       ViewGroup.LayoutParams.WrapContent,
                                       ViewGroup.LayoutParams.WrapContent,
                                       GravityFlags.Center));
                    builder.SetView(parent);


                    builder.SetNegativeButton(global::Android.Resource.String.Cancel, (o, args) => {
                        ClearFocus();
                    });
                    builder.SetPositiveButton(global::Android.Resource.String.Ok, (o, args) => {
                        _TextPickerCell.SelectedItem = _TextPickerCell.Items[_picker.Value];
                        _command?.Execute(_TextPickerCell.Items[_picker.Value]);
                        ClearFocus();
                    });

                    _dialog = builder.Create();
                }
                _dialog.SetCanceledOnTouchOutside(true);
                _dialog.DismissEvent += (ss, ee) => {
                    _dialog.Dispose();
                    _dialog = null;
                    _picker.RemoveFromParent();
                    _picker.Dispose();
                    _picker = null;
                };

                _dialog.Show();
            }
        }
Example #3
0
 /// <summary>
 /// Dispose the specified disposing.
 /// </summary>
 /// <returns>The dispose.</returns>
 /// <param name="disposing">If set to <c>true</c> disposing.</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         _picker?.Dispose();
         _picker = null;
         _dialog?.Dispose();
         _dialog  = null;
         _context = null;
         _command = null;
     }
     base.Dispose(disposing);
 }
Example #4
0
 public VotesPage(string nomination, string group, int minValue, int maxValue)
 {
     InitializeComponent();
     nominationLabel.Text = nomination;
     groupLabel.Text      = group;
     numberPicker         = new Android.Widget.NumberPicker(Android.App.Application.Context)
     {
         MinValue = minValue,
         MaxValue = maxValue,
         Value    = maxValue
     };
     gridNumberPicker.Children.Add(numberPicker);
 }
Example #5
0
 void DestroyDialog()
 {
     if (_dialog != null)
     {
         // Set _dialog to null to avoid racing attempts to destroy dialog - e.g. in response to dismiss event
         var dialog = _dialog;
         _dialog = null;
         _picker.RemoveFromParent();
         _picker.Dispose();
         _picker = null;
         // Dialog.Dispose() does not close an open dialog view so explicitly dismiss it before disposing
         dialog.Dismiss();
         dialog.Dispose();
     }
 }
Example #6
0
        void CreateDialog()
        {
            _picker          = new APicker(_context);
            _picker.MinValue = _min;
            _picker.MaxValue = _max;
            _picker.Value    = _NumberPikcerCell.Number;

            if (_dialog == null)
            {
                using (var builder = new AlertDialog.Builder(_context)) {
                    builder.SetTitle(_title);

                    Android.Widget.FrameLayout parent = new Android.Widget.FrameLayout(_context);
                    parent.AddView(_picker, new Android.Widget.FrameLayout.LayoutParams(
                                       ViewGroup.LayoutParams.WrapContent,
                                       ViewGroup.LayoutParams.WrapContent,
                                       GravityFlags.Center));
                    builder.SetView(parent);


                    builder.SetNegativeButton(global::Android.Resource.String.Cancel, (o, args) =>
                    {
                        ClearFocus();
                    });
                    builder.SetPositiveButton(global::Android.Resource.String.Ok, (o, args) =>
                    {
                        _NumberPikcerCell.Number = _picker.Value;
                        _command?.Execute(_picker.Value);
                        ClearFocus();
                    });

                    _dialog = builder.Create();
                }
                _dialog.SetCanceledOnTouchOutside(true);
                _dialog.DismissEvent += (ss, ee) =>
                {
                    _dialog.Dispose();
                    _dialog = null;
                    _picker.RemoveFromParent();
                    _picker.Dispose();
                    _picker = null;
                };

                _dialog.Show();
            }
        }
Example #7
0
        void CreateDialog()
        {
            if (_dialog != null)
            {
                return;
            }

            var picker = new APicker(_view.Context);

            picker.MinValue = _min;
            picker.MaxValue = _max;
            picker.Value    = _number;

            using (var builder = new AlertDialog.Builder(_view.Context)) {
                builder.SetTitle(AddNumberPicker.GetTitle(Element));

                Android.Widget.FrameLayout parent = new Android.Widget.FrameLayout(_view.Context);
                parent.AddView(picker, new Android.Widget.FrameLayout.LayoutParams(
                                   ViewGroup.LayoutParams.WrapContent,
                                   ViewGroup.LayoutParams.WrapContent,
                                   GravityFlags.Center));
                builder.SetView(parent);

                builder.SetNegativeButton(global::Android.Resource.String.Cancel, (o, args) => { });

                builder.SetPositiveButton(global::Android.Resource.String.Ok, (o, args) => {
                    AddNumberPicker.SetNumber(Element, picker.Value);
                    _command?.Execute(picker.Value);
                });

                _dialog = builder.Create();
            }

            _dialog.SetCanceledOnTouchOutside(true);

            _dialog.DismissEvent += (ss, ee) => {
                _dialog.Dispose();
                _dialog = null;
                picker.RemoveFromParent();
                picker.Dispose();
                picker = null;
            };

            _dialog.Show();
        }
 public void stop(Android.Widget.NumberPicker picker, long elapsedTime)
 {
     // Nothing to do
 }