public FlippingView(Context context, Listener listener, int width, int height) : base(context) { this.listener = listener; this.flipOutView = new ImageView(context); this.flipInView = new ImageView(context); AddView(flipOutView, width, height); AddView(flipInView, width, height); flipInView.Rotation = -90; ObjectAnimator flipOutAnimator = ObjectAnimator.OfFloat(flipOutView, "rotationY", 0, 90); flipOutAnimator.SetInterpolator(new AccelerateInterpolator()); Animator flipInAnimator = ObjectAnimator.OfFloat(flipInView, "rotationY", -90, 0); flipInAnimator.SetInterpolator(new DecelerateInterpolator()); animations = new AnimatorSet(); animations.PlaySequentially(flipOutAnimator, flipInAnimator); animations.SetDuration(1000); animations.AddListener(new AnimationListener() { AnimationEnd = (animation) => { flipOutView.Rotation = 0; flipInView.Rotation = -90; listener.onFlipped(this); } }); }
public void Animate(PathSegment segment) { lock (_lockObject) { if (!_animatorSet.IsRunning) { _pathSegment = segment; _animatorSet = new AnimatorSet(); _animatorSet.AddListener(this); var animators = new List <ObjectAnimator>(); foreach (var marker in _markers) { var positionAnimator = ObjectAnimator.OfObject( marker, "Position", new MarkerPositionEvaluator(), segment.FinalLocation.ToLatLng()); positionAnimator.AddListener(this); positionAnimator.AddUpdateListener(this); positionAnimator.SetDuration(Convert.ToInt64(segment.Duration.TotalMilliseconds)); animators.Add(positionAnimator); } _animatorSet.PlayTogether(animators.ToArray()); _animatorSet.Start(); } } }
/** * Close the menu; */ public void CloseMenu() { IsOpened = false; AnimatorSet scaleUp_activity = BuildScaleUpAnimation(viewActivity, 1.0f, 1.0f); AnimatorSet scaleUp_shadow = BuildScaleUpAnimation(imageViewShadow, 1.0f, 1.0f); AnimatorSet alpha_menu = BuildMenuAnimation(scrollViewMenu, 0.0f); scaleUp_activity.AddListener(animationListener); scaleUp_activity.PlayTogether(scaleUp_shadow); scaleUp_activity.PlayTogether(alpha_menu); scaleUp_activity.Start(); }
/** * Show the menu; */ public void OpenMenu(Direction direction) { SetScaleDirection(direction); IsOpened = true; AnimatorSet scaleDown_activity = BuildScaleDownAnimation(viewActivity, ScaleValueX, ScaleValueY); AnimatorSet scaleDown_shadow = BuildScaleDownAnimation(imageViewShadow, ScaleValueX + shadowAdjustScaleX, ScaleValueY + shadowAdjustScaleY); AnimatorSet alpha_menu = BuildMenuAnimation(scrollViewMenu, 1.0f); scaleDown_shadow.AddListener(animationListener); scaleDown_activity.PlayTogether(scaleDown_shadow); scaleDown_activity.PlayTogether(alpha_menu); scaleDown_activity.Start(); }
public virtual void Discard(int direction, Animator.IAnimatorListener al, int duration = 250) { var @as = new AnimatorSet(); var aCollection = new List <Animator>(); var topView = TopView; var topParams = (RelativeLayout.LayoutParams)topView.LayoutParameters; var layout = CardUtils.CloneParams(topParams); var discardAnim = ValueAnimator.OfObject(new RelativeLayoutParamsEvaluator(), layout, _mRemoteLayouts[direction]); discardAnim.Update += (sender, args) => { topView.LayoutParameters = (RelativeLayout.LayoutParams)args.Animation.AnimatedValue; }; discardAnim.SetDuration(duration); aCollection.Add(discardAnim); for (var i = 0; i < MCardCollection.Count; i++) { var v = MCardCollection[i]; if (v == topView) { continue; } var nv = MCardCollection[i + 1]; var layoutParams = (RelativeLayout.LayoutParams)v.LayoutParameters; var endLayout = CardUtils.CloneParams(layoutParams); RelativeLayout.LayoutParams viewParams; _mLayoutsMap.TryGetValue(nv, out viewParams); var layoutAnim = ValueAnimator.OfObject(new RelativeLayoutParamsEvaluator(), endLayout, viewParams); layoutAnim.SetDuration(duration); layoutAnim.Update += (sender, args) => { v.LayoutParameters = (RelativeLayout.LayoutParams)args.Animation.AnimatedValue; }; aCollection.Add(layoutAnim); } @as.AddListener(new DiscardAnimationEndListener(this, al)); @as.PlayTogether(aCollection); @as.Start(); }
private void buildAnimator() { var valueAnimator = ValueAnimator.OfFloat(0f, 1f); valueAnimator.SetDuration(ANIMATOR_DURATION); valueAnimator.RepeatCount = -1; valueAnimator.SetInterpolator(new LinearInterpolator()); valueAnimator.Update += (sender, e) => { mRotation = (float)valueAnimator.AnimatedValue; Invalidate(); }; animator = valueAnimator; animatorSet = buildFlexibleAnimation(); animatorSet.AddListener(animatorListener); }
private void BuildAnimator() { var valueAnimator = ValueAnimator.OfFloat(0f, 1f); valueAnimator.SetDuration(AnimatorDuration); valueAnimator.RepeatCount = -1; valueAnimator.SetInterpolator(new LinearInterpolator()); valueAnimator.Update += (sender, e) => { _rotation = (float)valueAnimator.AnimatedValue; Invalidate(); }; _animator = valueAnimator; _animatorSet = BuildFlexibleAnimation(); _animatorSet.AddListener(_animatorListener); }
public override bool AnimateAppearance(RecyclerView.ViewHolder viewHolder, ItemHolderInfo preLayoutInfo, ItemHolderInfo postLayoutInfo) { EnsureDiffResultIsSet(); var view = viewHolder.ItemView; var set = new AnimatorSet(); var scaleAnimator = ObjectAnimator.OfFloat(view, "scaleY", 1f); var translateAnimator = ObjectAnimator.OfFloat(view, "translationY", 0); view.TranslationY = -view.Height * _addedIndexes.FindIndex(0, x => x == ((IndexedItemHolderInfo)postLayoutInfo).Index); view.ScaleY = 0f; view.PivotY = 0; set.PlayTogether(scaleAnimator, translateAnimator); set.AddListener(new AnimatorListener(onEndAction: _ => DispatchAnimationFinished(viewHolder))); _pendingAnimators.Add(set); return(true); }
/** * Animates the pending {@link android.view.View} back to its original position. */ private void restoreCurrentViewTranslation() { if (mCurrentView == null) { return; } ObjectAnimator xAnimator = ObjectAnimator.OfFloat(mSwipingView, TRANSLATION_X, 0); ObjectAnimator alphaAnimator = ObjectAnimator.OfFloat(mSwipingView, ALPHA, 1); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.PlayTogether(xAnimator, alphaAnimator); animatorSet.SetDuration(mAnimationTime); animatorSet.AddListener(new RestoreAnimatorListener(mCurrentView, mCurrentPosition, this)); animatorSet.Start(); }
/** * Flings given {@link android.view.View} out of sight. * * @param view the parent {@link android.view.View}. * @param position the position of the item in the {@link android.widget.ListAdapter} corresponding to the {@code View}. * @param flingToRight {@code true} if the {@code View} should be flinged to the right, {@code false} if it should be flinged to the left. */ private void flingView(View view, int position, bool flingToRight) { if (mViewWidth < 2) { mViewWidth = mListViewWrapper.getListView().Width; } View swipeView = getSwipeView(view); ObjectAnimator xAnimator = ObjectAnimator.OfFloat(swipeView, TRANSLATION_X, flingToRight ? mViewWidth : -mViewWidth); ObjectAnimator alphaAnimator = ObjectAnimator.OfFloat(swipeView, ALPHA, 0); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.PlayTogether(xAnimator, alphaAnimator); animatorSet.SetDuration(mAnimationTime); animatorSet.AddListener(new FlingAnimatorListener(view, position, this)); animatorSet.Start(); }
protected void animateAllAssetsOff(AnimatorListenerAdapter adapter) { // title // 120dp + 50dp + buffer(30dp) ObjectAnimator titleAnimator = ObjectAnimator.OfFloat(mTitle, "translationY", GameUtility.Px(-200)); titleAnimator.SetInterpolator(new AccelerateInterpolator(2)); titleAnimator.SetDuration(300); // lights ObjectAnimator lightsAnimatorX = ObjectAnimator.OfFloat(mStartButtonLights, "scaleX", 0f); ObjectAnimator lightsAnimatorY = ObjectAnimator.OfFloat(mStartButtonLights, "scaleY", 0f); // tooltip ObjectAnimator tooltipAnimator = ObjectAnimator.OfFloat(mTooltip, "alpha", 0f); tooltipAnimator.SetDuration(100); // settings button ObjectAnimator settingsAnimator = ObjectAnimator.OfFloat(mSettingsGameButton, "translationY", GameUtility.Px(120)); settingsAnimator.SetInterpolator(new AccelerateInterpolator(2)); settingsAnimator.SetDuration(300); // google play button ObjectAnimator googlePlayAnimator = ObjectAnimator.OfFloat(mGooglePlayGameButton, "translationY", GameUtility.Px(120)); googlePlayAnimator.SetInterpolator(new AccelerateInterpolator(2)); googlePlayAnimator.SetDuration(300); // start button ObjectAnimator startButtonAnimator = ObjectAnimator.OfFloat(mStartGameButton, "translationY", GameUtility.Px(130)); startButtonAnimator.SetInterpolator(new AccelerateInterpolator(2)); startButtonAnimator.SetDuration(300); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.PlayTogether(titleAnimator, lightsAnimatorX, lightsAnimatorY, tooltipAnimator, settingsAnimator, googlePlayAnimator, startButtonAnimator); animatorSet.AddListener(adapter); animatorSet.Start(); }
//@Override //@NonNull public override View GetView(int position, View convertView, ViewGroup parent) { View view = base.GetView(position, convertView, parent); if (mInsertQueue.getActiveIndexes().Contains(position)) { int widthMeasureSpec = View.MeasureSpec.MakeMeasureSpec(ViewGroup.LayoutParams.MatchParent, MeasureSpecMode.AtMost); int heightMeasureSpec = View.MeasureSpec.MakeMeasureSpec(ViewGroup.LayoutParams.WrapContent, MeasureSpecMode.Unspecified); view.Measure(widthMeasureSpec, heightMeasureSpec); int originalHeight = view.MeasuredHeight; ValueAnimator heightAnimator = ValueAnimator.OfInt(1, originalHeight); heightAnimator.AddUpdateListener(new HeightUpdater(view)); Animator[] customAnimators = getAdditionalAnimators(view, parent); Animator[] animators = new Animator[customAnimators.Length + 1]; animators[0] = heightAnimator; //System.arraycopy(customAnimators, 0, animators, 1, customAnimators.length); Array.Copy(customAnimators, 0, animators, 1, customAnimators.Length); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.PlayTogether(animators); //ViewHelper.setAlpha(view, 0); view.Alpha = 0; ObjectAnimator alphaAnimator = ObjectAnimator.OfFloat(view, ALPHA, 0, 1); AnimatorSet allAnimatorsSet = new AnimatorSet(); allAnimatorsSet.PlaySequentially(animatorSet, alphaAnimator); allAnimatorsSet.SetDuration(mInsertionAnimationDurationMs); allAnimatorsSet.AddListener(new ExpandAnimationListener(this, position)); allAnimatorsSet.Start(); } return(view); }
public void shift(View view) { if (!mShifted) { foreach (ImageView imageView in mImageViews) { ObjectAnimator tx = ObjectAnimator.OfFloat(imageView, View.X, (mRandom.NextFloat() - 0.5f) * 500); tx.AddUpdateListener(new AnimListener(mBlurringView)); ObjectAnimator ty = ObjectAnimator.OfFloat(imageView, View.Y, (mRandom.NextFloat() - 0.5f) * 500); ty.AddUpdateListener(new AnimListener(mBlurringView)); AnimatorSet set = new AnimatorSet(); set.PlayTogether(tx, ty); set.SetDuration(3000); set.SetInterpolator(new OvershootInterpolator()); set.AddListener(new AnimationEndListener(imageView)); set.Start(); } ; mShifted = true; } else { foreach (ImageView imageView in mImageViews) { ObjectAnimator tx = ObjectAnimator.OfFloat(imageView, View.X, 0); tx.AddUpdateListener(new AnimListener(mBlurringView)); ObjectAnimator ty = ObjectAnimator.OfFloat(imageView, View.Y, 0); ty.AddUpdateListener(new AnimListener(mBlurringView)); AnimatorSet set = new AnimatorSet(); set.PlayTogether(tx, ty); set.SetDuration(3000); set.SetInterpolator(new OvershootInterpolator()); set.AddListener(new AnimationEndListener(imageView)); set.Start(); } ; mShifted = false; } }
protected AnimatorSet createBGAnimatorSet(Android.Graphics.Color color) { View bgColorView = new ImageView(mAppContext); bgColorView.LayoutParameters = new RelativeLayout.LayoutParams(mRootLayout.Width, mRootLayout.Height); bgColorView.SetBackgroundColor(color); mBackgroundContainer.AddView(bgColorView); int[] pos = calculateCurrentCenterCoordinatesOfPagerElement(mActiveElementIndex); float finalRadius = mRootLayout.Width > mRootLayout.Height ? mRootLayout.Width : mRootLayout.Height; AnimatorSet bgAnimSet = new AnimatorSet(); Animator fadeIn = ObjectAnimator.OfFloat(bgColorView, "alpha", 0, 1); if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { Animator circularReveal = ViewAnimationUtils.CreateCircularReveal(bgColorView, pos[0], pos[1], 0, finalRadius); circularReveal.SetInterpolator(new AccelerateInterpolator()); bgAnimSet.PlayTogether(circularReveal, fadeIn); } else { bgAnimSet.PlayTogether(fadeIn); } bgAnimSet.SetDuration(ANIM_BACKGROUND_TIME); var endListener = new AnimatorEndListener(); endListener.OnEndAnimation += () => { mRootLayout.SetBackgroundColor(color); bgColorView.Visibility = ViewStates.Gone; mBackgroundContainer.RemoveView(bgColorView); }; bgAnimSet.AddListener(endListener); return(bgAnimSet); }
/** * Performs the undo animation and restores the original state for given {@link android.view.View}. * * @param view the parent {@code View} which contains both primary and undo {@code View}s. */ public void undo(View view) { int position = AdapterViewUtil.getPositionForView(getListViewWrapper(), view); mUndoPositions.Remove(position); View primaryView = mCallback.getPrimaryView(view); View undoView = mCallback.getUndoView(view); primaryView.Visibility = ViewStates.Visible; ObjectAnimator undoAlphaAnimator = ObjectAnimator.OfFloat(undoView, ALPHA, 1f, 0f); ObjectAnimator primaryAlphaAnimator = ObjectAnimator.OfFloat(primaryView, ALPHA, 0f, 1f); ObjectAnimator primaryXAnimator = ObjectAnimator.OfFloat(primaryView, TRANSLATION_X, primaryView.Width, 0f); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.PlayTogether(undoAlphaAnimator, primaryAlphaAnimator, primaryXAnimator); animatorSet.AddListener(new UndoAnimatorListener(undoView, this)); animatorSet.Start(); mCallback.onUndo(view, position); }
public BaseViewAnimator addAnimatorListener(Animator.IAnimatorListener l) { mAnimatorSet.AddListener(l); return(this); }
private void ZoomImageFromThumb(View thumbView, int imageResId) { var expandedImageView = FindViewById <ImageView>(Resource.Id.expanded_image); expandedImageView.SetImageResource(imageResId); var startBounds = new Rect(); var finalBounds = new Rect(); var globalOffset = new Point(); thumbView.GetGlobalVisibleRect(startBounds); FindViewById(Resource.Id.container).GetGlobalVisibleRect(finalBounds, globalOffset); startBounds.Offset(-globalOffset.X, -globalOffset.Y); finalBounds.Offset(-globalOffset.X, -globalOffset.Y); float startScale; if (((float)finalBounds.Width() / finalBounds.Height()) .CompareTo((float)startBounds.Width() / startBounds.Height()) < 0) { startScale = (float)startBounds.Height() / finalBounds.Height(); var startWidth = startScale * finalBounds.Width(); var deltaWidth = (startWidth - startBounds.Width()) / 2; startBounds.Left -= (int)deltaWidth; startBounds.Right += (int)deltaWidth; } else { startScale = (float)startBounds.Width() / finalBounds.Width(); var startHeight = startScale * finalBounds.Height(); var deltaHeight = (startHeight - startBounds.Height()) / 2; startBounds.Top -= (int)deltaHeight; startBounds.Bottom += (int)deltaHeight; } thumbView.Alpha = 0f; expandedImageView.Visibility = ViewStates.Visible; expandedImageView.PivotX = 0f; expandedImageView.PivotY = 0f; var set = new AnimatorSet(); set.Play(ObjectAnimator.OfFloat(expandedImageView, View.X, startBounds.Left, finalBounds.Left)) .With(ObjectAnimator.OfFloat(expandedImageView, View.Y, startBounds.Top, finalBounds.Top)) .With(ObjectAnimator.OfFloat(expandedImageView, View.ScaleXs, startScale, 1f)) .With(ObjectAnimator.OfFloat(expandedImageView, View.ScaleYs, startScale, 1f)); set.SetDuration(_shortAnimationDuration); set.SetInterpolator(new DecelerateInterpolator()); set.AddListener(new AnimatorListener(this)); set.Start(); _currentAnimator = set; expandedImageView.Click += (s, e) => { if (_currentAnimator != null) { _currentAnimator.Cancel(); } var animSet = new AnimatorSet(); animSet.Play(ObjectAnimator.OfFloat(expandedImageView, View.X, startBounds.Left)) .With(ObjectAnimator.OfFloat(expandedImageView, View.Y, startBounds.Top)) .With(ObjectAnimator.OfFloat(expandedImageView, View.ScaleXs, startScale)) .With(ObjectAnimator.OfFloat(expandedImageView, View.ScaleYs, startScale)); animSet.SetDuration(_shortAnimationDuration); animSet.SetInterpolator(new DecelerateInterpolator()); animSet.AnimationEnd += (sender, args) => { thumbView.Alpha = 1f; expandedImageView.Visibility = ViewStates.Gone; _currentAnimator = null; }; animSet.AnimationCancel += (sender, args) => { thumbView.Alpha = 1f; expandedImageView.Visibility = ViewStates.Gone; _currentAnimator = null; }; }; }