Ejemplo n.º 1
0
        private void SwitchPositions()
        {
            // Remove the listner
            _animator.SetListener(null);
            _animator = null;

            RunOnUiThread(() =>
            {
                var width = _currentImageView.Width;

                var tmp           = _currentImageView;
                _currentImageView = _nextImageView;
                _currentImageView.TranslationX = 0;

                _nextImageView = tmp;
                _nextImageView.TranslationX = width;
                _nextImageView.SetImageBitmap(null);
                _nextImageView.DestroyDrawingCache();

                GC.Collect();

                ImageLoader.LoadImage(_images[_nextImageIndex], _nextImageView);
                _nextImageIndex++;

                if (_nextImageIndex >= _images.Count)
                {
                    _nextImageIndex = 0;
                }
            });
        }
Ejemplo n.º 2
0
        public void SetupInitialAnimations(Action callback = null)
        {
            int delay        = 10;
            var time         = Resources.GetInteger(Android.Resource.Integer.ConfigMediumAnimTime);
            var delayIncr    = (3 * time) / 4;
            var interpolator = new Android.Views.Animations.DecelerateInterpolator();
            ViewPropertyAnimator circleAnim = null;

            foreach (var id in circleIds)
            {
                var circle = circlesLayout.FindViewById(id);

                circle.ScaleX = .3f;
                circle.ScaleY = .3f;
                circle.Alpha  = 0;

                circleAnim = circle.Animate()
                             .ScaleX(1)
                             .ScaleY(1)
                             .Alpha(1)
                             .SetStartDelay(delay)
                             .SetDuration(time)
                             .SetInterpolator(interpolator);

                var last = id == circleIds.Last();
                if (last && callback != null)
                {
                    circleAnim.WithEndAction(new Run(callback));
                }

                circleAnim.Start();
                delay += delayIncr;
            }
        }
Ejemplo n.º 3
0
            public LoadingBarController(View flashBarView)
            {
                barView     = flashBarView;
                barAnimator = barView.Animate();
                messageView = barView.FindViewById <TextView> (Resource.Id.loadingBarMessage);

                HideBar(true);
            }
Ejemplo n.º 4
0
        protected static void Hide(View view)
        {
            ViewPropertyAnimator animator = view.Animate().TranslationY(viewY).SetInterpolator(INTERPOLATOR).SetDuration(300);

            animator.SetListener(new HideAnimatorListener(view));

            animator.Start();
        }
        public static ViewPropertyAnimator ScrollY(this ViewPropertyAnimator vpa, ImageView imgView, params int[] values)
        {
            ObjectAnimator objAnim = ObjectAnimator.OfInt(imgView, "ScrollY", values);

            objAnim.SetDuration(vpa.Duration);
            objAnim.StartDelay = vpa.StartDelay;
            objAnim.Start();
            return(vpa);
        }
        public static ViewPropertyAnimator ScrollX(this ViewPropertyAnimator vpa, ImageView imgView, params int[] values)
        {
            ObjectAnimator objAnim = ObjectAnimator.OfInt(imgView, "ScrollX", values);

            objAnim.SetDuration(vpa.Duration / 2); //Divide by 2 so it will take less time.
            objAnim.StartDelay = vpa.StartDelay;
            objAnim.Start();
            return(vpa);
        }
Ejemplo n.º 7
0
        public SlidingInterpolator(Context context, IAttributeSet attributeSet) : base(context, attributeSet)
        {
            if (view == null)
            {
                throw new Exception("SlidingInterpolator requires a View in its constructor");
            }

            _animatedView = view;
            _animator     = view.Animate();
        }
Ejemplo n.º 8
0
        protected override void OnDestroy()
        {
            base.OnDestroy();

            _timer            = null;
            _listener         = null;
            _animator         = null;
            _currentImageView = null;
            _nextImageView    = null;
            _images           = null;
        }
 private void RunOnAnimationEnd(ViewPropertyAnimator animator, Action runnable)
 {
     if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBean)
     {
         animator.WithEndAction(new Java.Lang.Runnable(runnable));
     }
     else
     {
         animator.SetListener(new Listener(runnable));
     }
 }
Ejemplo n.º 10
0
        public UndoBarController(View undoBarView, IUndoListener undoListener)
        {
            mBarView      = undoBarView;
            mBarAnimator  = mBarView.Animate();
            mUndoListener = undoListener;

            mMessageView = (TextView)mBarView.FindViewById(Resource.Id.undobar_message);
            mBarView.FindViewById <Button> (Resource.Id.undobar_button).Click += (object sender, EventArgs e) => {
                HideUndoBar(false);
                mUndoListener.OnUndo(mUndoToken);
            };
            HideUndoBar(true);
        }
Ejemplo n.º 11
0
        private void OnTimedEvent(object sender, System.Timers.ElapsedEventArgs e)
        {
            var width = _currentImageView.Width;

            RunOnUiThread(() =>
            {
                _nextImageView.TranslationX = width;

                _currentImageView.Animate().SetDuration(300).TranslationX(-width).Start();

                _animator = _nextImageView.Animate().SetDuration(300).TranslationX(0).SetListener(_listener);
                _animator.Start();
            });
        }
Ejemplo n.º 12
0
        private static Task RunAnimationAsync(
            ViewPropertyAnimator animator)
        {
            if (null == animator)
            {
                throw new ArgumentNullException(nameof(animator));
            }

            AsyncAnimatorListener listener = new AsyncAnimatorListener();

            animator.SetListener(listener);
            animator.Start();

            return(listener.Task);
        }
Ejemplo n.º 13
0
        private void RunCountdown(int countdownTime, Action onFinished)
        {
            UpdateCountdownLabel(countdownTime);
            ViewPropertyAnimator animator = _label.Animate().ScaleX(0).ScaleY(0).Alpha(0.0f).SetDuration(1000);

            if (countdownTime > 0)
            {
                animator.WithEndAction(new Runnable(() => RunCountdown(countdownTime - 1, onFinished)));
            }
            else
            {
                animator.WithStartAction(new Runnable(onFinished));
                animator.WithEndAction(new Runnable(() => _label.Visibility = ViewStates.Visible));
            }
            animator.Start();
        }
Ejemplo n.º 14
0
        public void OnClickClose(View view)
        {
            listFragment.ListView.ClearChoices();
            listFragment.ListView.RequestLayout();
            videoFragment.Pause();
            ViewPropertyAnimator animator = videoBox.Animate().TranslationYBy(videoBox.Height).SetDuration(ANIMATION_DURATION_MILLIS);

            animator.SetListener(new AinimatorListener()
            {
                AnimatorEnd = (a) =>
                {
                    if (videoBox.Height < 0)
                    {
                        videoBox.Visibility = ViewStates.Gone;
                    }
                }
            });
        }
Ejemplo n.º 15
0
        public FlashBarController(View flashBarView)
        {
            barView     = flashBarView;
            barAnimator = barView.Animate();

            messageView = barView.FindViewById <TextView> (Resource.Id.flashbar_message);
            var flashBarBtn = barView.FindViewById <Button> (Resource.Id.flashbar_button);

            flashBarBtn.Click += delegate {
                HideBar(false);
                if (flashBarCallback != null)
                {
                    flashBarCallback();
                }
            };
            hideRunnable = () => HideBar(false);

            HideBar(true);
        }
Ejemplo n.º 16
0
        private void SetVisibility(bool isVisible, bool animate = true)
        {
            if (animate)
            {
                if (isVisible)
                {
                    if (_fadeInAnimation != null)
                    {
                        return; // Already fading in
                    }

                    if (_fadeOutAnimation != null)
                    {
                        _fadeOutAnimation.Cancel();
                        _fadeOutAnimation = null;
                    }

                    _fadeInAnimation = _northArrow.Animate().Alpha(1f).SetDuration(250).WithEndAction(new Java.Lang.Runnable(() => { _fadeInAnimation = null; }));
                }
                else
                {
                    if (_fadeOutAnimation != null)
                    {
                        return; // Already fading out
                    }

                    if (_fadeInAnimation != null)
                    {
                        _fadeInAnimation.Cancel();
                        _fadeInAnimation = null;
                    }

                    _fadeOutAnimation = _northArrow.Animate().Alpha(0f).SetDuration(250).WithEndAction(new Java.Lang.Runnable(() => { _fadeOutAnimation = null; }));
                }
            }
            else
            {
                _northArrow.Alpha = isVisible ? 1f : .0f;
            }
        }
Ejemplo n.º 17
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.ViewPropertyAnimator);

            var container       = FindViewById <LinearLayout>(Resource.Id.container);
            var animatingButton = FindViewById <Button>(Resource.Id.animatingButton);

            FindViewById(Resource.Id.fadeOut).Click += delegate
            {
                ViewPropertyAnimator.Animate(animatingButton).Alpha(0);
            };

            FindViewById(Resource.Id.fadeIn).Click += delegate
            {
                ViewPropertyAnimator.Animate(animatingButton).Alpha(1);
            };

            FindViewById(Resource.Id.moveOver).Click += delegate
            {
                int xValue = container.Width - animatingButton.Width;
                int yValue = container.Height - animatingButton.Height;
                ViewPropertyAnimator.Animate(animatingButton).X(xValue).Y(yValue);
            };

            FindViewById(Resource.Id.moveBack).Click += delegate
            {
                ViewPropertyAnimator.Animate(animatingButton).X(0).Y(0);
            };

            FindViewById(Resource.Id.rotate).Click += delegate
            {
                ViewPropertyAnimator.Animate(animatingButton).RotationYBy(720);
            };

            // Set long default duration for the animator, for the purposes of this demo
            ViewPropertyAnimator.Animate(animatingButton).SetDuration(2000);
        }
Ejemplo n.º 18
0
 public static void BackAndForthX(this ViewPropertyAnimator TheAnimator, Activity ParentActivity, float First = 1.1F, float Then = 1.0F, long Duration = 300)
 {
     TheAnimator.ScaleX(First).SetDuration(Duration).Start();
     Task.Delay(300).ContinueWith((task) => ParentActivity.RunOnUiThread(() => TheAnimator.ScaleX(Then).Start()));
 }
Ejemplo n.º 19
0
        Task <bool> SwitchContentAsync(Page view, bool animated, bool removed = false)
        {
            Context.HideKeyboard(this);

            IVisualElementRenderer rendererToAdd = Platform.GetRenderer(view);
            bool existing = rendererToAdd != null;

            if (!existing)
            {
                Platform.SetRenderer(view, rendererToAdd = Platform.CreateRenderer(view));
            }

            Page pageToRemove = _current;
            IVisualElementRenderer rendererToRemove  = pageToRemove == null ? null : Platform.GetRenderer(pageToRemove);
            PageContainer          containerToRemove = rendererToRemove == null ? null : (PageContainer)rendererToRemove.ViewGroup.Parent;
            PageContainer          containerToAdd    = (PageContainer)rendererToAdd.ViewGroup.Parent ?? new PageContainer(Context, rendererToAdd);

            containerToAdd.SetWindowBackground();

            _current = view;

            ((Platform)Element.Platform).NavAnimationInProgress = true;

            var tcs = new TaskCompletionSource <bool>();

            if (animated)
            {
                if (s_currentAnimation != null)
                {
                    s_currentAnimation.Cancel();
                }

                if (removed)
                {
                    // animate out
                    if (containerToAdd.Parent != this)
                    {
                        AddView(containerToAdd, Element.LogicalChildren.IndexOf(rendererToAdd.Element));
                    }
                    else
                    {
                        ((Page)rendererToAdd.Element).SendAppearing();
                    }
                    containerToAdd.Visibility = ViewStates.Visible;

                    if (containerToRemove != null)
                    {
                        Action <AndroidAnimation.Animator> done = a =>
                        {
                            containerToRemove.Visibility = ViewStates.Gone;
                            containerToRemove.Alpha      = 1;
                            containerToRemove.ScaleX     = 1;
                            containerToRemove.ScaleY     = 1;
                            RemoveView(containerToRemove);

                            tcs.TrySetResult(true);
                            ((Platform)Element.Platform).NavAnimationInProgress = false;

                            VisualElement removedElement = rendererToRemove.Element;
                            rendererToRemove.Dispose();
                            if (removedElement != null)
                            {
                                Platform.SetRenderer(removedElement, null);
                            }
                        };

                        // should always happen
                        s_currentAnimation = containerToRemove.Animate().Alpha(0).ScaleX(0.8f).ScaleY(0.8f).SetDuration(250).SetListener(new GenericAnimatorListener {
                            OnEnd = a =>
                            {
                                s_currentAnimation = null;
                                done(a);
                            },
                            OnCancel = done
                        });
                    }
                }
                else
                {
                    bool containerAlreadyAdded = containerToAdd.Parent == this;
                    // animate in
                    if (!containerAlreadyAdded)
                    {
                        AddView(containerToAdd);
                    }
                    else
                    {
                        ((Page)rendererToAdd.Element).SendAppearing();
                    }

                    if (existing)
                    {
                        Element.ForceLayout();
                    }

                    containerToAdd.Alpha      = 0;
                    containerToAdd.ScaleX     = containerToAdd.ScaleY = 0.8f;
                    containerToAdd.Visibility = ViewStates.Visible;
                    s_currentAnimation        = containerToAdd.Animate().Alpha(1).ScaleX(1).ScaleY(1).SetDuration(250).SetListener(new GenericAnimatorListener {
                        OnEnd = a =>
                        {
                            if (containerToRemove != null && containerToRemove.Handle != IntPtr.Zero)
                            {
                                containerToRemove.Visibility = ViewStates.Gone;
                                if (pageToRemove != null)
                                {
                                    pageToRemove.SendDisappearing();
                                }
                            }
                            s_currentAnimation = null;
                            tcs.TrySetResult(true);
                            ((Platform)Element.Platform).NavAnimationInProgress = false;
                        }
                    });
                }
            }
            else
            {
                // just do it fast
                if (containerToRemove != null)
                {
                    if (removed)
                    {
                        RemoveView(containerToRemove);
                    }
                    else
                    {
                        containerToRemove.Visibility = ViewStates.Gone;
                    }
                }

                if (containerToAdd.Parent != this)
                {
                    AddView(containerToAdd);
                }
                else
                {
                    ((Page)rendererToAdd.Element).SendAppearing();
                }

                if (containerToRemove != null && !removed)
                {
                    pageToRemove.SendDisappearing();
                }

                if (existing)
                {
                    Element.ForceLayout();
                }

                containerToAdd.Visibility = ViewStates.Visible;
                tcs.SetResult(true);
                ((Platform)Element.Platform).NavAnimationInProgress = false;
            }

            return(tcs.Task);
        }
Ejemplo n.º 20
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.LockScreen2);
            ThreadPool.QueueUserWorkItem(isApphealthy =>
            {
                if (Checkers.IsNotificationListenerEnabled() == false || Checkers.IsThisAppADeviceAdministrator() == false)
                {
                    RunOnUiThread(() =>
                    {
                        Toast.MakeText(Application.Context, "You dont have the required permissions", ToastLength.Long).Show();
                        Finish();
                    }
                                  );
                }
            });

            startCamera          = FindViewById <Button>(Resource.Id.btnStartCamera);
            startDialer          = FindViewById <Button>(Resource.Id.btnStartPhone);
            clearAll             = FindViewById <Button>(Resource.Id.btnClearAllNotifications);
            lockscreen           = FindViewById <LinearLayout>(Resource.Id.contenedorPrincipal);
            viewPropertyAnimator = Window.DecorView.Animate();
            viewPropertyAnimator.SetListener(new LockScreenAnimationHelper(Window));
            livedisplayinfo            = FindViewById <TextView>(Resource.Id.livedisplayinfo);
            livedisplayinfo.Visibility = ViewStates.Gone;  //You won't be seeing this anymore.

            fadeoutanimation = AnimationUtils.LoadAnimation(Application.Context, Resource.Animation.abc_fade_out);
            fadeoutanimation.AnimationEnd += Fadeoutanimation_AnimationEnd;

            clearAll.Click    += BtnClearAll_Click;
            startCamera.Click += StartCamera_Click;
            startDialer.Click += StartDialer_Click;
            lockscreen.Touch  += Lockscreen_Touch;

            watchDog = new System.Timers.Timer
            {
                AutoReset = false
            };
            watchDog.Elapsed += WatchdogInterval_Elapsed;

            halfscreenheight = Resources.DisplayMetrics.HeightPixels / 2;

            WallpaperPublisher.NewWallpaperIssued += Wallpaper_NewWallpaperIssued;

            //CatcherHelper events
            CatcherHelper.NotificationListSizeChanged += CatcherHelper_NotificationListSizeChanged;

            using (recycler = FindViewById <RecyclerView>(Resource.Id.NotificationListRecyclerView))
            {
                using (layoutManager = new LinearLayoutManager(Application.Context))
                {
                    recycler.SetLayoutManager(layoutManager);
                    recycler.SetAdapter(CatcherHelper.notificationAdapter);
                }
            }
            LoadAllFragments();
            LoadConfiguration();

            WallpaperPublisher.CurrentWallpaperCleared  += WallpaperPublisher_CurrentWallpaperCleared;
            WidgetStatusPublisher.OnWidgetStatusChanged += WidgetStatusPublisher_OnWidgetStatusChanged;
        }