Пример #1
0
        public static Animator CreateSlideAnimator(
            Context context,
            int animeResId,
            float to = 0)
        {
            float deviceWidth = context.Resources.DisplayMetrics.WidthPixels;
            var   animSet     = AnimatorInflater.LoadAnimator(context, animeResId) as AnimatorSet;
            var   anim        = animSet.ChildAnimations.First() as ObjectAnimator;

            deviceWidth += (float)(deviceWidth * 0.1);

            switch (animeResId)
            {
            case Resource.Animator.slide_enter_left_to_right:
                anim.SetFloatValues(-deviceWidth, to);
                break;

            case Resource.Animator.slide_enter_right_to_left:
                anim.SetFloatValues(deviceWidth, to);
                break;

            case Resource.Animator.slide_exit_left_to_right:
                anim.SetFloatValues(to, deviceWidth);
                break;

            case Resource.Animator.slide_exit_right_to_left:
                anim.SetFloatValues(to, -deviceWidth);
                break;

            default:
                throw new IndexOutOfRangeException("The provided anim resource is not valid");
            }
            return(animSet);
        }
Пример #2
0
        private void FlyImages_Click(object sender, EventArgs e)
        {
            bool isSelected  = FListView.IsSelectedItem(Position);
            var  setRightOut = (AnimatorSet)AnimatorInflater.LoadAnimator(Context, Resource.Animator.right_out);
            var  setLeftIn   = (AnimatorSet)AnimatorInflater.LoadAnimator(Context, Resource.Animator.left_in);

            if (!isSelected)
            {
                setRightOut.SetTarget(ImgUser);
                setLeftIn.SetTarget(ImgBack);
                setRightOut.Start();
                setLeftIn.Start();
                //this.SetBackgroundColor(Android.Graphics.Color.AliceBlue);
                FListView.MarkItemAsSelected(Position, true);
            }
            else
            {
                setRightOut.SetTarget(ImgBack);
                setLeftIn.SetTarget(ImgUser);
                setRightOut.Start();
                setLeftIn.Start();
                //this.SetBackgroundColor(Android.Graphics.Color.White);
                FListView.MarkItemAsSelected(Position, false);
            }

            FListView.UpdateActionModeDroid();
        }
Пример #3
0
        /// <summary>
        /// Performs flip animation on two views.
        /// </summary>
        /// <param name="back">Back.</param>
        /// <param name="front">Front.</param>
        /// <param name="showFront">If set to <c>true</c> show front.</param>
        public static void FlipView(View back, View front, bool showFront)
        {
            AnimatorSet leftIn, rightOut, leftOut, rightIn;

            leftIn   = (AnimatorSet)AnimatorInflater.LoadAnimator(Application.Context, Resource.Animator.flip_left_in);
            rightOut = (AnimatorSet)AnimatorInflater.LoadAnimator(Application.Context, Resource.Animator.flip_right_out);
            leftOut  = (AnimatorSet)AnimatorInflater.LoadAnimator(Application.Context, Resource.Animator.flip_left_out);
            rightIn  = (AnimatorSet)AnimatorInflater.LoadAnimator(Application.Context, Resource.Animator.flip_right_in);

            var animator = new AnimatorSet();

            animator.AnimationEnd += (sender, e) =>
            {
                animator.Dispose();
                leftIn.Dispose();
                rightOut.Dispose();
                leftOut.Dispose();
                rightIn.Dispose();
            };

            if (showFront)
            {
                leftIn.SetTarget(back);
                rightOut.SetTarget(front);
                animator.PlayTogether(leftIn, rightOut);
            }
            else
            {
                leftOut.SetTarget(back);
                rightIn.SetTarget(front);
                animator.PlayTogether(rightIn, leftOut);
            }

            animator.Start();
        }
 public override Android.Animation.Animator OnCreateAnimator(FragmentTransit transit, bool enter, int nextAnim)
 {
     if (!enter && shouldAnimatePop)
     {
         return(AnimatorInflater.LoadAnimator(View.Context, Resource.Animation.add_to_basket_in));
     }
     return(base.OnCreateAnimator(transit, enter, nextAnim));
 }
Пример #5
0
        public override Animator OnCreateAnimator(FragmentTransit transit, bool enter, int nextAnim)
        {
            int      id   = enter ? Resource.Animator.slide_fragment_in : Resource.Animator.slide_fragment_out;
            Animator anim = AnimatorInflater.LoadAnimator(Activity, id);

            if (enter)
            {
                anim.AnimationEnd += anim_AnimationEnd;
            }

            return(anim);
        }
Пример #6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_view_property_animation);

            _imageView        = FindViewById <ImageView>(Resource.Id.activity_view_animation_imageView);
            _imageView.Click += OnImageViewClick;

            _animator = AnimatorInflater.LoadAnimator(this, Resource.Animator.property_animation);
            _animator.SetTarget(_imageView);

            _random = new Random();
        }
        private Animator createAnimatorIn(Context context)
        {
            Animator animatorIn;

            if (mAnimatorReverseResId == 0)
            {
                animatorIn = AnimatorInflater.LoadAnimator(context, mAnimatorResId);
                animatorIn.SetInterpolator(new ReverseInterpolator());
            }
            else
            {
                animatorIn = AnimatorInflater.LoadAnimator(context, mAnimatorReverseResId);
            }
            return(animatorIn);
        }
Пример #8
0
        public CompatibilityAnimation(Context context, int objectAnimation, int backupAnimation)
        {
            if (Build.VERSION.SdkInt >= BuildVersionCodes.IceCreamSandwich)
            {
                anim = AnimatorInflater.LoadAnimator(context, objectAnimation);

                var animator = (Animator)anim;

                animator.AnimationStart += (sender, args) =>
                {
                    if (AnimationStart != null)
                    {
                        AnimationStart();
                    }
                };
                animator.AnimationEnd += (sender, args) =>
                {
                    if (AnimatioEnd != null)
                    {
                        AnimatioEnd();
                    }
                };
            }
            else
            {
                anim = AnimationUtils.LoadAnimation(context, backupAnimation);
                var animation = (Animation)anim;
                animation.FillBefore = true;
                animation.FillAfter  = true;

                animation.AnimationStart += (sender, args) =>
                {
                    if (AnimationStart != null)
                    {
                        AnimationStart();
                    }
                };

                animation.AnimationEnd += (sender, args) =>
                {
                    if (AnimatioEnd != null)
                    {
                        AnimatioEnd();
                    }
                };
            }
        }
Пример #9
0
        /// <summary>
        /// Called when a fragment loads an animation.
        /// </summary>
        /// <param name="transit">To be added.</param>
        /// <param name="enter">To be added.</param>
        /// <param name="nextAnim">To be added.</param>
        /// <returns>The Animator object to be used for the transition.</returns>
        public override Animator OnCreateAnimator([GeneratedEnum] FragmentTransit transit, bool enter, int nextAnim)
        {
            var animator = AnimatorInflater.LoadAnimator(Activity, nextAnim);

            if (animator != null)
            {
                animator.AnimationStart += (sender, args) =>
                {
                    ((Activities.CrexActivity)Activity).FragmentAnimationStarted(enter);
                };
                animator.AnimationEnd += (sender, args) =>
                {
                    ((Activities.CrexActivity)Activity).FragmentAnimationEnded(enter);
                };
            }

            return(animator);
        }
        /// <summary>
        /// Flips a view, hiding one view and revealing another as the flip finished.
        /// </summary>
        /// <param name="view">View.</param>
        /// <param name="hideId">Hide identifier.</param>
        /// <param name="revealId">Reveal identifier.</param>
        private void FlipView(View view, int hideId, int revealId)
        {
            var fo      = AnimatorInflater.LoadAnimator(this, Resource.Animation.card_flip_left_out);
            var fi      = AnimatorInflater.LoadAnimator(this, Resource.Animation.card_flip_left_in);
            var fadeOut = AnimatorInflater.LoadAnimator(this, Resource.Animation.fade_out);
            var fadeIn  = AnimatorInflater.LoadAnimator(this, Resource.Animation.fade_in);

            var hideView   = view.FindViewById(hideId);
            var revealView = view.FindViewById(revealId);

            fo.SetTarget(view);
            fi.SetTarget(view);
            fadeOut.SetTarget(hideView);
            fadeIn.SetTarget(revealView);

            var animOut = new AnimatorSet();

            animOut.Play(fo);
            animOut.SetDuration(350);
            animOut.AnimationEnd += (obj, args) => {
                hideView.Visibility   = ViewStates.Gone;
                revealView.Visibility = ViewStates.Visible;
            };

            var animIn = new AnimatorSet();

            animIn.Play(fi);
            animIn.SetDuration(350);

            var animationSet = new AnimatorSet();

            animationSet.AnimationEnd += (obj, args) => {
                hideView.Visibility   = ViewStates.Gone;
                revealView.Visibility = ViewStates.Visible;
            };
            animationSet.Play(animOut)
            .Before(animIn);
            animationSet.Start();
        }
Пример #11
0
        public override Animator OnCreateAnimator(FragmentTransit transit, bool enter, int nextAnim)
        {
            Animator animator = AnimatorInflater.LoadAnimator(Activity,
                                                              enter ? Android.Resource.Animator.FadeIn : Android.Resource.Animator.FadeOut);

            // We bind a listener for the fragment transaction. We only bind it when
            // this fragment is entering.
            if (animator != null && enter)
            {
                animator.AnimationEnd += (object sender, EventArgs e) => {
                    // This method is called at the end of the animation for the fragment transaction,
                    // which is perfect time to start our Transition.
                    Log.Info(TAG, "Fragment animation ended. Starting a Transition.");
                    Scene scene = Scene.GetSceneForLayout((ViewGroup)View, Resource.Layout.fragment_detail_content, Activity);
                    TransitionManager.Go(scene);
                    // Note that we need to bind views with data after we call TransitionManager.go().
                    Bind(scene.SceneRoot);
                }
            }
            ;

            return(animator);
        }
    }
Пример #12
0
 private Animator createAnimatorOut(Context context)
 {
     return(AnimatorInflater.LoadAnimator(context, mAnimatorResId));
 }
 public override Animator[] getAnimators(ViewGroup parent, View view)
 {
     return(new Animator[] { AnimatorInflater.LoadAnimator(mContext, getAnimationResourceId()) });
 }