Example #1
0
        public void AnimateBasket(float basketInitialY)
        {
            try
            {
                IsBasketAnimating = true;

                ClearAlphaAnimation(false);

                //save initial x,y values for mic icon
                if (MicX == 0)
                {
                    MicX = SmallBlinkingMic.GetX();
                    MicY = SmallBlinkingMic.GetY();
                }

                MicAnimation = (AnimatorSet)AnimatorInflaterCompat.LoadAnimator(Context, Resource.Animator.delete_mic_animation);
                MicAnimation.SetTarget(SmallBlinkingMic); // set the view you want to animate

                TranslateAnimation1 = new TranslateAnimation(0, 0, basketInitialY, basketInitialY - 90)
                {
                    Duration = 250
                };
                TranslateAnimation2 = new TranslateAnimation(0, 0, basketInitialY - 130, basketInitialY)
                {
                    Duration = 350
                };

                MicAnimation.Start();
                BasketImg.SetImageDrawable(AnimatedVectorDrawable);

                Handler1 = new Handler(Looper.MainLooper);
                Handler1.PostDelayed(() =>
                {
                    try
                    {
                        BasketImg.Visibility = ViewStates.Visible;
                        BasketImg.StartAnimation(TranslateAnimation1);
                    }
                    catch (Exception e)
                    {
                        Methods.DisplayReportResultTrack(e);
                    }
                }, 350);

                TranslateAnimation1.AnimationEnd += (sender, args) =>
                {
                    try
                    {
                        AnimatedVectorDrawable.Start();
                        Handler2 = new Handler(Looper.MainLooper);
                        Handler2.PostDelayed(() =>
                        {
                            try
                            {
                                BasketImg.StartAnimation(TranslateAnimation2);
                                SmallBlinkingMic.Visibility = ViewStates.Invisible;
                                BasketImg.Visibility        = ViewStates.Invisible;
                            }
                            catch (Exception e)
                            {
                                Methods.DisplayReportResultTrack(e);
                            }
                        }, 450);
                    }
                    catch (Exception e)
                    {
                        Methods.DisplayReportResultTrack(e);
                    }
                };


                TranslateAnimation2.AnimationEnd += (sender, args) =>
                {
                    try
                    {
                        BasketImg.Visibility = ViewStates.Invisible;

                        IsBasketAnimating = false;

                        //if the user pressed the record button while the animation is running
                        // then do NOT call on Animation end
                        if (OnBasketAnimationEndListener != null && !IsStartRecorded)
                        {
                            OnBasketAnimationEndListener.OnAnimationEnd();
                        }
                    }
                    catch (Exception e)
                    {
                        Methods.DisplayReportResultTrack(e);
                    }
                };
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Example #2
0
 private void RepeatAnimation()
 {
     avdProgress.Start();
     loadingBar.PostDelayed(action, 300);
 }