Search in sources :

Example 6 with AnticipateInterpolator

use of android.view.animation.AnticipateInterpolator in project sentinel-android by Samourai-Wallet.

the class BalanceActivity method rotateTxStatus.

private void rotateTxStatus(View view, boolean clockwise) {
    float degrees = 360f;
    if (!clockwise) {
        degrees = -360f;
    }
    ObjectAnimator animation = ObjectAnimator.ofFloat(view, "rotationY", 0.0f, degrees);
    animation.setDuration(1000);
    animation.setRepeatCount(0);
    animation.setInterpolator(new AnticipateInterpolator());
    animation.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) AnticipateInterpolator(android.view.animation.AnticipateInterpolator)

Example 7 with AnticipateInterpolator

use of android.view.animation.AnticipateInterpolator in project MaterialFBook by ZeeRooo.

the class FloatingActionMenu method init.

private void init(Context context, AttributeSet attrs) {
    TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionMenu, 0, 0);
    mButtonSpacing = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_buttonSpacing, mButtonSpacing);
    mLabelsMargin = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_margin, mLabelsMargin);
    mLabelsPosition = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_position, LABELS_POSITION_LEFT);
    mLabelsShowAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_showAnimation, mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_in_from_right : R.anim.fab_slide_in_from_left);
    mLabelsHideAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_hideAnimation, mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_out_to_right : R.anim.fab_slide_out_to_left);
    mLabelsPaddingTop = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingTop, mLabelsPaddingTop);
    mLabelsPaddingRight = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingRight, mLabelsPaddingRight);
    mLabelsPaddingBottom = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingBottom, mLabelsPaddingBottom);
    mLabelsPaddingLeft = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingLeft, mLabelsPaddingLeft);
    mLabelsTextColor = attr.getColorStateList(R.styleable.FloatingActionMenu_menu_labels_textColor);
    // set default value if null same as for textview
    if (mLabelsTextColor == null) {
        mLabelsTextColor = ColorStateList.valueOf(Color.WHITE);
    }
    mLabelsTextSize = attr.getDimension(R.styleable.FloatingActionMenu_menu_labels_textSize, getResources().getDimension(R.dimen.labels_text_size));
    mLabelsCornerRadius = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_cornerRadius, mLabelsCornerRadius);
    mLabelsShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_showShadow, true);
    mLabelsColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorNormal, 0xFF333333);
    mLabelsColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorPressed, 0xFF444444);
    mLabelsColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorRipple, 0x66FFFFFF);
    mMenuShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_showShadow, true);
    mMenuShadowColor = attr.getColor(R.styleable.FloatingActionMenu_menu_shadowColor, 0x66000000);
    mMenuShadowRadius = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowRadius, mMenuShadowRadius);
    mMenuShadowXOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowXOffset, mMenuShadowXOffset);
    mMenuShadowYOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowYOffset, mMenuShadowYOffset);
    mMenuColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_colorNormal, 0xFFDA4336);
    mMenuColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_colorPressed, 0xFFE75043);
    mMenuColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_colorRipple, 0x99FFFFFF);
    mAnimationDelayPerItem = attr.getInt(R.styleable.FloatingActionMenu_menu_animationDelayPerItem, 50);
    mIcon = attr.getDrawable(R.styleable.FloatingActionMenu_menu_icon);
    if (mIcon == null) {
        mIcon = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_fab_menu, null);
    }
    mLabelsSingleLine = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_singleLine, false);
    mLabelsEllipsize = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_ellipsize, 0);
    mLabelsMaxLines = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_maxLines, -1);
    mMenuFabSize = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_size, FloatingActionButton.SIZE_NORMAL);
    mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_style, 0);
    String customFont = attr.getString(R.styleable.FloatingActionMenu_menu_labels_customFont);
    try {
        if (!TextUtils.isEmpty(customFont)) {
            mCustomTypefaceFromFont = Typeface.createFromAsset(getContext().getAssets(), customFont);
        }
    } catch (RuntimeException ex) {
        throw new IllegalArgumentException("Unable to load specified custom font: " + customFont, ex);
    }
    mOpenDirection = attr.getInt(R.styleable.FloatingActionMenu_menu_openDirection, OPEN_UP);
    mBackgroundColor = attr.getColor(R.styleable.FloatingActionMenu_menu_backgroundColor, Color.TRANSPARENT);
    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_fab_label)) {
        mUsingMenuLabel = true;
        mMenuLabelText = attr.getString(R.styleable.FloatingActionMenu_menu_fab_label);
    }
    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_labels_padding)) {
        int padding = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_padding, 0);
        initPadding(padding);
    }
    mOpenInterpolator = new OvershootInterpolator();
    mCloseInterpolator = new AnticipateInterpolator();
    mLabelsContext = new ContextThemeWrapper(getContext(), mLabelsStyle);
    initBackgroundDimAnimation();
    createMenuButton();
    initMenuButtonAnimations(attr);
    attr.recycle();
}
Also used : OvershootInterpolator(android.view.animation.OvershootInterpolator) ContextThemeWrapper(android.view.ContextThemeWrapper) TypedArray(android.content.res.TypedArray) AnticipateInterpolator(android.view.animation.AnticipateInterpolator)

Example 8 with AnticipateInterpolator

use of android.view.animation.AnticipateInterpolator in project KJFrameForAndroid by kymjs.

the class KJAnimations method closeAnimation.

/**
 * 关闭的动画
 *
 * @param relativeLayout
 *            子菜单容器
 * @param background
 *            子菜单背景
 * @param menu
 *            菜单按钮
 * @param durationMillis
 *            动画时间
 */
public static void closeAnimation(final RelativeLayout relativeLayout, final ImageView menu, long durationMillis) {
    for (int i = 1; i < relativeLayout.getChildCount(); i++) {
        ImageView imageView = null;
        if (relativeLayout.getChildAt(i) instanceof ImageView) {
            imageView = (ImageView) relativeLayout.getChildAt(i);
        } else {
            continue;
        }
        AnimationSet set = new AnimationSet(true);
        set.addAnimation(getRotateAnimation(0, -360, durationMillis));
        set.addAnimation(getAlphaAnimation(1.0f, 0.5f, durationMillis));
        set.addAnimation(getTranslateAnimation(0, menu.getLeft() - imageView.getLeft(), 0, menu.getTop() - imageView.getTop(), durationMillis));
        set.setFillAfter(true);
        set.setDuration(durationMillis);
        set.setStartOffset(((relativeLayout.getChildCount() - i) * 100) / (-1 + relativeLayout.getChildCount()));
        set.setInterpolator(new AnticipateInterpolator(1f));
        set.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation arg0) {
            }

            @Override
            public void onAnimationRepeat(Animation arg0) {
            }

            @Override
            public void onAnimationEnd(Animation arg0) {
                relativeLayout.setVisibility(View.GONE);
            }
        });
        imageView.startAnimation(set);
    }
}
Also used : ScaleAnimation(android.view.animation.ScaleAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) RotateAnimation(android.view.animation.RotateAnimation) ImageView(android.widget.ImageView) AnimationSet(android.view.animation.AnimationSet) AnticipateInterpolator(android.view.animation.AnticipateInterpolator)

Example 9 with AnticipateInterpolator

use of android.view.animation.AnticipateInterpolator in project ChatExchange by HueToYou.

the class FloatingActionMenu method init.

private void init(Context context, AttributeSet attrs) {
    TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionMenu, 0, 0);
    mOpenRotationLeft = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_open_rotation_left, (int) OPENED_PLUS_ROTATION_LEFT);
    mOpenRotationRight = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_open_rotation_right, (int) OPENED_PLUS_ROTATION_RIGHT);
    mAnimationDuration = attr.getInt((int) getAnimDuration(R.styleable.FloatingActionMenu_menu_fab_animation_duration, context), (int) getAnimDuration(ANIMATION_DURATION, context));
    mButtonSpacing = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_buttonSpacing, mButtonSpacing);
    mLabelsMargin = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_margin, mLabelsMargin);
    mLabelsPosition = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_position, LABELS_POSITION_LEFT);
    mLabelsShowAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_showAnimation, mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_in_from_right : R.anim.fab_slide_in_from_left);
    mLabelsHideAnimation = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_hideAnimation, mLabelsPosition == LABELS_POSITION_LEFT ? R.anim.fab_slide_out_to_right : R.anim.fab_slide_out_to_left);
    mLabelsPaddingTop = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingTop, mLabelsPaddingTop);
    mLabelsPaddingRight = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingRight, mLabelsPaddingRight);
    mLabelsPaddingBottom = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingBottom, mLabelsPaddingBottom);
    mLabelsPaddingLeft = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingLeft, mLabelsPaddingLeft);
    mLabelsTextColor = attr.getColorStateList(R.styleable.FloatingActionMenu_menu_labels_textColor);
    // set default value if null same as for textview
    if (mLabelsTextColor == null) {
        mLabelsTextColor = ColorStateList.valueOf(Color.WHITE);
    }
    mLabelsTextSize = attr.getDimension(R.styleable.FloatingActionMenu_menu_labels_textSize, getResources().getDimension(R.dimen.labels_text_size));
    mLabelsCornerRadius = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_cornerRadius, mLabelsCornerRadius);
    mLabelsShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_showShadow, true);
    mLabelsColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorNormal, 0xFF333333);
    mLabelsColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorPressed, 0xFF444444);
    mLabelsColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_colorRipple, 0x66FFFFFF);
    mMenuShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_showShadow, true);
    mMenuShadowColor = attr.getColor(R.styleable.FloatingActionMenu_menu_shadowColor, 0x66000000);
    mMenuShadowRadius = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowRadius, mMenuShadowRadius);
    mMenuShadowXOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowXOffset, mMenuShadowXOffset);
    mMenuShadowYOffset = attr.getDimension(R.styleable.FloatingActionMenu_menu_shadowYOffset, mMenuShadowYOffset);
    mMenuColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_colorNormal, 0xFFDA4336);
    mMenuColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_colorPressed, 0xFFE75043);
    mMenuColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_colorRipple, 0x99FFFFFF);
    mAnimationDelayPerItem = attr.getInt(R.styleable.FloatingActionMenu_menu_animationDelayPerItem, 50);
    try {
        mIcon = VectorDrawableCompat.create(attr.getResources(), attr.getResourceId(R.styleable.FloatingActionMenu_menu_icon, R.drawable.fab_add), null);
    } catch (Resources.NotFoundException e) {
        e.printStackTrace();
        mIcon = getResources().getDrawable(R.drawable.fab_add);
    }
    mLabelsSingleLine = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_singleLine, false);
    mLabelsEllipsize = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_ellipsize, 0);
    mLabelsMaxLines = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_maxLines, -1);
    mMenuFabSize = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_size, FloatingActionButton.SIZE_NORMAL);
    mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_style, 0);
    String customFont = attr.getString(R.styleable.FloatingActionMenu_menu_labels_customFont);
    try {
        if (!TextUtils.isEmpty(customFont)) {
            mCustomTypefaceFromFont = Typeface.createFromAsset(getContext().getAssets(), customFont);
        }
    } catch (RuntimeException ex) {
        throw new IllegalArgumentException("Unable to load specified custom font: " + customFont, ex);
    }
    mOpenDirection = attr.getInt(R.styleable.FloatingActionMenu_menu_openDirection, OPEN_UP);
    mBackgroundColor = attr.getColor(R.styleable.FloatingActionMenu_menu_backgroundColor, Color.TRANSPARENT);
    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_fab_label)) {
        mUsingMenuLabel = true;
        mMenuLabelText = attr.getString(R.styleable.FloatingActionMenu_menu_fab_label);
    }
    if (attr.hasValue(R.styleable.FloatingActionMenu_menu_labels_padding)) {
        int padding = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_padding, 0);
        initPadding(padding);
    }
    mOpenInterpolator = new OvershootInterpolator();
    mCloseInterpolator = new AnticipateInterpolator();
    mLabelsContext = new ContextThemeWrapper(getContext(), mLabelsStyle);
    initBackgroundDimAnimation();
    createMenuButton();
    initMenuButtonAnimations(attr);
    attr.recycle();
}
Also used : OvershootInterpolator(android.view.animation.OvershootInterpolator) ContextThemeWrapper(android.view.ContextThemeWrapper) TypedArray(android.content.res.TypedArray) Resources(android.content.res.Resources) AnticipateInterpolator(android.view.animation.AnticipateInterpolator)

Example 10 with AnticipateInterpolator

use of android.view.animation.AnticipateInterpolator in project ENViews by codeestX.

the class ENPlayView method pause.

public void pause() {
    if (mCurrentState == STATE_PAUSE) {
        return;
    }
    mCurrentState = STATE_PAUSE;
    ValueAnimator valueAnimator = ValueAnimator.ofFloat(1.f, 100.f);
    valueAnimator.setDuration(mDuration);
    valueAnimator.setInterpolator(new AnticipateInterpolator());
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mFraction = valueAnimator.getAnimatedFraction();
            invalidate();
        }
    });
    if (!valueAnimator.isRunning()) {
        valueAnimator.start();
    }
}
Also used : ValueAnimator(android.animation.ValueAnimator) AnticipateInterpolator(android.view.animation.AnticipateInterpolator)

Aggregations

AnticipateInterpolator (android.view.animation.AnticipateInterpolator)17 OvershootInterpolator (android.view.animation.OvershootInterpolator)8 ObjectAnimator (android.animation.ObjectAnimator)6 ValueAnimator (android.animation.ValueAnimator)4 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)4 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)4 AnticipateOvershootInterpolator (android.view.animation.AnticipateOvershootInterpolator)4 BounceInterpolator (android.view.animation.BounceInterpolator)4 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)4 LinearInterpolator (android.view.animation.LinearInterpolator)4 TypedArray (android.content.res.TypedArray)3 ContextThemeWrapper (android.view.ContextThemeWrapper)3 Animation (android.view.animation.Animation)2 ScaleAnimation (android.view.animation.ScaleAnimation)2 AccountManagerCallback (android.accounts.AccountManagerCallback)1 AccountManagerFuture (android.accounts.AccountManagerFuture)1 Intent (android.content.Intent)1 Resources (android.content.res.Resources)1 Bundle (android.os.Bundle)1 ActionMenuView (android.support.v7.widget.ActionMenuView)1