Search in sources :

Example 96 with AnimatorUpdateListener

use of android.animation.ValueAnimator.AnimatorUpdateListener in project android_packages_apps_Dialer by MoKee.

the class ActionBarController method slideActionBar.

public void slideActionBar(boolean slideUp, boolean animate) {
    if (DEBUG) {
        Log.d(TAG, "Sliding actionBar - up: " + slideUp + " animate: " + animate);
    }
    if (animate) {
        ValueAnimator animator = slideUp ? ValueAnimator.ofFloat(0, 1) : ValueAnimator.ofFloat(1, 0);
        animator.addUpdateListener(new AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                final float value = (float) animation.getAnimatedValue();
                setHideOffset((int) (mActivityUi.getActionBarHeight() * value));
            }
        });
        animator.start();
    } else {
        setHideOffset(slideUp ? mActivityUi.getActionBarHeight() : 0);
    }
    mIsActionBarSlidUp = slideUp;
}
Also used : AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator)

Example 97 with AnimatorUpdateListener

use of android.animation.ValueAnimator.AnimatorUpdateListener in project Xposed-Tinted-Status-Bar by MohammadAG.

the class OverlayDrawable method setOverrideColor.

public void setOverrideColor(final int color) {
    int animateFrom;
    final int animateTo;
    if (mOverrideColor != -3) {
        animateFrom = mOverrideColor;
    } else {
        animateFrom = mColor;
    }
    if (color == -3) {
        animateTo = mColor;
    } else {
        animateTo = color;
    }
    if (mAnimator != null && mAnimator.isRunning()) {
        mAnimator.cancel();
        animateFrom = mOverrideColor;
        mAnimator = null;
    }
    mAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), animateFrom, animateTo);
    mAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            mOverrideColor = (Integer) animator.getAnimatedValue();
            invalidateSelf();
        }
    });
    mAnimator.addListener(new AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (color == -3) {
                mOverrideColor = -3;
                mColor = animateTo;
                invalidateSelf();
            }
            mAnimator = null;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }
    });
    mAnimator.start();
}
Also used : AnimatorListener(android.animation.Animator.AnimatorListener) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) ArgbEvaluator(android.animation.ArgbEvaluator) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator) Paint(android.graphics.Paint)

Example 98 with AnimatorUpdateListener

use of android.animation.ValueAnimator.AnimatorUpdateListener in project Xposed-Tinted-Status-Bar by MohammadAG.

the class ColourChangerMod method setStatusBarTint.

@SuppressLint("NewApi")
public void setStatusBarTint(final int tintColor) {
    if (mStatusBarView == null)
        return;
    log("Setting statusbar color to " + tintColor);
    if (mSettingsHelper.animateStatusBarTintChange()) {
        int animateFrom = mLastSetColor == KITKAT_TRANSPARENT_COLOR ? Color.TRANSPARENT : mLastSetColor;
        int animateTo = tintColor == KITKAT_TRANSPARENT_COLOR ? Color.TRANSPARENT : tintColor;
        ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), animateFrom, animateTo);
        colorAnimation.addUpdateListener(new AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animator) {
                mGradientDrawable.setColor((Integer) animator.getAnimatedValue());
            }
        });
        Utils.setViewBackground(mStatusBarView, mGradientDrawable);
        colorAnimation.start();
    } else {
        mStatusBarView.setAlpha(1f);
        if (tintColor == KITKAT_TRANSPARENT_COLOR) {
            Utils.setViewBackground(mStatusBarView, mGradientDrawable);
            mGradientDrawable.setColor(Color.TRANSPARENT);
        } else {
            Utils.setViewBackground(mStatusBarView, mGradientDrawable);
            mGradientDrawable.setColor(tintColor);
        }
    }
    mGradientDrawable.setMode(mSettingsHelper.getOverlayMode(), mSettingsHelper.getSemiTransparentOverlayOpacity());
    mGradientDrawable.setIsTransparentCauseOfKitKatApi(tintColor == KITKAT_TRANSPARENT_COLOR && mSettingsHelper.isLegacyGradientMode());
    mLastSetColor = tintColor;
    if (mSettingsHelper.shouldLinkStatusBarAndNavBar() && !mKeyboardUp) {
        mNavigationBarTint = tintColor;
        setNavigationBarTint(tintColor, true);
    }
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator) SuppressLint(android.annotation.SuppressLint) Tint(com.mohammadag.colouredstatusbar.SettingsHelper.Tint) SuppressLint(android.annotation.SuppressLint)

Example 99 with AnimatorUpdateListener

use of android.animation.ValueAnimator.AnimatorUpdateListener in project Launcher3 by chislon.

the class AppWidgetResizeFrame method snapToWidget.

public void snapToWidget(boolean animate) {
    final DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
    int newWidth = mWidgetView.getWidth() + 2 * mBackgroundPadding - mWidgetPaddingLeft - mWidgetPaddingRight;
    int newHeight = mWidgetView.getHeight() + 2 * mBackgroundPadding - mWidgetPaddingTop - mWidgetPaddingBottom;
    mTmpPt[0] = mWidgetView.getLeft();
    mTmpPt[1] = mWidgetView.getTop();
    mDragLayer.getDescendantCoordRelativeToSelf(mCellLayout.getShortcutsAndWidgets(), mTmpPt);
    int newX = mTmpPt[0] - mBackgroundPadding + mWidgetPaddingLeft;
    int newY = mTmpPt[1] - mBackgroundPadding + mWidgetPaddingTop;
    // down accordingly to provide a proper touch target.
    if (newY < 0) {
        // In this case we shift the touch region down to start at the top of the DragLayer
        mTopTouchRegionAdjustment = -newY;
    } else {
        mTopTouchRegionAdjustment = 0;
    }
    if (newY + newHeight > mDragLayer.getHeight()) {
        // In this case we shift the touch region up to end at the bottom of the DragLayer
        mBottomTouchRegionAdjustment = -(newY + newHeight - mDragLayer.getHeight());
    } else {
        mBottomTouchRegionAdjustment = 0;
    }
    if (!animate) {
        lp.width = newWidth;
        lp.height = newHeight;
        lp.x = newX;
        lp.y = newY;
        mLeftHandle.setAlpha(1.0f);
        mRightHandle.setAlpha(1.0f);
        mTopHandle.setAlpha(1.0f);
        mBottomHandle.setAlpha(1.0f);
        requestLayout();
    } else {
        PropertyValuesHolder width = PropertyValuesHolder.ofInt("width", lp.width, newWidth);
        PropertyValuesHolder height = PropertyValuesHolder.ofInt("height", lp.height, newHeight);
        PropertyValuesHolder x = PropertyValuesHolder.ofInt("x", lp.x, newX);
        PropertyValuesHolder y = PropertyValuesHolder.ofInt("y", lp.y, newY);
        ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(lp, this, width, height, x, y);
        ObjectAnimator leftOa = LauncherAnimUtils.ofFloat(mLeftHandle, "alpha", 1.0f);
        ObjectAnimator rightOa = LauncherAnimUtils.ofFloat(mRightHandle, "alpha", 1.0f);
        ObjectAnimator topOa = LauncherAnimUtils.ofFloat(mTopHandle, "alpha", 1.0f);
        ObjectAnimator bottomOa = LauncherAnimUtils.ofFloat(mBottomHandle, "alpha", 1.0f);
        oa.addUpdateListener(new AnimatorUpdateListener() {

            public void onAnimationUpdate(ValueAnimator animation) {
                requestLayout();
            }
        });
        AnimatorSet set = LauncherAnimUtils.createAnimatorSet();
        if (mResizeMode == AppWidgetProviderInfo.RESIZE_VERTICAL) {
            set.playTogether(oa, topOa, bottomOa);
        } else if (mResizeMode == AppWidgetProviderInfo.RESIZE_HORIZONTAL) {
            set.playTogether(oa, leftOa, rightOa);
        } else {
            set.playTogether(oa, leftOa, rightOa, topOa, bottomOa);
        }
        set.setDuration(SNAP_DURATION);
        set.start();
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) PropertyValuesHolder(android.animation.PropertyValuesHolder) AnimatorSet(android.animation.AnimatorSet) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator)

Example 100 with AnimatorUpdateListener

use of android.animation.ValueAnimator.AnimatorUpdateListener in project NotificationPeekPort by lzanita09.

the class SwipeHelper method snapChild.

public void snapChild(final View view, float velocity) {
    final View animView = mCallback.getChildContentView(view);
    final boolean canAnimViewBeDismissed = mCallback.canChildBeDismissed(animView);
    ObjectAnimator anim = createTranslationAnimation(animView, 0);
    anim.setInterpolator(new OvershootInterpolator(2.5f));
    int duration = OVERSHOOT_DURATION;
    anim.setDuration(duration);
    anim.addUpdateListener(new AnimatorUpdateListener() {

        public void onAnimationUpdate(ValueAnimator animation) {
            updateAlphaFromOffset(animView, canAnimViewBeDismissed);
        }
    });
    anim.addListener(new AnimatorListenerAdapter() {

        public void onAnimationEnd(Animator animator) {
            updateAlphaFromOffset(animView, canAnimViewBeDismissed);
        }
    });
    anim.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) OvershootInterpolator(android.view.animation.OvershootInterpolator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator) View(android.view.View)

Aggregations

AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)118 ValueAnimator (android.animation.ValueAnimator)111 Animator (android.animation.Animator)74 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)69 ObjectAnimator (android.animation.ObjectAnimator)37 View (android.view.View)17 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)17 TimeInterpolator (android.animation.TimeInterpolator)16 Interpolator (android.view.animation.Interpolator)14 SuppressLint (android.annotation.SuppressLint)10 Resources (android.content.res.Resources)9 AnimatorListener (android.animation.Animator.AnimatorListener)8 AnimatorSet (android.animation.AnimatorSet)8 TextView (android.widget.TextView)8 ArgbEvaluator (android.animation.ArgbEvaluator)7 PropertyValuesHolder (android.animation.PropertyValuesHolder)7 Rect (android.graphics.Rect)7 ImageView (android.widget.ImageView)7 AppWidgetHostView (android.appwidget.AppWidgetHostView)6 Paint (android.graphics.Paint)6