Java Code Examples for android.animation.Animator#setStartDelay()

The following examples show how to use android.animation.Animator#setStartDelay() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From Android-Tutorials with Apache License 2.0 6 votes vote down vote up
private void animateAppAndStatusBar(int cx, final int toColor) {
    Animator animator = ViewAnimationUtils.createCircularReveal(
            mRevealView,
            cx,
            appBarLayout.getBottom(), 0,
            appBarLayout.getWidth() / 2);

    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            mRevealView.setBackgroundColor(getResources().getColor(toColor));
        }
    });

    mRevealBackgroundView.setBackgroundColor(getResources().getColor(fromColor));
    animator.setStartDelay(200);
    animator.setDuration(125);
    animator.start();
    mRevealView.setVisibility(View.VISIBLE);
    fromColor = toColor;
}
 
Example 2
Source File: AnimatorUtil.java    From AndroidLinkup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 平移动画
 * 
 * @param view
 *            执行动画的view
 * @param fromX
 *            起始X坐标
 * @param toX
 *            结束X坐标
 * @param fromY
 *            起始Y坐标
 * @param toY
 *            结束Y坐标
 * @param duration
 *            动画时长
 */
public static void animTranslate(View view, float fromX, float toX, float fromY, float toY, int duration, int delay, boolean isHide) {
    Animator animX = ObjectAnimator.ofFloat(view, "translationX", fromX, toX).setDuration(duration);
    Animator animY = ObjectAnimator.ofFloat(view, "translationY", fromY, toY).setDuration(duration);

    if (fromX != toX) {
        animX.setStartDelay(delay);
        animX.start();
    } else {
        view.setTranslationX(fromX);
    }
    if (fromY != toY) {
        animY.setStartDelay(delay);
        if (isHide) {
            animY.addListener(new HideAnimator(view));
        }
        animY.start();
    } else {
        view.setTranslationY(fromY);
    }
}
 
Example 3
Source File: GameCard.java    From AndroidLinkup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 设置与界面卡片关联的piece
 * 
 * @param piece
 *            piece信息
 * @param isAnim
 *            是否应用动画
 */
public void setPiece(Piece piece, Bitmap bm, boolean isAnim) {
    this.piece = piece;
    imageView.setImageBitmap(bm);
    if (piece.isStar()) {
        // 卡片星星
        imageStar = new ImageView(getContext());
        imageStar.setImageResource(R.drawable.star_48);
        addView(imageStar, 48, 48);
    }

    if (isAnim) {
        setXY(piece.getBeginX(), -piece.getHeight());
        // 从上面落下
        Animator anim = ObjectAnimator.ofFloat(this, "translationY", 0, piece.getBeginY() + piece.getHeight());
        anim.setDuration(500);
        anim.setStartDelay((Piece.YSize - piece.getIndexY()) * 50 - ran.nextInt(50));
        anim.start();
    } else {
        // 设置卡片的left和top
        setXY(piece.getBeginX(), piece.getBeginY());
    }

    lineWidth = piece.getWidth() / 16 + 1;
    rect = new RectF(piece.getWidth() / 32, piece.getWidth() / 32, piece.getWidth() - lineWidth + 1, piece.getHeight() - lineWidth + 1);
}
 
Example 4
Source File: FabTransformationBehavior.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
/** Adds pre radial expansion animator. */
private void createPreFillRadialExpansion(
    View child,
    long delay,
    int revealCenterX,
    int revealCenterY,
    float fromRadius,
    @NonNull List<Animator> animations) {
  if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
    // No setter for circular reveal in L+.
    if (delay > 0) {
      Animator animator =
          ViewAnimationUtils.createCircularReveal(
              child, revealCenterX, revealCenterY, fromRadius, fromRadius);
      animator.setStartDelay(0);
      animator.setDuration(delay);
      animations.add(animator);
    }
  }
}
 
Example 5
Source File: AnimationBody.java    From Flubber with Apache License 2.0 6 votes vote down vote up
public Animator createFor(View view) {
    final Animator animation = Flubber.getAnimation(this, view);

    animation.setDuration(duration);
    animation.setStartDelay(delay);

    if (autoStart) {
        animation.start();
    }

    if (animatorListener != null) {
        animation.addListener(animatorListener);
    }

    return animation;
}
 
Example 6
Source File: Transition.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * This is a utility method used by subclasses to handle standard parts of
 * setting up and running an Animator: it sets the {@link #getDuration()
 * duration} and the {@link #getStartDelay() startDelay}, starts the
 * animation, and, when the animator ends, calls {@link #end()}.
 *
 * @param animator The Animator to be run during this transition.
 *
 * @hide
 */
protected void animate(Animator animator) {
    // TODO: maybe pass auto-end as a boolean parameter?
    if (animator == null) {
        end();
    } else {
        if (getDuration() >= 0) {
            animator.setDuration(getDuration());
        }
        if (getStartDelay() >= 0) {
            animator.setStartDelay(getStartDelay() + animator.getStartDelay());
        }
        if (getInterpolator() != null) {
            animator.setInterpolator(getInterpolator());
        }
        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                end();
                animation.removeListener(this);
            }
        });
        animator.start();
    }
}
 
Example 7
Source File: TransitionHelperKitkat.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues,
        TransitionValues endValues) {
    Animator animator = super.createAnimator(sceneRoot, startValues, endValues);
    if (animator != null && endValues != null && endValues.view != null) {
        animator.setStartDelay(getDelay(endValues.view));
    }
    return animator;
}
 
Example 8
Source File: FadeAnimationController.java    From IslamicLibraryAndroid with GNU General Public License v3.0 5 votes vote down vote up
public static Animator createAnimator(@NonNull View view, float toAlpha, int durationMillis, int startDelayMillis, AnimatorListener listener) {
    Animator animator = ObjectAnimator.ofFloat(view, "alpha", view.getAlpha(), toAlpha);
    animator.setDuration((long) durationMillis);
    animator.setStartDelay((long) startDelayMillis);
    animator.addListener(listener);
    return animator;
}
 
Example 9
Source File: FlatPlayerPlaybackControlsFragment.java    From Orin with GNU General Public License v3.0 5 votes vote down vote up
private static void addAnimation(Collection<Animator> animators, View view, TimeInterpolator interpolator, int duration, int delay) {
    Animator scaleX = ObjectAnimator.ofFloat(view, View.SCALE_X, 0f, 1f);
    scaleX.setInterpolator(interpolator);
    scaleX.setDuration(duration);
    scaleX.setStartDelay(delay);
    animators.add(scaleX);

    Animator scaleY = ObjectAnimator.ofFloat(view, View.SCALE_Y, 0f, 1f);
    scaleY.setInterpolator(interpolator);
    scaleY.setDuration(duration);
    scaleY.setStartDelay(delay);
    animators.add(scaleY);
}
 
Example 10
Source File: SharingActivity.java    From UI-Motion with Apache License 2.0 5 votes vote down vote up
/**
 * Hide the background
 */
private void hideTheBackground() {
    Animator hide = createRevealAnimator(false);
    hide.setStartDelay(mDefaultAnimDuration);
    hide.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mBackgroundView.setVisibility(View.INVISIBLE);
            supportFinishAfterTransition();
        }
    });
    hide.start();
}
 
Example 11
Source File: SpotsDialog.java    From KUtils-master with Apache License 2.0 5 votes vote down vote up
private Animator[] createAnimations() {
    Animator[] animators = new Animator[size];
    for (int i = 0; i < spots.length; i++) {
        Animator move = ObjectAnimator.ofFloat(spots[i], "xFactor", 0, 1);
        move.setDuration(DURATION);
        move.setInterpolator(new HesitateInterpolator());
        move.setStartDelay(DELAY * i);
        animators[i] = move;
    }
    return animators;
}
 
Example 12
Source File: MaterialIn.java    From Material-In with Apache License 2.0 5 votes vote down vote up
public static void startAnimators(final View view, int startOffsetX, int startOffsetY, long delay) {
    if (view.getVisibility() == View.VISIBLE && view.getAlpha() != 0f) {
        view.clearAnimation();
        view.animate().cancel();
        final Resources res = view.getResources();
        final float endAlpha = view.getAlpha();
        final float endTranslateX = view.getTranslationX();
        final float endTranslateY = view.getTranslationY();
        view.setAlpha(0);
        final Animator fade = ObjectAnimator.ofFloat(view, View.ALPHA, endAlpha);
        fade.setDuration(res.getInteger(R.integer.material_in_fade_anim_duration));
        fade.setInterpolator(new AccelerateInterpolator());
        fade.setStartDelay(delay);
        fade.start();
        ViewPropertyAnimator slide = view.animate();
        if (startOffsetY != 0) {
            view.setTranslationY(startOffsetY);
            slide.translationY(endTranslateY);
        } else {
            view.setTranslationX(startOffsetX);
            slide.translationX(endTranslateX);
        }
        slide.setInterpolator(new DecelerateInterpolator(2));
        slide.setDuration(res.getInteger(R.integer.material_in_slide_anim_duration));
        slide.setStartDelay(delay);
        slide.setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationCancel(Animator animation) {
                if (fade.isStarted()) {
                    fade.cancel();
                }
                view.setAlpha(endAlpha);
                view.setTranslationX(endTranslateX);
                view.setTranslationY(endTranslateY);
            }
        });
        slide.start();
    }
}
 
Example 13
Source File: HeaderViewHolder.java    From GeometricWeather with GNU Lesser General Public License v3.0 5 votes vote down vote up
@NotNull
@Override
protected Animator getEnterAnimator(List<Animator> pendingAnimatorList) {
    Animator a = ObjectAnimator.ofFloat(itemView, "alpha", 0f, 1f);
    a.setDuration(300);
    a.setStartDelay(100);
    a.setInterpolator(new FastOutSlowInInterpolator());
    return a;
}
 
Example 14
Source File: MotionTiming.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
public void apply(@NonNull Animator animator) {
  animator.setStartDelay(getDelay());
  animator.setDuration(getDuration());
  animator.setInterpolator(getInterpolator());
  if (animator instanceof ValueAnimator) {
    ((ValueAnimator) animator).setRepeatCount(getRepeatCount());
    ((ValueAnimator) animator).setRepeatMode(getRepeatMode());
  }
}
 
Example 15
Source File: FlatPlayerPlaybackControlsFragment.java    From Music-Player with GNU General Public License v3.0 5 votes vote down vote up
private static void addAnimation(Collection<Animator> animators, View view, TimeInterpolator interpolator, int duration, int delay) {
    Animator scaleX = ObjectAnimator.ofFloat(view, View.SCALE_X, 0f, 1f);
    scaleX.setInterpolator(interpolator);
    scaleX.setDuration(duration);
    scaleX.setStartDelay(delay);
    animators.add(scaleX);

    Animator scaleY = ObjectAnimator.ofFloat(view, View.SCALE_Y, 0f, 1f);
    scaleY.setInterpolator(interpolator);
    scaleY.setDuration(duration);
    scaleY.setStartDelay(delay);
    animators.add(scaleY);
}
 
Example 16
Source File: ToolbarPhone.java    From delion with Apache License 2.0 4 votes vote down vote up
private void populateUrlClearFocusingAnimatorSet(List<Animator> animators) {
    Animator animator = ObjectAnimator.ofFloat(this, mUrlFocusChangePercentProperty, 0f);
    animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
    animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
    animators.add(animator);

    animator = ObjectAnimator.ofFloat(mMenuButtonWrapper, TRANSLATION_X, 0);
    animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
    animator.setStartDelay(URL_CLEAR_FOCUS_MENU_DELAY_MS);
    animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
    animators.add(animator);

    animator = ObjectAnimator.ofFloat(mMenuButtonWrapper, ALPHA, 1);
    animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
    animator.setStartDelay(URL_CLEAR_FOCUS_MENU_DELAY_MS);
    animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
    animators.add(animator);

    if (mToggleTabStackButton != null) {
        animator = ObjectAnimator.ofFloat(mToggleTabStackButton, TRANSLATION_X, 0);
        animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
        animator.setStartDelay(URL_CLEAR_FOCUS_TABSTACK_DELAY_MS);
        animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
        animators.add(animator);

        animator = ObjectAnimator.ofFloat(mToggleTabStackButton, ALPHA, 1);
        animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
        animator.setStartDelay(URL_CLEAR_FOCUS_TABSTACK_DELAY_MS);
        animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
        animators.add(animator);
    }

    for (int i = 0; i < mPhoneLocationBar.getChildCount(); i++) {
        View childView = mPhoneLocationBar.getChildAt(i);
        if (childView == mPhoneLocationBar.getFirstViewVisibleWhenFocused()) break;
        animator = ObjectAnimator.ofFloat(childView, ALPHA, 1);
        animator.setStartDelay(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
        animator.setDuration(URL_CLEAR_FOCUS_MENU_DELAY_MS);
        animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
        animators.add(animator);
    }

    if (isLocationBarShownInNTP() && mNtpSearchBoxScrollPercent == 0f) return;

    // The call to getLayout() can return null briefly during text changes, but as it
    // is only needed for RTL calculations, we proceed if the location bar is showing
    // LTR content.
    boolean isLocationBarRtl = ApiCompatibilityUtils.isLayoutRtl(mPhoneLocationBar);
    if (!isLocationBarRtl || mUrlBar.getLayout() != null) {
        int urlBarStartScrollX = 0;
        if (isLocationBarRtl) {
            urlBarStartScrollX = (int) mUrlBar.getLayout().getPrimaryHorizontal(0);
            urlBarStartScrollX -= mUrlBar.getWidth();
        }

        // If the scroll position matches the current scroll position, do not trigger
        // this animation as it will cause visible jumps when going from cleared text
        // back to page URLs (despite it continually calling setScrollX with the same
        // number).
        if (mUrlBar.getScrollX() != urlBarStartScrollX) {
            animator = ObjectAnimator.ofInt(
                    mUrlBar,
                    buildUrlScrollProperty(mPhoneLocationBar, isLocationBarRtl),
                    urlBarStartScrollX);
            animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
            animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
            animators.add(animator);
        }
    }
}
 
Example 17
Source File: AnimateableDialogDecorator.java    From AndroidMaterialDialog with Apache License 2.0 4 votes vote down vote up
/**
 * Creates an animator, which should be used for a circle reveal animation.
 *
 * @param animatedView
 *         The animated view as an instance of the class {@link View}. The view may not be null
 * @param rootView
 *         The root view of the dialog as an instance of the class {@link View}. The view may
 *         not be null
 * @param animation
 *         The animation as an instance of the class {@link CircleRevealAnimation}. The
 *         animation may not be null
 * @param listener
 *         The listener, which should be notified about the animation's events, as an instance
 *         of type {@link AnimatorListener} or null, if no listener should be notified
 * @param show
 *         True, if the animation should be used for showing the dialog, false otherwise
 * @return The animator, which has been created, as an instance of the class {@link Animator} or
 * null, if no animation should be used
 */
@Nullable
private Animator createAnimator(@NonNull final View animatedView, @NonNull final View rootView,
                                @NonNull final CircleRevealAnimation animation,
                                @Nullable final AnimatorListener listener, final boolean show) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        long duration = getDuration(animatedView, animation);
        int horizontalDistance = Math.max(Math.abs(rootView.getLeft() - animation.getX()),
                Math.abs(rootView.getRight() - animation.getX()));
        int verticalDistance = Math.max(Math.abs(rootView.getTop() - animation.getY()),
                Math.abs(rootView.getBottom() - animation.getY()));
        float maxRadius = (float) Math
                .sqrt(Math.pow(horizontalDistance, 2) + Math.pow(verticalDistance, 2));
        Animator animator = ViewAnimationUtils
                .createCircularReveal(animatedView, animation.getX(), animation.getY(),
                        show ? animation.getRadius() : maxRadius,
                        show ? maxRadius : animation.getRadius());
        animator.setInterpolator(animation.getInterpolator());
        animator.setStartDelay(animation.getStartDelay());
        animator.setDuration(duration);

        if (listener != null) {
            animator.addListener(listener);
        }

        if (animation.getAlpha() != null) {
            ObjectAnimator alphaAnimator = ObjectAnimator
                    .ofFloat(animatedView, "alpha", show ? animation.getAlpha() : 1,
                            show ? 1 : animation.getAlpha());
            alphaAnimator.setInterpolator(animation.getInterpolator());
            alphaAnimator.setStartDelay(animation.getStartDelay());
            alphaAnimator.setDuration(duration);
            AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.playTogether(animator, alphaAnimator);
            return animatorSet;
        }

        return animator;
    }

    return null;
}
 
Example 18
Source File: PostActivity.java    From materialup with Apache License 2.0 4 votes vote down vote up
/**
 * Animate in the title, description and author – can't do this in a content transition as they
 * are within the ListView so do it manually.  Also handle the FAB tanslation here so that it
 * plays nicely with #calculateFabPosition
 */
private void enterAnimation(boolean isOrientationChange) {
    Interpolator interp = null;
    if (UI.isLollipop()) {
        interp = AnimationUtils.loadInterpolator(this, android.R.interpolator
                .fast_out_slow_in);
    } else {
        interp = AnimationUtils.loadInterpolator(this, android.R.interpolator
                .accelerate_decelerate);
    }
    int offset = title.getHeight();
    viewEnterAnimation(title, offset, interp);
    if (description.getVisibility() == View.VISIBLE) {
        offset *= 1.5f;
        viewEnterAnimation(description, offset, interp);
    }
    // animate the fab without touching the alpha as this is handled in the content transition
    offset *= 1.5f;
    float fabTransY = fab.getTranslationY();
    fab.setTranslationY(fabTransY + offset);
    fab.animate()
            .translationY(fabTransY)
            .setDuration(600)
            .setInterpolator(interp)
            .start();
    offset *= 1.5f;
    viewEnterAnimation(shotActions, offset, interp);
    offset *= 1.5f;
    viewEnterAnimation(playerName, offset, interp);
    viewEnterAnimation(playerAvatar, offset, interp);
    viewEnterAnimation(shotTimeAgo, offset, interp);
    back.animate()
            .alpha(1f)
            .setDuration(600)
            .setInterpolator(interp)
            .start();
    source.animate()
            .alpha(1f)
            .setDuration(600)
            .setInterpolator(interp)
            .start();

    if (isOrientationChange) {
        // we rely on the window enter content transition to show the fab. This isn't run on
        // orientation changes so manually show it.
        Animator showFab = ObjectAnimator.ofPropertyValuesHolder(fab,
                PropertyValuesHolder.ofFloat(View.ALPHA, 0f, 1f),
                PropertyValuesHolder.ofFloat(View.SCALE_X, 0f, 1f),
                PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f, 1f));
        showFab.setStartDelay(300L);
        showFab.setDuration(300L);
        showFab.setInterpolator(AnimationUtils.loadInterpolator(this,
                android.R.interpolator.linear_out_slow_in));
        showFab.start();
    }
}
 
Example 19
Source File: ToolbarPhone.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
private void populateUrlClearFocusingAnimatorSet(List<Animator> animators) {
    Animator animator = ObjectAnimator.ofFloat(this, mUrlFocusChangePercentProperty, 0f);
    animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
    animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
    animators.add(animator);

    animator = ObjectAnimator.ofFloat(mMenuButtonWrapper, TRANSLATION_X, 0);
    animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
    animator.setStartDelay(URL_CLEAR_FOCUS_MENU_DELAY_MS);
    animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
    animators.add(animator);

    animator = ObjectAnimator.ofFloat(mMenuButtonWrapper, ALPHA, 1);
    animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
    animator.setStartDelay(URL_CLEAR_FOCUS_MENU_DELAY_MS);
    animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
    animators.add(animator);

    if (mToggleTabStackButton != null) {
        animator = ObjectAnimator.ofFloat(mToggleTabStackButton, TRANSLATION_X, 0);
        animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
        animator.setStartDelay(URL_CLEAR_FOCUS_TABSTACK_DELAY_MS);
        animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
        animators.add(animator);

        animator = ObjectAnimator.ofFloat(mToggleTabStackButton, ALPHA, 1);
        animator.setDuration(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
        animator.setStartDelay(URL_CLEAR_FOCUS_TABSTACK_DELAY_MS);
        animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
        animators.add(animator);
    }

    for (int i = 0; i < mLocationBar.getChildCount(); i++) {
        View childView = mLocationBar.getChildAt(i);
        if (childView == mLocationBar.getFirstViewVisibleWhenFocused()) break;
        animator = ObjectAnimator.ofFloat(childView, ALPHA, 1);
        animator.setStartDelay(URL_FOCUS_TOOLBAR_BUTTONS_DURATION_MS);
        animator.setDuration(URL_CLEAR_FOCUS_MENU_DELAY_MS);
        animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
        animators.add(animator);
    }

    if (isLocationBarShownInNTP() && mNtpSearchBoxScrollPercent == 0f) return;

    // The call to getLayout() can return null briefly during text changes, but as it
    // is only needed for RTL calculations, we proceed if the location bar is showing
    // LTR content.
    boolean isLocationBarRtl = ApiCompatibilityUtils.isLayoutRtl(mLocationBar);
    if (!isLocationBarRtl || mUrlBar.getLayout() != null) {
        int urlBarStartScrollX = 0;
        if (isLocationBarRtl) {
            urlBarStartScrollX = (int) mUrlBar.getLayout().getPrimaryHorizontal(0);
            urlBarStartScrollX -= mUrlBar.getWidth();
        }

        // If the scroll position matches the current scroll position, do not trigger
        // this animation as it will cause visible jumps when going from cleared text
        // back to page URLs (despite it continually calling setScrollX with the same
        // number).
        if (mUrlBar.getScrollX() != urlBarStartScrollX) {
            animator = ObjectAnimator.ofInt(mUrlBar,
                    buildUrlScrollProperty(mLocationBar, isLocationBarRtl), urlBarStartScrollX);
            animator.setDuration(URL_FOCUS_CHANGE_ANIMATION_DURATION_MS);
            animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
            animators.add(animator);
        }
    }
}
 
Example 20
Source File: PopupContainerWithArrow.java    From LaunchEnr with GNU General Public License v3.0 4 votes vote down vote up
public void trimNotifications(Map<PackageUserKey, BadgeInfo> updatedBadges) {
    if (mNotificationItemView == null) {
        return;
    }
    ItemInfo originalInfo = (ItemInfo) mOriginalIcon.getTag();
    BadgeInfo badgeInfo = updatedBadges.get(PackageUserKey.fromItemInfo(originalInfo));
    if (badgeInfo == null || badgeInfo.getNotificationKeys().size() == 0) {
        AnimatorSet removeNotification = LauncherAnimUtils.createAnimatorSet();
        final int duration = getResources().getInteger(
                R.integer.config_removeNotificationViewDuration);
        final int spacing = getResources().getDimensionPixelSize(R.dimen.popup_items_spacing);
        removeNotification.play(reduceNotificationViewHeight(
                mNotificationItemView.getHeightMinusFooter() + spacing, duration));
        final View removeMarginView = mIsAboveIcon ? getItemViewAt(getItemCount() - 2)
                : mNotificationItemView;
        if (removeMarginView != null) {
            ValueAnimator removeMargin = ValueAnimator.ofFloat(1, 0).setDuration(duration);
            removeMargin.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    ((MarginLayoutParams) removeMarginView.getLayoutParams()).bottomMargin
                            = (int) (spacing * (float) valueAnimator.getAnimatedValue());
                }
            });
            removeNotification.play(removeMargin);
        }
        Animator fade = ObjectAnimator.ofFloat(mNotificationItemView, ALPHA, 0)
                .setDuration(duration);
        fade.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                removeView(mNotificationItemView);
                mNotificationItemView = null;
                if (getItemCount() == 0) {
                    close(false);
                    return;
                }
            }
        });
        removeNotification.play(fade);
        final long arrowScaleDuration = getResources().getInteger(
                R.integer.config_deepShortcutArrowOpenDuration);
        Animator hideArrow = createArrowScaleAnim(0).setDuration(arrowScaleDuration);
        hideArrow.setStartDelay(0);
        Animator showArrow = createArrowScaleAnim(1).setDuration(arrowScaleDuration);
        showArrow.setStartDelay((long) (duration - arrowScaleDuration * 1.5));
        removeNotification.playSequentially(hideArrow, showArrow);
        removeNotification.start();
        return;
    }
    mNotificationItemView.trimNotifications(NotificationKeyData.extractKeysOnly(
            badgeInfo.getNotificationKeys()));
}