public void ToggleVisibleTitles() { // Use these for custom animations. FragmentManager fm = FragmentManager; TitlesFragment f = (TitlesFragment)fm.FindFragmentById(Resource.Id.frag_title); View titlesView = f.View; mLabelIndex = 1 - mLabelIndex; // Determine if we're in portrait, and whether we're showing or hiding the titles // with this toggle. bool isPortrait = Resources.Configuration.Orientation == Android.Content.Res.Orientation.Portrait; bool shouldShow = f.IsHidden || mCurrentTitlesAnimator != null; // Cancel the current titles animation if there is one. if (mCurrentTitlesAnimator != null) { mCurrentTitlesAnimator.Cancel(); } // Begin setting up the object animator. We'll animate the bottom or right edge of the // titles view, as well as its alpha for a fade effect. ObjectAnimator objectAnimator = ObjectAnimator.OfPropertyValuesHolder( titlesView, PropertyValuesHolder.OfInt( isPortrait ? "bottom" : "right", shouldShow ? Resources.GetDimensionPixelSize(Resource.Dimension.titles_size) : 0), PropertyValuesHolder.OfFloat("alpha", shouldShow ? 1 : 0) ); // At each step of the animation, we'll perform layout by calling setLayoutParams. ViewGroup.LayoutParams lp = titlesView.LayoutParameters; objectAnimator.AddUpdateListener(new AnimatorUpdateListener(isPortrait, titlesView, lp)); if (shouldShow) { fm.BeginTransaction().Show(f).Commit(); objectAnimator.AddListener(new ObjectAnimatorListenerAdapter(this)); } else { objectAnimator.AddListener(new ObjectAnimatorListenerAdapter2(this, fm, f)); } // Start the animation. objectAnimator.Start(); mCurrentTitlesAnimator = objectAnimator; InvalidateOptionsMenu(); // Manually trigger onNewIntent to check for ACTION_DIALOG. OnNewIntent(Intent); }
private void HandleViewSwipingOut(View child, float deltaX, float deltaY) { ObjectAnimator animator = mAnimators.GetSwipeOutAnimator(child, deltaX, deltaY); if (animator != null) { animator.AddListener(new AnimatorListener() { OnAnimationEndAction = (Animator animation) => { RemoveView(child); NotifyOnDismissEvent(child); } }); } else { RemoveView(child); NotifyOnDismissEvent(child); } if (animator != null) { animator.SetTarget(child); animator.Start(); } }
private void HandleViewSwipingIn(View child, float deltaX, float deltaY) { ObjectAnimator animator = mAnimators.GetSwipeInAnimator(child, deltaX, deltaY); if (animator != null) { animator.AddListener(new AnimatorListener() { OnAnimationEndAction = (Animator animation) => { child.TranslationX = 0f; child.TranslationY = 0f; } }); } else { child.TranslationX = 0f; child.TranslationY = 0f; } if (animator != null) { animator.SetTarget(child); animator.Start(); } }
/** * Resets all the appropriate fields to a default state while also animating * the hover cell back to its correct location. */ void touchEventsEnded() { touchEventsEndedMobileView = getViewForID(mMobileItemId); if (mCellIsMobile || mIsWaitingForScrollFinish) { mCellIsMobile = false; mIsWaitingForScrollFinish = false; mIsMobileScrolling = false; mActivePointerId = INVALID_POINTER_ID; // If the autoscroller has not completed scrolling, we need to wait for it to // finish in order to determine the final location of where the hover cell // should be animated to. if (mScrollState != 0) //OnScrollListener.SCROLL_STATE_IDLE) { { mIsWaitingForScrollFinish = true; return; } mHoverCellCurrentBounds.OffsetTo(mHoverCellOriginalBounds.Left, touchEventsEndedMobileView.Top); ObjectAnimator hoverViewAnimator = ObjectAnimator.OfObject(mHoverCell, "bounds", this, mHoverCellCurrentBounds); hoverViewAnimator.AddUpdateListener(this); hoverViewAnimator.AddListener(new MyAnimatorListenerAdapter(this)); hoverViewAnimator.Start(); } }
public ExpandHelper(Context context, Callback callback, int small, int large) { this.smallSize = small; this.maximumStretch = Math.Max(smallSize, 1) * StretchInterval; this.largeSize = large; this.context = context; this.callback = callback; this.scaler = new ViewScaler(); this.gravity = GravityFlags.Top; //this.scaleAnimation = ObjectAnimator.OfFloat (scaler, "Height", 0f); this.scaleAnimation = ValueAnimator.OfFloat(0f); this.scaleAnimation.Update += (sender, e) => scaler.Height = (float)e.Animation.AnimatedValue; this.scaleAnimation.SetDuration(ExpandDuration); AnimatorListenerAdapter glowVisibilityController = new AnimatorListener(); glowTopAnimation = ObjectAnimator.OfFloat(null, "alpha", 0f); glowTopAnimation.AddListener(glowVisibilityController); glowBottomAnimation = ObjectAnimator.OfFloat(null, "alpha", 0f); glowBottomAnimation.AddListener(glowVisibilityController); glowAnimationSet = new AnimatorSet(); glowAnimationSet.Play(glowTopAnimation).With(glowBottomAnimation); glowAnimationSet.SetDuration(GlowDuration); detector = new DoubleSwipeDetector(context, new GestureDetector(this)); }
void Animate(LibraryHoloCircularProgressBar.HoloCircularProgressBar progressBar, Android.Animation.Animator.IAnimatorListener listener, float progress, int duration) { _progressBarAnimator = ObjectAnimator.OfFloat(progressBar, "progress", progress); _progressBarAnimator.SetDuration(duration); progressBar1 = progressBar; progress1 = progress; _progressBarAnimator.AddListener(this); if (listener != null) { _progressBarAnimator.AddListener(listener); } _progressBarAnimator.Reverse(); _progressBarAnimator.AddUpdateListener(this); progressBar.SetMarkerProgress(progress); _progressBarAnimator.Start(); }
private void hideBubble() { if (currentBubbleAnimator != null) { currentBubbleAnimator.Cancel(); } currentBubbleAnimator = (ObjectAnimator)ObjectAnimator.OfFloat(bubble, "alpha", 1f, 0f).SetDuration(ANIMATION_DURATION); currentBubbleAnimator.AddListener(new BubbleAnimationEndListener(this)); currentBubbleAnimator.Start(); }
public AnimatedViewPortJob(ViewPortHandler viewPortHandler, float xValue, float yValue, Transformer trans, IChartBase v, float xOrigin, float yOrigin, long duration) : base(viewPortHandler, xValue, yValue, trans, v) { this.xOrigin = xOrigin; this.yOrigin = yOrigin; animator = ObjectAnimator.OfFloat(this, "phase", 0f, 1f); animator.SetDuration(duration); animator.AddUpdateListener(this); animator.AddListener(this); }
public ProgressBarIndeterminateDeterminate(Context context, IAttributeSet attrs) : base(context, attrs) { Post(() => { Progress = 60; ViewHelper.SetX(progressView, Width + progressView.Width / 2); animation = ObjectAnimator.OfFloat(progressView, "x", -progressView.Width / 2); animation.SetDuration(1200); animation.AddListener(new MyAnimatorListener(this)); animation.Start(); }); }
public virtual void OnAnimationEnd(Animator arg0) { // Repeat animation ViewHelper.SetX(progress.progressView, -progress.progressView.Width / 2); cont += suma; ObjectAnimator anim2Repeat = ObjectAnimator.OfFloat(progress.progressView, "x", progress.Width); anim2Repeat.SetDuration(duration / cont); anim2Repeat.AddListener(this); anim2Repeat.Start(); if (cont == 3 || cont == 1) { suma *= -1; } }
public ProgressBarIndeterminate(Context context, IAttributeSet attrs) : base(context, attrs) { Post(() => { Progress = 60; Animation anim = AnimationUtils.LoadAnimation(Context, Resource.Animation.progress_indeterminate_animation); progressView.StartAnimation(anim); ObjectAnimator anim2 = ObjectAnimator.OfFloat(progressView, "x", Width); anim2.SetDuration(1200); anim2.AddListener(new MyAnimatorListener(this)); anim2.Start(); }); }
private void PrepDown() { ObjectAnimator y1 = ObjectAnimator.OfFloat(headers, "translationY", 0, -h1.Height); y1.SetDuration(0); nextAnim = () => { BindHeader(true, vm.GetHeader(jvm.NextProperty())); CycleDownValuesOut(); }; y1.AddListener(this); y1.Start(); //headers.OffsetTopAndBottom (-headers.Top-h1.Height); //h1.OffsetTopAndBottom (-100); //h2.OffsetTopAndBottom (-100); }
private void hideHandle(bool animated = true) { if (animated) { if (currentHandleAnimator != null) { currentHandleAnimator.Cancel(); } currentHandleAnimator = (ObjectAnimator)ObjectAnimator.OfFloat(handle, "alpha", 1f, 0f).SetDuration(ANIMATION_DURATION); currentHandleAnimator.AddListener(new HandleAnimationEndListener(this)); currentHandleAnimator.Start(); } else { handle.Alpha = 0f; } }
/** * Animate enter toolbarlayout * * @param yOffset */ private void AnimateEnterToolbarLayout() { if (!FollowScrollToolbarIsVisible && _headerAnimator != null) { ObjectAnimator objectAnimator = _headerAnimator as ObjectAnimator; if (objectAnimator != null) { objectAnimator.Cancel(); } else { Android.Animation.ObjectAnimator androidObjectAnimator = _headerAnimator as Android.Animation.ObjectAnimator; if (androidObjectAnimator != null) { androidObjectAnimator.Cancel(); } } _headerAnimator = null; } if (_headerAnimator == null) { if (Build.VERSION.SdkInt > BuildVersionCodes.GingerbreadMr1) { _headerAnimator = Android.Animation.ObjectAnimator.OfFloat(_mHeader.ToolbarLayout, "translationY", 0).SetDuration(_enterToolbarAnimationDuration); Android.Animation.ObjectAnimator animator = (Android.Animation.ObjectAnimator)_headerAnimator; animator.AnimationEnd += (sender, args) => { FollowScrollToolbarIsVisible = true; FirstScrollValue = float.MinValue; JustToolbarAnimated = true; }; animator.Start(); } else { _headerAnimator = ObjectAnimator.OfFloat(_mHeader.ToolbarLayout, "translationY", 0).SetDuration(_enterToolbarAnimationDuration); ObjectAnimator animator = (ObjectAnimator)_headerAnimator; animator.AddListener(new AnimatorListener(this)); animator.Start(); } } }
private void CycleDownValuesOut() { ObjectAnimator y1 = ObjectAnimator.OfFloat(headers, "translationY", -h1.Height, 0); //y1.SetDuration (0); //y1.SetupStartValues nextAnim = () => { ValuesOutCompleted(null, null); }; y1.AddListener(this); y1.Start(); //ObjectAnimator y2 = ObjectAnimator.OfFloat (h2, "y", 10f); //y2.Start (); foreach (var t in animvalues) { ObjectAnimator x = ObjectAnimator.OfFloat(t, "translationY", 0, offscreen); x.Start(); } }
public void AnimateObject(View view, string PropertyName, float Value, long Duration = 150, long Delay = 0) { if (PropertyName != null || PropertyName.Length != 0) { List <Animator> animations = new List <Animator>(); ObjectAnimator objectAnimator = ObjectAnimator.OfFloat(view, PropertyName, Value); animations.Add(objectAnimator); ObjectAnimator lastAnimation = (ObjectAnimator)animations[animations.Count - 1]; lastAnimation.AddListener(this); animatorSet.PlayTogether(animations.ToArray()); animatorSet.SetDuration(Duration); animatorSet.StartDelay = Delay; animatorSet.Start(); } else { throw new ArgumentNullException(nameof(PropertyName)); } }
private void TouchEventsEnded() { ViewHolder viewHolderForItemId = FindViewHolderForItemId(mobileItemId); if (viewHolderForItemId == null) { return; } mobileViewTouchEventsEnded = viewHolderForItemId.ItemView; if (cellIsMobile || usWaitingForScrollFinish) { cellIsMobile = false; usWaitingForScrollFinish = false; activePointerId = INVALID_POINTER_ID; // If the autoscroller has not completed scrolling, we need to wait for it to // finish in order to determine the final location of where the hover cell // should be animated to. if (ScrollState != (int)Android.Widget.ScrollState.Idle) { usWaitingForScrollFinish = true; return; } hoverCellCurrentBounds.OffsetTo(mobileViewTouchEventsEnded.Left, mobileViewTouchEventsEnded.Top); ObjectAnimator hoverViewAnimator = ObjectAnimator.OfObject(hoverCell, "bounds", sBoundEvaluator, hoverCellCurrentBounds); hoverViewAnimator.AddUpdateListener(valueAnimatorUpdateListner); hoverViewAnimator.AddListener(rcAnimatorListener); hoverViewAnimator.Start(); // Tell adpter movement of an item has completed. ((DraggableAdapter)GetAdapter()).MoveFinished(); } else { TouchEventsCancelled(); } }
public void AnimateObject(View view, string[] PropertyNames, float[] Values, long Duration = 150, long Delay = 0) { if (PropertyNames != null || PropertyNames.Length != 0) { List <Animator> animations = new List <Animator>(); for (int i = 0; i < PropertyNames.Length; i++) { ObjectAnimator objectAnimator = ObjectAnimator.OfFloat(view, PropertyNames[i], Values[i]); animations.Add(objectAnimator); } ObjectAnimator lastAnimation = (ObjectAnimator)animations[animations.Count - 1]; lastAnimation.AddListener(this); animatorSet.PlayTogether(animations.ToArray()); animatorSet.SetDuration(Duration); animatorSet.StartDelay = Delay; animatorSet.Start(); } else { throw new ArgumentNullException(nameof(PropertyNames)); } }