public void animateCarMove1(Marker SecondMarker, LatLng beginLatLng1, LatLng endLatLng1, float duration1) { long startTime1 = SystemClock.UptimeMillis(); Android.Views.Animations.IInterpolator interpolator = new Android.Views.Animations.LinearInterpolator(); float angleDeg1 = (float)(180 * getAngle(beginLatLng1, endLatLng1) / System.Math.PI); //float angleDeg = (float)(180 * getBearing(beginLatLng, endLatLng) / System.Math.PI); Matrix matrix1 = new Matrix(); matrix1.PostRotate(angleDeg1); SecondMarker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.black1)); // marker.SetIcon(BitmapDescriptorFactory.FromBitmap(Bitmap.CreateBitmap(mMarkerIcon, 0, 0, mMarkerIcon.Width, mMarkerIcon.Height, matrix, true))); handler1 = new Handler(); action2 = () => { // your code that you want to delay here long elapsed1 = SystemClock.UptimeMillis() - startTime1; float t1 = interpolator.GetInterpolation((float)elapsed1 / duration1); // calculate new position for marker double lat1 = (endLatLng1.Latitude - beginLatLng1.Latitude) * t1 + beginLatLng1.Latitude; double lngDelta1 = endLatLng1.Longitude - beginLatLng1.Longitude; if (System.Math.Abs(lngDelta1) > 180) { lngDelta1 -= System.Math.Sign(lngDelta1) * 360; } double lng1 = lngDelta1 * t1 + beginLatLng1.Longitude; SecondMarker.Position = new LatLng(lat1, lng1); if (t1 < 1.0) { handler1.PostDelayed(action2, 1); } else { nextTurnAnimation1(); } }; handler1.Post(action2); }
public void animateCarMove(Marker marker, LatLng beginLatLng, LatLng endLatLng, float duration) { long startTime = SystemClock.UptimeMillis(); Android.Views.Animations.IInterpolator interpolator = new Android.Views.Animations.LinearInterpolator(); float angleDeg = (float)(180 * getAngle(beginLatLng, endLatLng) / System.Math.PI); Matrix matrix = new Matrix(); matrix.PostRotate(angleDeg); marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.black1)); // marker.SetIcon(BitmapDescriptorFactory.FromBitmap(Bitmap.CreateBitmap(mMarkerIcon, 0, 0, mMarkerIcon.Width, mMarkerIcon.Height, matrix, true))); handler = new Handler(); action1 = () => { long elapsed = SystemClock.UptimeMillis() - startTime; float t = interpolator.GetInterpolation((float)elapsed / duration); // calculate new position for marker double lat = (endLatLng.Latitude - beginLatLng.Latitude) * t + beginLatLng.Latitude; double lngDelta = endLatLng.Longitude - beginLatLng.Longitude; if (System.Math.Abs(lngDelta) > 180) { lngDelta -= System.Math.Sign(lngDelta) * 360; } double lng = lngDelta * t + beginLatLng.Longitude; marker.Position = new LatLng(lat, lng); if (t < 1.0) { handler.PostDelayed(action1, 13); } else { nextTurnAnimation(); } }; handler.Post(action1); }
public void animateCarTurn1(Marker marker1, float startAngle1, float endAngle1, float duration1) { Handler handler1 = new Handler(); long startTime1 = SystemClock.UptimeMillis(); Android.Views.Animations.IInterpolator interpolator1 = new Android.Views.Animations.LinearInterpolator(); float dAndgle1 = endAngle1 - startAngle1; Matrix matrix1 = new Matrix(); matrix1.PostRotate(startAngle1); Bitmap rotatedBitmap1 = Bitmap.CreateBitmap(mMarkerIcon1, 0, 0, mMarkerIcon1.Width, mMarkerIcon1.Height, matrix1, true); //marker.SetIcon(BitmapDescriptorFactory.FromBitmap(rotatedBitmap)); marker1.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.black1)); Handler h1 = new Handler(); myAction2 = () => { long elapsed1 = SystemClock.UptimeMillis() - startTime1; float t1 = interpolator1.GetInterpolation((float)elapsed1 / duration1); Matrix m1 = new Matrix(); m1.PostRotate(startAngle1 + dAndgle1 * t1); // marker.SetIcon(BitmapDescriptorFactory.FromBitmap(Bitmap.CreateBitmap(mMarkerIcon, 0, 0, mMarkerIcon.Width, mMarkerIcon.Height, m, true))); marker1.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.black1)); if (t1 < 1.0) { h1.PostDelayed(myAction2, 500); } else { nextMoveAnimation1(); } }; h1.Post(myAction2); }
public void animateCarTurn(Marker marker, float startAngle, float endAngle, float duration) { Handler handler = new Handler(); long startTime = SystemClock.UptimeMillis(); Android.Views.Animations.IInterpolator interpolator = new Android.Views.Animations.LinearInterpolator(); float dAndgle = endAngle - startAngle; Matrix matrix = new Matrix(); matrix.PostRotate(startAngle); Bitmap rotatedBitmap = Bitmap.CreateBitmap(mMarkerIcon, 0, 0, mMarkerIcon.Width, mMarkerIcon.Height, matrix, true); //marker.SetIcon(BitmapDescriptorFactory.FromBitmap(rotatedBitmap)); marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.red2)); Handler h = new Handler(); myAction1 = () => { long elapsed = SystemClock.UptimeMillis() - startTime; float t = interpolator.GetInterpolation((float)elapsed / duration); Matrix m = new Matrix(); m.PostRotate(startAngle + dAndgle * t); // marker.SetIcon(BitmapDescriptorFactory.FromBitmap(Bitmap.CreateBitmap(mMarkerIcon, 0, 0, mMarkerIcon.Width, mMarkerIcon.Height, m, true))); marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.red2)); if (t < 1.0) { h.PostDelayed(myAction1, 1000); } else { nextMoveAnimation(); } }; h.Post(myAction1); }
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; }
private void SetValues() { _progressBar.SmoothProgressDrawableSpeed = _speed; _progressBar.SmoothProgressDrawableSectionsCount = _sectionsCount; _progressBar.SmoothProgressDrawableSeparatorLength = DpToPx(_separatorLength); _progressBar.SmoothProgressDrawableStrokeWidth = DpToPx(_strokeWidth); _progressBar.SmoothProgressDrawableReversed = _checkBoxReversed.Checked; _progressBar.SmoothProgressDrawableMirrorMode = _checkBoxMirror.Checked; IInterpolator interpolator; switch (_spinnerInterpolators.SelectedItemPosition) { case 1: interpolator = new LinearInterpolator(); break; case 2: interpolator = new AccelerateDecelerateInterpolator(); break; case 3: interpolator = new DecelerateInterpolator(); break; default: interpolator = new AccelerateInterpolator(); break; } _progressBar.SmoothProgressDrawableInterpolator = interpolator; _progressBar.SmoothProgressDrawableColors = IntsToColors(Resources.GetIntArray(Resource.Array.colors)); }
void SetInterpolator(int position) { IInterpolator CurrentInterpolator; switch (position) { case 1: CurrentInterpolator = new LinearInterpolator(); _seekBarFactor.Enabled=false; break; case 2: CurrentInterpolator = new AccelerateDecelerateInterpolator(); _seekBarFactor.Enabled=false; break; case 3: CurrentInterpolator = new DecelerateInterpolator(_factor); _seekBarFactor.Enabled=true; break; case 0: default: CurrentInterpolator = new AccelerateInterpolator(_factor); _seekBarFactor.Enabled=true; break; } _progressBar.SetSmoothProgressDrawableInterpolator(CurrentInterpolator); _progressBar.SetSmoothProgressDrawableColors(Resources.GetIntArray(Resource.Array.gplus_colors)); }
public IndicatorLayout(Context context, Mode mode) :base(context) { //super(context); mArrowImageView = new ImageView(context); Drawable arrowD =Resources.GetDrawable(Resource.Drawable.indicator_arrow); mArrowImageView.SetImageDrawable(arrowD); int padding = Resources.GetDimensionPixelSize(Resource.Dimension.indicator_internal_padding); mArrowImageView.SetPadding(padding, padding, padding, padding); AddView(mArrowImageView); int inAnimResId, outAnimResId; switch (mode) { case Mode.PULL_FROM_END: inAnimResId = Resource.Animation.slide_in_from_bottom; outAnimResId = Resource.Animation.slide_out_to_bottom; SetBackgroundResource(Resource.Drawable.indicator_bg_bottom); // Rotate Arrow so it's pointing the correct way mArrowImageView.SetScaleType(Android.Widget.ImageView.ScaleType.Matrix); Matrix matrix = new Matrix(); matrix.SetRotate(180f, arrowD.IntrinsicWidth/ 2f, arrowD.IntrinsicHeight/ 2f); mArrowImageView.ImageMatrix=matrix; break; default: case Mode.PULL_FROM_START: inAnimResId = Resource.Animation.slide_in_from_top; outAnimResId = Resource.Animation.slide_out_to_top; SetBackgroundResource(Resource.Drawable.indicator_bg_top); break; } mInAnim = AnimationUtils.LoadAnimation(context, inAnimResId); mInAnim.SetAnimationListener(this); mOutAnim = AnimationUtils.LoadAnimation(context, outAnimResId); mOutAnim.SetAnimationListener(this); IInterpolator interpolator = new LinearInterpolator(); //mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f); mRotateAnimation = new RotateAnimation(0, -180, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f); mRotateAnimation.Interpolator=interpolator; mRotateAnimation.Duration=DEFAULT_ROTATION_ANIMATION_DURATION; mRotateAnimation.FillAfter=true; mResetRotateAnimation = new RotateAnimation(-180, 0, Dimension.RelativeToSelf, 0.5f, Dimension.RelativeToSelf, 0.5f); mResetRotateAnimation.Interpolator=interpolator; mResetRotateAnimation.Duration=DEFAULT_ROTATION_ANIMATION_DURATION; mResetRotateAnimation.FillAfter=true; }