コード例 #1
0
        /**
         * build FlexibleAnimation to control the progress
         *
         * @return Animatorset for control the progress
         */
        private AnimatorSet buildFlexibleAnimation()
        {
            Ring          ring      = mRing;
            AnimatorSet   set       = new AnimatorSet();
            ValueAnimator increment = ValueAnimator.OfFloat(0, MAX_PROGRESS_ARC - MIN_PROGRESS_ARC);

            increment.SetDuration(ANIMATOR_DURATION / 2);
            increment.SetInterpolator(new LinearInterpolator());
            increment.Update += (sender, e) =>
            {
                float sweeping = ring.sweeping;
                float value    = (float)e.Animation.AnimatedValue;
                ring.sweep = sweeping + value;
                Invalidate();
            };
            increment.AddListener(animatorListener);
            ValueAnimator reduce = ValueAnimator.OfFloat(0, MAX_PROGRESS_ARC - MIN_PROGRESS_ARC);

            reduce.SetDuration(ANIMATOR_DURATION / 2);
            reduce.SetInterpolator(interpolator);
            reduce.Update += (sender, e) =>
            {
                float sweeping = ring.sweeping;
                float starting = ring.starting;
                float value    = (float)e.Animation.AnimatedValue;
                ring.sweep = sweeping - value;
                ring.start = starting + value;
            };
            set.Play(reduce).After(increment);
            return(set);
        }
コード例 #2
0
        /// <summary>
        /// Animates the root view's content view closed.
        /// </summary>
        /// <param name="root"></param>
        private void AnimateCollapsing(RootView root)
        {
            ValueAnimator animator = AnimationHelper.CreateHeightAnimator(root.contentLayout, root.contentLayout.Height, 0);

            animator.AddListener(new SetViewToGoneOnAnimatorEndAction(root.contentLayout));
            animator.Start();
        }
コード例 #3
0
 private void doShareAnim()
 {
     shakeAnimator = ValueAnimator.OfFloat(0.4f, 1f, 0.9f, 1f);
     shakeAnimator.SetInterpolator(new LinearInterpolator());
     shakeAnimator.SetDuration(500);
     shakeAnimator.StartDelay = 180;
     invalidate();
     shakeAnimator.AddUpdateListener(new XAnimatorUpdateListener()
     {
         AnimationUpdate = (valueAnimator) =>
         {
             ScaleX = (float)valueAnimator.AnimatedValue;
             ScaleY = (float)valueAnimator.AnimatedValue;
         }
     });
     shakeAnimator.AddListener(new XAnimatorListener()
     {
         Start = (animator) =>
         {
             setSrcColor(btnFillColor);
         },
         End = (animator) =>
         {
             setSrcColor(_isChecked ? btnFillColor : btnColor);
         },
         Cancel = (animator) =>
         {
             setSrcColor(btnColor);
         }
     });
     shakeAnimator.Start();
 }
コード例 #4
0
 partial void OnStart()
 {
     _val = ValueAnimator.OfFloat(0f, 1f);
     _val.SetDuration(duration);
     _val.AddUpdateListener(this);
     _val.AddListener(this);
     _val.Start();
 }
コード例 #5
0
        public ShineView(Context context, ShineButton shineButton, ShineParams shineParams) : base(context)
        {
            initShineParams(shineParams, shineButton);


            this.shineAnimator       = new ShineAnimator(animDuration, shineDistanceMultiple, clickAnimDuration);
            ValueAnimator.FrameDelay = FRAME_REFRESH_DELAY;
            this.shineButton         = shineButton;


            paint             = new Paint();
            paint.Color       = bigShineColor;
            paint.StrokeWidth = 20;
            paint.SetStyle(Paint.Style.Stroke);
            paint.StrokeCap = Paint.Cap.Round;

            paint2             = new Paint();
            paint2.Color       = Color.White;
            paint2.StrokeWidth = 20;
            paint2.StrokeCap   = Paint.Cap.Round;

            paintSmall             = new Paint();
            paintSmall.Color       = smallShineColor;
            paintSmall.StrokeWidth = 10;
            paintSmall.SetStyle(Paint.Style.Stroke);
            paintSmall.StrokeCap = Paint.Cap.Round;

            clickAnimator            = ValueAnimator.OfFloat(0f, 1.1f);
            ValueAnimator.FrameDelay = FRAME_REFRESH_DELAY;
            clickAnimator.SetDuration(clickAnimDuration);
            clickAnimator.SetInterpolator(new XEI(Ease.QUART_OUT));

            clickAnimator.AddUpdateListener(new XAnimatorUpdateListener()
            {
                AnimationUpdate = (valueAnimator) =>
                {
                    clickValue = (float)valueAnimator.AnimatedValue;
                    Invalidate();
                }
            });

            clickAnimator.AddListener(new XAnimatorListener()
            {
                End = (animator) =>
                {
                    clickValue = 0;
                    Invalidate();
                }
            });

            shineAnimator.AddListener(new XAnimatorListener()
            {
                End = (animator) =>
                {
                    shineButton.removeView(this);
                }
            });
        }
コード例 #6
0
        private void AnimateLoginButton(bool AnimateBackwards = false)
        {
            ValueAnimator Animator = ValueAnimator.OfInt(loginButton.MeasuredWidth, ButtonWidth);

            if (!AnimateBackwards)
            {
                Animator = ValueAnimator.OfInt(loginButton.MeasuredWidth, ValueConverter.DpToPx(40));
            }
            Animator.AddListener(new AnimationListner(AnimateBackwards));
            Animator.AddUpdateListener(new AnimUpdateListner(loginButton));
            Animator.SetDuration(250);
            Animator.Start();
        }
コード例 #7
0
        /**
         * Animates the dismissed list item to zero-height and fires the dismiss callback when all dismissed list item animations have completed.
         *
         * @param view the dismissed {@link android.view.View}.
         */
        protected virtual void performDismiss(View view, int position)
        {
            mDismissedViews.Add(view);
            mDismissedPositions.Add(position);

            ValueAnimator animator = ValueAnimator.OfInt(view.Height, 1);

            animator.SetDuration(mDismissAnimationTime);
            animator.AddUpdateListener(new DismissAnimatorUpdateListener(view));
            animator.AddListener(new DismissAnimatorListener(this));
            animator.Start();

            mActiveDismissCount++;
        }
コード例 #8
0
        protected ValueAnimator CreateAnimator()
        {
            // Calculate the longest distance from the hot spot to the edge of the circle.
            int endRadius = Width / 2 + ((int)Math.Sqrt(Math.Pow(Width / 2 - touchPoint.Y, 2)
                                                        + Math.Pow(Width / 2 - touchPoint.X, 2)));

            // Make sure the touch point is defined or set it to the middle of the view.
            if (touchPoint == null)
            {
                touchPoint = new Point(Width / 2, Height / 2);
            }

            ValueAnimator anim = ViewAnimationUtils.CreateCircularReveal(revealView, touchPoint.X, touchPoint.Y, 0, endRadius);

            anim.AddListener(new MyAnimatorListenerAdapter(this));
            return(anim);
        }
コード例 #9
0
        /**
         * Manually cause the item at the given position to be dismissed (trigger the dismiss
         * animation).
         */


        public void PerformDismiss(View dismissView, int dismissPosition)
        {
            // Animate the dismissed list item to zero-height and fire the dismiss callback when
            // all dismissed list item animations have completed. This triggers layout on each animation
            // frame; in the future we may want to do something smarter and more performant.
            ViewGroup.LayoutParams lp    = dismissView.LayoutParameters;
            int           originalHeight = dismissView.Height;
            ValueAnimator animator       = ValueAnimator.OfInt(originalHeight, 1);

            animator.SetDuration(mAnimationTime);
            animator.AddListener(new DismissAnimatorListenerAdapter(this, originalHeight));

            animator.AddUpdateListener(new AnimatorUpdateListener(dismissView, lp));

            mPendingDismisses.Add(new PendingDismissData(dismissPosition, dismissView));
            animator.Start();
        }
コード例 #10
0
        public AnimatingLineRenderableSeries()
        {
            _animator = ValueAnimator.OfFloat(StartValue, EndValue);
            _animator.SetInterpolator(new DecelerateInterpolator());
            _animator.SetDuration(Duration);
            _animator.AddUpdateListener(this);
            _animator.AddListener(this);

            _animatorRestartRunnable = new ActionRunnable(() =>
            {
                if (_animator.IsRunning)
                {
                    _animator.Cancel();
                }

                _animator.Start();
            });
        }
コード例 #11
0
            public static void animateCollapsing(View view)
            {
                int origHeight = view.Height;

                ValueAnimator animator = createHeightAnimator(view, origHeight, 0);

                //animator.addListener(
                //        new AnimatorListenerAdapter() {

                //            @Override
                //            public void onAnimationEnd( Animator animation) {
                //                view.setVisibility(View.GONE);
                //            }
                //        }
                //);
                animator.AddListener(new ExpandCollapseAnimatorHelper(view));

                animator.Start();
            }
コード例 #12
0
        private void InitBarAnimator(int start, int end, int animationType)
        {
            try
            {
                if (MBarAnimator == null)
                {
                    MBarAnimator = ValueAnimator.OfInt(start, end);
                    MBarAnimator.SetDuration(1000);
                    MBarAnimator.AddUpdateListener(new MyBarAnimatorUpdateListener(this));
                    MBarAnimator.AddListener(new MyBarAnimatorListener(this, animationType));

                    MBarAnimator.Start();
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
コード例 #13
0
        private void InitBarAnimator(int start, int end, int animationType)
        {
            try
            {
                if (MBarAnimator == null)
                {
                    MBarAnimator = ValueAnimator.OfInt(start, end);
                    MBarAnimator.SetDuration(1000);
                    MBarAnimator.AddUpdateListener(new MyBarAnimatorUpdateListener(this));
                    MBarAnimator.AddListener(new MyBarAnimatorListener(this, animationType));

                    MBarAnimator.Start();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #14
0
ファイル: NavbarFragment.cs プロジェクト: J3057/MobileApp
        public void RevealSpringboard(bool wantReveal)
        {
            if (!Animating)
            {
                Animating = true;

                int xOffset = wantReveal ? (int)Springboard.GetSpringboardDisplayWidth( ) : 0;

                // setup an animation from our current mask scale to the new one.
                XPosAnimator = ValueAnimator.OfInt((int)View.GetX( ), xOffset);

                XPosAnimator.AddUpdateListener(this);
                XPosAnimator.AddListener(new NavbarAnimationListener( )
                {
                    NavbarFragment = this
                });
                XPosAnimator.SetDuration((int)(PrivatePrimaryContainerConfig.SlideRate * 1000.0f));
                XPosAnimator.Start();
            }
        }
コード例 #15
0
        private void ShowAnimation(Activity ctx)
        {
            View   decorView   = ctx.Window.DecorView;
            Bitmap cacheBitmap = GetCacheBitmapFromView(decorView);

            if (decorView is ViewGroup group && cacheBitmap != null)
            {
                View view = new View(ctx)
                {
                    Background = new BitmapDrawable(ctx.Resources, cacheBitmap)
                };
                ViewGroup.LayoutParams layoutParam = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
                group.AddView(view, layoutParam);
                ValueAnimator objectAnimator = ValueAnimator.OfFloat(1f, 0f);
                objectAnimator.SetDuration(500);
                objectAnimator.AddListener(new AnimatorListenerAdapter(decorView, view));
                objectAnimator.AddUpdateListener(new AnimatorUpdateListener(view));
                objectAnimator.Start();
            }
        }
コード例 #16
0
 public void InitProgressAnimator(float playbackSpeed, int progress, int max)
 {
     try
     {
         int timeToEnd = (int)((max - progress) / playbackSpeed);
         if (timeToEnd > 0)
         {
             if (ValueAnimator.OfInt(progress, max).SetDuration(timeToEnd) is ValueAnimator value)
             {
                 MProgressAnimator = value;
                 MProgressAnimator.SetInterpolator(new LinearInterpolator());
                 MProgressAnimator.AddUpdateListener(new MyProgressAnimatorUpdateListener(this));
                 MProgressAnimator.AddListener(new MyProgressAnimatorListener(this));
                 MProgressAnimator.Start();
             }
         }
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
コード例 #17
0
        /**
         * Handles the up event.
         * <p/>
         * Animates the hover drawable to its final position, and finalizes our drag properties when the animation has finished.
         * Will also notify the {@link com.nhaarman.listviewanimations.itemmanipulation.dragdrop.OnItemMovedListener} set if applicable.
         *
         * @return {@code true} if the event was handled, {@code false} otherwise.
         */
        private bool handleUpEvent()
        {
            if (mMobileView == null)
            {
                return(false);
            }
            //assert mHoverDrawable != null;

            ValueAnimator valueAnimator = ValueAnimator.OfInt(mHoverDrawable.getTop(), (int)mMobileView.GetY());
            SettleHoverDrawableAnimatorListener listener = new SettleHoverDrawableAnimatorListener(mHoverDrawable, mMobileView, this);

            valueAnimator.AddUpdateListener(listener);
            valueAnimator.AddListener(listener);
            valueAnimator.Start();

            int newPosition = getPositionForId(mMobileItemId) - mWrapper.getHeaderViewsCount();

            if (mOriginalMobileItemPosition != newPosition && mOnItemMovedListener != null)
            {
                mOnItemMovedListener.onItemMoved(mOriginalMobileItemPosition, newPosition);
            }

            return(true);
        }
コード例 #18
0
ファイル: Odometer.cs プロジェクト: EXOMODE/Odometer
        protected virtual void Initialize(Context context, IAttributeSet attrs, int defStyle, int defStyleRes)
        {
            if (context == null)
            {
                return;
            }

            OdometerStyledAttributes styledAttributes = new OdometerStyledAttributes(this, context.Resources);
            TypedArray arr = context.ObtainStyledAttributes(attrs, Resource.Styleable.odometer, defStyle, defStyleRes);
            int        textAppearanceResId = arr.GetResourceId(Resource.Styleable.odometer_android_textAppearance, -1);

            if (textAppearanceResId != -1)
            {
                TypedArray textAppearanceArr = context.ObtainStyledAttributes(textAppearanceResId, Resource.Styleable.odometer);
                styledAttributes.ApplyTypedArray(textAppearanceArr);
                textAppearanceArr.Recycle();
            }

            styledAttributes.ApplyTypedArray(arr);

            animationInterpolator       = DefaultAnimationInterpolator;
            animationDurationInMillis   = arr.GetInt(Resource.Styleable.odometer_animationDuration, DefaultAnimationDuration);
            isAnimateMeasurementChanged = arr.GetBoolean(Resource.Styleable.odometer_animateMeasurementChange, false);
            gravity = styledAttributes.Gravity;

            if (styledAttributes.ShadowColor != 0)
            {
                textPaint.SetShadowLayer(styledAttributes.ShadowRadius, styledAttributes.ShadowDx, styledAttributes.ShadowDy, styledAttributes.ShadowColor);
            }

            if (styledAttributes.TextStyle != 0)
            {
                textStyle = styledAttributes.TextStyle;
                Typeface  = textPaint.Typeface;
            }

            TextColor = styledAttributes.TextColor;
            TextSize  = styledAttributes.TextSize;

            int defaultCharList = arr.GetInt(Resource.Styleable.odometer_defaultCharacterList, 0);

            switch (defaultCharList)
            {
            case 1:
                SetCharacterLists(Utils.ProvideNumberList);
                break;

            case 2:
                SetCharacterLists(Utils.ProvideAlphabeticalList);
                break;

            default:
                SetCharacterLists(Utils.ProvideNumberList, Utils.ProvideAlphabeticalList);
                break;
            }

            int defaultPreferredScrollingDirection = arr.GetInt(Resource.Styleable.odometer_defaultPreferredScrollingDirection, 0);

            metrics.PreferredScrollingDirection = defaultPreferredScrollingDirection switch
            {
                0 => ScrollingDirection.Any,
                1 => ScrollingDirection.Up,
                2 => ScrollingDirection.Down,
                _ => throw new System.ArgumentException("Unsupported ticker_defaultPreferredScrollingDirection: " + defaultPreferredScrollingDirection),
            };

            if (IsCharacterListsSet)
            {
                SetText(styledAttributes.Text, false);
            }
            else
            {
                pendingTextToSet = styledAttributes.Text;
            }

            arr.Recycle();

            animator.AddUpdateListener(new AnimatorUpdateListener(this));
            animator.AddListener(new AnimationAdapter(this));
        }
コード例 #19
0
 public void addAnimatorListener(Animator.IAnimatorListener animatorListener)
 {
     animator.AddListener(animatorListener);
 }
コード例 #20
0
ファイル: ChartCell.xaml.cs プロジェクト: UnigramDev/Unigram
        private void ZoomChart(bool skipTransition)
        {
            chartView.Visibility = Visibility.Visible;

            long d         = chartView.GetSelectedDate();
            var  childData = data.childChartData;

            if (childData == null)
            {
                return;
            }

            if (!skipTransition || zoomedChartView.Visibility != Visibility.Visible)
            {
                zoomedChartView.UpdatePicker(childData, d);
            }
            zoomedChartView.SetDataPublic(childData);

            if (data.chartData.lines.Count > 1)
            {
                var lines        = chartView.GetLines();
                var zoomedLines  = zoomedChartView.GetLines();
                int enabledCount = 0;
                for (int i = 0; i < data.chartData.lines.Count; i++)
                {
                    bool found = false;
                    for (int j = 0; j < childData.lines.Count; j++)
                    {
                        var line = childData.lines[j];
                        if (line.id.Equals(data.chartData.lines[i].id))
                        {
                            bool check = lines[j].enabled;
                            zoomedLines[j].enabled = check;
                            zoomedLines[j].alpha   = check ? 1f : 0f;
                            //checkBoxes.get(i).checkBox.enabled = true;
                            //checkBoxes.get(i).checkBox.animate().alpha(1).start();
                            if (check)
                            {
                                enabledCount++;
                            }

                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        //checkBoxes.get(i).checkBox.enabled = false;
                        //checkBoxes.get(i).checkBox.animate().alpha(0).start();
                    }
                }

                if (enabledCount == 0)
                {
                    for (int i = 0; i < data.chartData.lines.Count; i++)
                    {
                        //checkBoxes.get(i).checkBox.enabled = true;
                        //checkBoxes.get(i).checkBox.animate().alpha(1).start();
                    }
                    return;
                }
            }

            data.activeZoom = d;

            //chartView.legendSignatureView.setAlpha(0f);
            chartView.selectionA      = 0;
            chartView.legendShowing   = false;
            chartView.animateLegentTo = false;

            zoomedChartView.UpdateColors();

            if (!skipTransition)
            {
                zoomedChartView.ClearSelection();
                chartHeaderView.zoomTo(zoomedChartView, d, true);
            }

            zoomedChartView.SetHeader(chartHeaderView);
            chartView.SetHeader(null);

            if (skipTransition)
            {
                chartView.Visibility       = Visibility.Collapsed;
                zoomedChartView.Visibility = Visibility.Visible;

                chartView.transitionMode       = BaseChartView.TRANSITION_MODE_NONE;
                zoomedChartView.transitionMode = BaseChartView.TRANSITION_MODE_NONE;
                //chartView.enabled = false;
                //zoomedChartView.enabled = true;
                chartHeaderView.zoomTo(zoomedChartView, d, false);
            }
            else
            {
                ValueAnimator animator = CreateTransitionAnimator(d, true);
                animator.AddListener(new AnimatorUpdateListener(null, animation =>
                {
                    _ = chartView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        chartView.Visibility = Visibility.Collapsed;
                    });

                    //chartView.enabled = false;
                    //zoomedChartView.enabled = true;
                    chartView.transitionMode       = BaseChartView.TRANSITION_MODE_NONE;
                    zoomedChartView.transitionMode = BaseChartView.TRANSITION_MODE_NONE;
                    //((Activity)getContext()).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
                }));
                animator.Start();
            }
        }