// // 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; }
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; }