Пример #1
0
        private ITimeInterpolator GetAndroidInterpolator(
            EasingFunction ease)
        {
            ITimeInterpolator androidEase = null;

            if (null != ease)
            {
                var cubicEase   = ease as CubicEase;
                var elasticEase = ease as SpringEase;

                if (null != cubicEase)
                {
                    if (ease.EasingMode == EasingMode.EaseIn)
                    {
                        androidEase = new AccelerateInterpolator(1.5f);
                    }
                    else if (ease.EasingMode == EasingMode.EaseOut)
                    {
                        androidEase = new DecelerateInterpolator(1.5f);
                    }
                    else if (ease.EasingMode == EasingMode.EaseInOut)
                    {
                        // TODO: A custom interpolator. This is actually a circular ease, not a cubic ease-in-out
                        androidEase = new AccelerateDecelerateInterpolator();
                    }
                    else
                    {
                        throw new NotSupportedException("Unsupported easing mode.");
                    }
                }
                else if (null != elasticEase)
                {
                    // TODO: Custom interpolators
                    if (ease.EasingMode == EasingMode.EaseIn)
                    {
                        androidEase = new BounceInterpolator();
                    }
                    else if (ease.EasingMode == EasingMode.EaseOut)
                    {
                        androidEase = new BounceInterpolator();
                    }
                    else if (ease.EasingMode == EasingMode.EaseInOut)
                    {
                        androidEase = new BounceInterpolator();
                    }
                    else
                    {
                        throw new NotSupportedException("Unsupported easing mode.");
                    }
                }
                else
                {
                    throw new NotSupportedException("Unsupported easing function.");
                }
            }

            return(androidEase);
        }
 /// <summary>
 /// Initializes the recycler view.
 /// </summary>
 private void Init()
 {
     SetLayoutManager(new LinearLayoutManager(Context));
     touchState        = ETouchState.None;
     viewConfig        = ViewConfiguration.Get(Context);
     openInterpolator  = new BounceInterpolator();
     closeInterpolator = new BounceInterpolator();
     swipeDirection    = EDirection.Left;
     swipingEnabled    = true;
 }
Пример #3
0
        //
        // Marker related listeners.
        //

        public bool OnMarkerClick(Marker marker)
        {
            // This causes the marker at Perth to bounce into position when it is clicked.
            if (marker.Equals(mPerth))
            {
                Handler    handler    = new Handler();
                long       start      = SystemClock.UptimeMillis();
                Projection proj       = mMap.Projection;
                Point      startPoint = proj.ToScreenLocation(PERTH);
                startPoint.Offset(0, -100);
                LatLng startLatLng = proj.FromScreenLocation(startPoint);
                long   duration    = 1500;

                IInterpolator interpolator = new BounceInterpolator();

                Runnable run = null;
                run = new Runnable(delegate {
                    long elapsed    = SystemClock.UptimeMillis() - start;
                    float t         = interpolator.GetInterpolation((float)elapsed / duration);
                    double lng      = t * PERTH.Longitude + (1 - t) * startLatLng.Longitude;
                    double lat      = t * PERTH.Latitude + (1 - t) * startLatLng.Latitude;
                    marker.Position = (new LatLng(lat, lng));

                    if (t < 1.0)
                    {
                        // Post again 16ms later.
                        handler.PostDelayed(run, 16);
                    }
                });
                handler.Post(run);
            }
            // We return false to indicate that we have not consumed the event and that we wish
            // for the default behavior to occur (which is for the camera to move such that the
            // marker is centered and for the marker's info window to open, if it has one).
            return(false);
        }
Пример #4
0
        private void AnimateTopLayer(float percent, bool force = false)
        {
            if (!canAnimate)
            {
                return;
            }

            if (height <= 0)
            {
                height = (float)topLayer.MeasuredHeight;
                if (height <= 0)
                {
                    return;
                }
            }

            canAnimate = false;

            var           start = animation == null ? -height : lastY;
            var           time  = 300;
            IInterpolator interpolator;


            if (percent < 0)
            {
                percent = 0;
            }
            else if (percent > 100)
            {
                percent = 100;
            }

            lastY = -height * (percent / 100F);

            if ((int)lastY == (int)start && !force)
            {
                canAnimate = true;
                return;
            }

            //is new so do bound, else linear
            if (fullAnimation || !Utils.IsSameDay)
            {
                interpolator  = new BounceInterpolator();
                time          = 3000;
                fullAnimation = false;
            }
            else
            {
                interpolator = new LinearInterpolator();
            }
            animation = new TranslateAnimation(Dimension.Absolute, 0,
                                               Dimension.Absolute, 0,
                                               Dimension.Absolute, start,
                                               Dimension.Absolute, lastY);
            animation.Duration = time;


            animation.Interpolator  = interpolator;
            animation.AnimationEnd += (object sender, Animation.AnimationEndEventArgs e) => {
                canAnimate = true;
            };

            animation.FillAfter = true;
            topLayer.StartAnimation(animation);
            if (topLayer.Visibility != Android.Views.ViewStates.Visible)
            {
                topLayer.Visibility = Android.Views.ViewStates.Visible;
            }
        }