Beispiel #1
0
 public void OnFlick(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
 {
     // sanity check, as the events could be null.
     if (e1 != null && e2 != null)
     {
         // if they flicked it, go ahead and open / close the springboard.
         // to know they intended to flick and not scroll, ensure X is > Y
         if (Math.Abs(velocityX) > Math.Abs(velocityY))
         {
             // only allow it if we're NOT animating, the task is ok with us panning, and we're in portrait mode.
             if (Animating == false &&
                 ActiveTask.CanContainerPan( ) &&
                 Activity.Resources.Configuration.Orientation == Android.Content.Res.Orientation.Portrait)
             {
                 if (velocityX > sMinVelocity)
                 {
                     RevealSpringboard(true);
                 }
                 else if (velocityX < -sMinVelocity)
                 {
                     RevealSpringboard(false);
                 }
             }
         }
     }
 }
Beispiel #2
0
        public void OnScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
        {
            // sanity check, as the events could be null.
            if (e1 != null && e2 != null)
            {
                // only allow it if we're NOT animating, the task is ok with us panning, and we're in portrait mode.
                if (Animating == false &&
                    ActiveTask.CanContainerPan( ) &&
                    Activity.Resources.Configuration.Orientation == Android.Content.Res.Orientation.Portrait)
                {
                    switch (Panning)
                    {
                    case PanState.Monitoring:
                    {
                        TotalPanY += Math.Abs(e2.RawY - e1.RawY);
                        TotalPanX += Math.Abs(e2.RawX - e1.RawX);

                        FrameCount++;

                        if (FrameCount > sNumPanTrackingFrames)
                        {
                            // decide how to proceed
                            Panning = PanState.None;

                            // put simply, if their total X was more than their total Y, well then,
                            // lets pan.
                            if (TotalPanX > TotalPanY)
                            {
                                Panning = PanState.Panning;

                                // mark where the panning began, so we can move the field appropriately
                                PanStartX = e2.RawX;

                                PanelOriginX = View.GetX( );
                            }
                            else
                            {
                                // Y was greater than X, so they probably intended to scroll, not pan.
                                Panning = PanState.None;
                            }
                        }
                        break;
                    }

                    case PanState.Panning:
                    {
                        distanceX = e2.RawX - PanStartX;

                        float xPos         = PanelOriginX + distanceX;
                        float revealAmount = Springboard.GetSpringboardDisplayWidth( );
                        xPos = Math.Max(0, Math.Min(xPos, revealAmount));

                        PanContainerViews(xPos);
                        break;
                    }
                    }
                }
            }
        }