/* * (non-Javadoc) * * @see android.app.Activity#onCreate(android.os.Bundle) */ protected override void OnCreate(Bundle bundle) { if (Intent != null) { Bundle extras = Intent.Extras; if (extras != null) { int theme = extras.GetInt("theme"); if (theme != 0) { SetTheme(theme); } } } base.OnCreate(bundle); SetContentView(Resource.Layout.Main); holoCircularProgressBar = FindViewById <LibraryHoloCircularProgressBar.HoloCircularProgressBar> (Resource.Id.holoCircularProgressBar); btnRandomColor = FindViewById <Button> (Resource.Id.btnRandomColor); btnRandomColor.Click += (object sender, EventArgs e) => { SwitchColor(); }; btnZero = FindViewById <Button> (Resource.Id.btnZero); btnZero.Click += (object sender, EventArgs e) => { if (_progressBarAnimator != null) { _progressBarAnimator.Cancel(); } Animate(holoCircularProgressBar, null, 0f, 1000); holoCircularProgressBar.SetMarkerProgress(0f); }; btnOne = FindViewById <Button> (Resource.Id.btnOne); btnOne.Click += (object sender, EventArgs e) => { if (_progressBarAnimator != null) { _progressBarAnimator.Cancel(); } Animate(holoCircularProgressBar, null, 1f, 1000); holoCircularProgressBar.SetMarkerProgress(1f); }; togAnimation = FindViewById <ToggleButton> (Resource.Id.togAnimation); togAnimation.SetOnCheckedChangeListener(this); }
public void Stop() { if (!IsRunning) { return; } _running = false; _objectAnimatorAngle.Cancel(); _objectAnimatorSweep.Cancel(); InvalidateSelf(); }
void ClearAnimation() { if (_animator == null) { return; } _animator.AnimationEnd -= AnimationOnAnimationEnd; _animator.Cancel(); _animator.Dispose(); _animator = null; }
private void ClearAnimation() { if (animation == null) { return; } animation.AnimationEnd -= AnimationOnAnimationEnd; animation.Cancel(); animation.Dispose(); animation = null; }
public void StopAnimating() { if (animator != null) { animator.Cancel(); animator = null; } MainLogContentView.TranslationX = 0; mainLogBackgroundContinue.Visibility = ViewStates.Invisible; mainLogBackgroundDelete.Visibility = ViewStates.Invisible; }
private void ClearAnimation() { if (null == animator) { return; } animator.AnimationEnd -= AnimationOnAnimationEnd; animator.Cancel(); animator.Dispose(); animator = null; }
public void AnimateCircular(float toValue, int milliseconds = 500, ITimeInterpolator interpolator = null) { if (animator != null) { animator.Cancel(); } animator = ObjectAnimator.OfFloat(this, "Progress", 0.0f, toValue); if (interpolator != null) { animator.SetInterpolator(interpolator); } animator.SetDuration(milliseconds); animator.RepeatMode = ValueAnimatorRepeatMode.Restart; animator.Start(); }
/** * Animate enter toolbarlayout * * @param yOffset */ private void AnimateEnterToolbarLayout() { if (!FollowScrollToolbarIsVisible && _headerAnimator != null) { ObjectAnimator objectAnimator = _headerAnimator as ObjectAnimator; if (objectAnimator != null) { objectAnimator.Cancel(); } else { Android.Animation.ObjectAnimator androidObjectAnimator = _headerAnimator as Android.Animation.ObjectAnimator; if (androidObjectAnimator != null) { androidObjectAnimator.Cancel(); } } _headerAnimator = null; } if (_headerAnimator == null) { if (Build.VERSION.SdkInt > BuildVersionCodes.GingerbreadMr1) { _headerAnimator = Android.Animation.ObjectAnimator.OfFloat(_mHeader.ToolbarLayout, "translationY", 0).SetDuration(_enterToolbarAnimationDuration); Android.Animation.ObjectAnimator animator = (Android.Animation.ObjectAnimator)_headerAnimator; animator.AnimationEnd += (sender, args) => { FollowScrollToolbarIsVisible = true; FirstScrollValue = float.MinValue; JustToolbarAnimated = true; }; animator.Start(); } else { _headerAnimator = ObjectAnimator.OfFloat(_mHeader.ToolbarLayout, "translationY", 0).SetDuration(_enterToolbarAnimationDuration); ObjectAnimator animator = (ObjectAnimator)_headerAnimator; animator.AddListener(new AnimatorListener(this)); animator.Start(); } } }
void ShowSwipeDown() { if (!setup) { ActionBar.Hide(); if (bar1Fade != null) { bar1Fade.Cancel(); bar1Fade = null; } if (bar2Fade != null) { bar2Fade.Cancel(); bar2Fade = null; } loadingBars.Visibility = ViewStates.Visible; swipeText.TranslationY = -(ActionBar.Height + swipeText.Height + 4); swipeText.Visibility = ViewStates.Visible; swipeText.Animate().TranslationY(0).SetStartDelay(50).Start(); accumulatedDeltaY = 0; setup = true; } }
/** * 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)); } }) ); }
/// <summary> /// Stop indeterminate animation to convert view in determinate progress bar /// </summary> private void StopIndeterminate() { animation.Cancel(); ViewHelper.SetX(progressView, 0); runAnimation = false; }
/** * Called when a scroller(RecyclerView/ListView,ScrollView,WebView) scrolled by the user * * @param source the scroller * @param yOffset the scroller current yOffset */ public bool OnMaterialScrolled(Object source, float yOffset) { if (_initialDistance == -1 || _initialDistance == 0) { _initialDistance = _mHeader.MPagerSlidingTabStrip.Top - _mHeader.Toolbar.Bottom; } //only if yOffset changed if (yOffset == LastYOffset) { return(false); } float scrollTop = -yOffset; { //parallax scroll of the Background ImageView (the KenBurnsView) if (_mHeader.HeaderBackground != null) { if (Settings.ParallaxHeaderFactor != 0) { ViewHelper.SetTranslationY(_mHeader.HeaderBackground, scrollTop / Settings.ParallaxHeaderFactor); } if (ViewHelper.GetY(_mHeader.HeaderBackground) >= 0) { ViewHelper.SetY(_mHeader.HeaderBackground, 0); } } } if (EnableLog) { Log.Debug("yOffset", "" + yOffset); } //dispatch the new offset to all registered scrollables DispatchScrollOffset(source, Utils.MinMax(0, yOffset, ScrollMaxDp)); //distance between pager & toolbar float newDistance = ViewHelper.GetY(_mHeader.MPagerSlidingTabStrip) - _mHeader.Toolbar.Bottom; float percent = 1 - newDistance / _initialDistance; if (float.IsNaN(percent)) //fix for orientation change { return(false); } percent = Utils.MinMax(0, percent, 1); { if (!Settings.ToolbarTransparent) { // change color of toolbar & viewpager indicator & statusBaground SetColorPercent(percent); } else { if (JustToolbarAnimated) { if (ToolbarJoinsTabs()) { SetColorPercent(1); } else if (LastPercent != percent) { AnimateColorPercent(0, 200); } } } LastPercent = percent; //save the percent if (_mHeader.MPagerSlidingTabStrip != null) { //move the viewpager indicator //float newY = ViewHelper.getY(mHeader.mPagerSlidingTabStrip) + scrollTop; if (EnableLog) { Log.Debug(_tag, "" + scrollTop); } //mHeader.mPagerSlidingTabStrip.setTranslationY(mHeader.getToolbar().getBottom()-mHeader.mPagerSlidingTabStrip.getY()); if (scrollTop <= 0) { ViewHelper.SetTranslationY(_mHeader.MPagerSlidingTabStrip, scrollTop); ViewHelper.SetTranslationY(_mHeader.ToolbarLayoutBackground, scrollTop); //when if (ViewHelper.GetY(_mHeader.MPagerSlidingTabStrip) < _mHeader.GetToolbar().Bottom) { float ty = _mHeader.GetToolbar().Bottom - _mHeader.MPagerSlidingTabStrip.Top; ViewHelper.SetTranslationY(_mHeader.MPagerSlidingTabStrip, ty); ViewHelper.SetTranslationY(_mHeader.ToolbarLayoutBackground, ty); } } } if (_mHeader.MLogo != null) { //move the header logo to toolbar if (Settings.HideLogoWithFade) { ViewHelper.SetAlpha(_mHeader.MLogo, 1 - percent); ViewHelper.SetTranslationY(_mHeader.MLogo, (_mHeader.FinalTitleY - _mHeader.OriginalTitleY) * percent); } else { ViewHelper.SetTranslationY(_mHeader.MLogo, (_mHeader.FinalTitleY - _mHeader.OriginalTitleY) * percent); ViewHelper.SetTranslationX(_mHeader.MLogo, (_mHeader.FinalTitleX - _mHeader.OriginalTitleX) * percent); float scale = (1 - percent) * (1 - _mHeader.FinalScale) + _mHeader.FinalScale; Utils.SetScale(scale, _mHeader.MLogo); } } if (Settings.HideToolbarAndTitle && _mHeader.ToolbarLayout != null) { bool scrollUp = LastYOffset < yOffset; if (scrollUp) { ScrollUp(yOffset); } else { ScrollDown(yOffset); } } } if (_headerAnimator != null && percent < 1) { ObjectAnimator objectAnimator = _headerAnimator as ObjectAnimator; if (objectAnimator != null) { objectAnimator.Cancel(); } else { Android.Animation.ObjectAnimator androidAnimator = _headerAnimator as Android.Animation.ObjectAnimator; if (androidAnimator != null) { androidAnimator.Cancel(); } } _headerAnimator = null; } LastYOffset = yOffset; return(true); }