示例#1
0
        public void AnimateY(long yAxisDuration, EasingFunction easing)
        {
            ObjectAnimator animatorY = YAnimator(yAxisDuration, easing);

            animatorY.AddUpdateListener(Delegate);
            animatorY.Start();
        }
示例#2
0
        /**
         * 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();
            }
        }
示例#3
0
        public void AnimateX(long xAxisDuration, EasingFunction easing)
        {
            ObjectAnimator animatorX = XAnimator(xAxisDuration, easing);

            animatorX.AddUpdateListener(Delegate);
            animatorX.Start();
        }
示例#4
0
        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);
        }
 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);
 }
        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();
        }
示例#7
0
        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();
            }
        }
示例#8
0
 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;
     }
 }
示例#9
0
        /**
         * Manage animation for Android < KITKAT
         *
         * @param child
         */
        private void ensureOrCancelObjectAnimation(T child, int offset, bool withAnimation)
        {
            if (translationObjectAnimator != null)
            {
                translationObjectAnimator.Cancel();
            }

            translationObjectAnimator = ObjectAnimator.OfFloat(child, /*View.TRANSLATION_Y*/ "translationY", offset);
            translationObjectAnimator.SetDuration(withAnimation ? ANIM_DURATION : 0);
            translationObjectAnimator.SetInterpolator(INTERPOLATOR);
            translationObjectAnimator.AddUpdateListener(
                new CustomViewPropertyIAnimatorUpdateListener((animation) =>
            {
                if (snackbarLayout != null && snackbarLayout.LayoutParameters is ViewGroup.MarginLayoutParams)
                {
                    targetOffset = child.MeasuredHeight - child.TranslationY;
                    ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams)snackbarLayout.LayoutParameters;
                    p.SetMargins(p.LeftMargin, p.TopMargin, p.RightMargin, (int)targetOffset);
                    snackbarLayout.RequestLayout();
                }
                // Animate Floating Action Button
                if (floatingActionButton != null && floatingActionButton.LayoutParameters is ViewGroup.MarginLayoutParams)
                {
                    ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams)floatingActionButton.LayoutParameters;
                    fabTargetOffset = fabDefaultBottomMargin - child.TranslationY + snackBarY;
                    p.SetMargins(p.LeftMargin, p.TopMargin, p.RightMargin, (int)fabTargetOffset);
                    floatingActionButton.RequestLayout();
                }
                // Pass navigation height to listener
                if (navigationPositionListener != null)
                {
                    navigationPositionListener.onPositionChange((int)(child.MeasuredHeight - child.TranslationY + snackBarY));
                }
            })
                );
        }