org.chromium.ui.interpolators.BakedBezierInterpolator Java Examples

The following examples show how to use org.chromium.ui.interpolators.BakedBezierInterpolator. 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: SnackbarView.java    From 365browser with Apache License 2.0 6 votes vote down vote up
void dismiss() {
    // Disable action button during animation.
    mActionButtonView.setEnabled(false);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setDuration(mAnimationDuration);
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mParent.removeOnLayoutChangeListener(mLayoutListener);
            mParent.removeView(mView);
        }
    });
    Animator moveDown = ObjectAnimator.ofFloat(mView, View.TRANSLATION_Y,
            mView.getHeight() + getLayoutParams().bottomMargin);
    moveDown.setInterpolator(new DecelerateInterpolator());
    Animator fadeOut = ObjectAnimator.ofFloat(mView, View.ALPHA, 0f);
    fadeOut.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE);

    animatorSet.playTogether(fadeOut, moveDown);
    startAnimatorOnSurfaceView(animatorSet);
}
 
Example #2
Source File: ToolbarProgressBarAnimatingView.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Start the animation if it hasn't been already.
 */
public void startAnimation() {
    mIsCanceled = false;
    if (!mAnimatorSet.isStarted()) {
        updateAnimationDuration();
        // Set the initial start delay to 0ms so it starts immediately.
        mAnimatorSet.setStartDelay(0);

        // Reset position.
        setScaleX(0.0f);
        setTranslationX(0.0f);
        mAnimatorSet.start();

        // Fade in to look nice on sites that trigger many loads that end quickly.
        animate().alpha(1.0f)
                .setDuration(500)
                .setInterpolator(BakedBezierInterpolator.FADE_IN_CURVE);
    }
}
 
Example #3
Source File: LocationBarLayout.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private void fadeOutOmniboxResultsContainerBackground() {
    if (mFadeOutOmniboxBackgroundAnimator == null) {
        mFadeOutOmniboxBackgroundAnimator = ObjectAnimator.ofInt(
                getRootView().findViewById(R.id.omnibox_results_container).getBackground(),
                AnimatorProperties.DRAWABLE_ALPHA_PROPERTY, 255, 0);
        mFadeOutOmniboxBackgroundAnimator.setDuration(OMNIBOX_CONTAINER_BACKGROUND_FADE_MS);
        mFadeOutOmniboxBackgroundAnimator.setInterpolator(
                BakedBezierInterpolator.FADE_OUT_CURVE);
        mFadeOutOmniboxBackgroundAnimator.addListener(new CancelAwareAnimatorListener() {
            @Override
            public void onEnd(Animator animator) {
                updateOmniboxResultsContainerVisibility(false);
            }
        });
    }
    runOmniboxResultsFadeAnimation(mFadeOutOmniboxBackgroundAnimator);
}
 
Example #4
Source File: FindResultBar.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/** Dismisses this results bar by removing it from the view hierarchy. */
public void dismiss() {
    mDismissing = true;
    mFindInPageBridge = null;
    if (mVisibilityAnimation != null && mVisibilityAnimation.isRunning()) {
        mVisibilityAnimation.cancel();
    }

    mVisibilityAnimation = ObjectAnimator.ofFloat(this, TRANSLATION_X,
            MathUtils.flipSignIf(mBarTouchWidth, LocalizationUtils.isLayoutRtl()));
    mVisibilityAnimation.setDuration(VISIBILITY_ANIMATION_DURATION_MS);
    mVisibilityAnimation.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE);
    mTab.getWindowAndroid().startAnimationOverContent(mVisibilityAnimation);
    mVisibilityAnimation.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);

            if (getParent() != null) ((ViewGroup) getParent()).removeView(FindResultBar.this);
        }
    });
}
 
Example #5
Source File: CustomTabBottomBarDelegate.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private void hideBottomBar() {
    if (mBottomBarView == null) return;
    ((ViewGroup) mBottomBarView.getParent()).removeView(mBottomBarView);
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.BOTTOM;
    final ViewGroup compositorView = mActivity.getCompositorViewHolder();
    compositorView.addView(mBottomBarView, lp);
    compositorView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                int oldLeft, int oldTop, int oldRight, int oldBottom) {
            compositorView.removeOnLayoutChangeListener(this);
            mBottomBarView.animate().alpha(0f).translationY(mBottomBarView.getHeight())
                    .setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE)
                    .setDuration(SLIDE_ANIMATION_DURATION_MS)
                    .withEndAction(new Runnable() {
                        @Override
                        public void run() {
                            ((ViewGroup) mBottomBarView.getParent()).removeView(mBottomBarView);
                            mBottomBarView = null;
                        }
                    }).start();
        }
    });
}
 
Example #6
Source File: SnackbarView.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
void dismiss() {
    // Disable action button during animation.
    mActionButtonView.setEnabled(false);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setDuration(mAnimationDuration);
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mParent.removeOnLayoutChangeListener(mLayoutListener);
            mParent.removeView(mView);
        }
    });
    Animator moveDown = ObjectAnimator.ofFloat(mView, View.TRANSLATION_Y,
            mView.getHeight() + getLayoutParams().bottomMargin);
    moveDown.setInterpolator(new DecelerateInterpolator());
    Animator fadeOut = ObjectAnimator.ofFloat(mView, View.ALPHA, 0f);
    fadeOut.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE);

    animatorSet.playTogether(fadeOut, moveDown);
    startAnimatorOnSurfaceView(animatorSet);
}
 
Example #7
Source File: ToolbarProgressBar.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private void animateAlphaTo(float targetAlpha) {
    float alphaDiff = targetAlpha - getAlpha();
    if (alphaDiff == 0.0f) return;

    long duration = (long) Math.abs(alphaDiff * mAlphaAnimationDurationMs);

    BakedBezierInterpolator interpolator = BakedBezierInterpolator.FADE_IN_CURVE;
    if (alphaDiff < 0) interpolator = BakedBezierInterpolator.FADE_OUT_CURVE;

    animate().alpha(targetAlpha)
            .setDuration(duration)
            .setInterpolator(interpolator);

    if (mAnimatingView != null) {
        mAnimatingView.animate().alpha(targetAlpha)
                .setDuration(duration)
                .setInterpolator(interpolator);
    }
}
 
Example #8
Source File: ToolbarProgressBar.java    From delion with Apache License 2.0 6 votes vote down vote up
private void animateAlphaTo(float targetAlpha) {
    float alphaDiff = targetAlpha - getAlpha();
    if (alphaDiff == 0.0f) return;

    long duration = (long) Math.abs(alphaDiff * mAlphaAnimationDurationMs);

    BakedBezierInterpolator interpolator = BakedBezierInterpolator.FADE_IN_CURVE;
    if (alphaDiff < 0) interpolator = BakedBezierInterpolator.FADE_OUT_CURVE;

    animate().alpha(targetAlpha)
            .setDuration(duration)
            .setInterpolator(interpolator);

    if (mAnimatingView != null) {
        mAnimatingView.animate().alpha(targetAlpha)
                .setDuration(duration)
                .setInterpolator(interpolator);
    }
}
 
Example #9
Source File: FindResultBar.java    From delion with Apache License 2.0 6 votes vote down vote up
/** Dismisses this results bar by removing it from the view hierarchy. */
public void dismiss() {
    mDismissing = true;
    mFindInPageBridge = null;
    if (mVisibilityAnimation != null && mVisibilityAnimation.isRunning()) {
        mVisibilityAnimation.cancel();
    }

    mVisibilityAnimation = ObjectAnimator.ofFloat(this, TRANSLATION_X,
            MathUtils.flipSignIf(mBarTouchWidth, LocalizationUtils.isLayoutRtl()));
    mVisibilityAnimation.setDuration(VISIBILITY_ANIMATION_DURATION_MS);
    mVisibilityAnimation.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE);
    mTab.getWindowAndroid().startAnimationOverContent(mVisibilityAnimation);
    mVisibilityAnimation.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);

            if (getParent() != null) ((ViewGroup) getParent()).removeView(FindResultBar.this);
        }
    });
}
 
Example #10
Source File: ToolbarProgressBarAnimatingView.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Start the animation if it hasn't been already.
 */
public void startAnimation() {
    mIsCanceled = false;
    if (!mAnimatorSet.isStarted()) {
        updateAnimationDuration();
        // Set the initial start delay to 0ms so it starts immediately.
        mAnimatorSet.setStartDelay(0);

        // Reset position.
        setScaleX(0.0f);
        setTranslationX(0.0f);
        mAnimatorSet.start();

        // Fade in to look nice on sites that trigger many loads that end quickly.
        animate().alpha(1.0f)
                .setDuration(500)
                .setInterpolator(BakedBezierInterpolator.FADE_IN_CURVE);
    }
}
 
Example #11
Source File: LocationBarLayout.java    From delion with Apache License 2.0 6 votes vote down vote up
private void fadeOutOmniboxResultsContainerBackground() {
    if (mFadeOutOmniboxBackgroundAnimator == null) {
        mFadeOutOmniboxBackgroundAnimator = ObjectAnimator.ofInt(
                getRootView().findViewById(R.id.omnibox_results_container).getBackground(),
                AnimatorProperties.DRAWABLE_ALPHA_PROPERTY, 255, 0);
        mFadeOutOmniboxBackgroundAnimator.setDuration(OMNIBOX_CONTAINER_BACKGROUND_FADE_MS);
        mFadeOutOmniboxBackgroundAnimator.setInterpolator(
                BakedBezierInterpolator.FADE_OUT_CURVE);
        mFadeOutOmniboxBackgroundAnimator.addListener(new CancelAwareAnimatorListener() {
            @Override
            public void onEnd(Animator animator) {
                updateOmniboxResultsContainerVisibility(false);
            }
        });
    }
    runOmniboxResultsFadeAnimation(mFadeOutOmniboxBackgroundAnimator);
}
 
Example #12
Source File: ToolbarProgressBar.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private void animateAlphaTo(float targetAlpha) {
    float alphaDiff = targetAlpha - getAlpha();
    if (alphaDiff == 0.0f) return;

    long duration = (long) Math.abs(alphaDiff * mAlphaAnimationDurationMs);

    BakedBezierInterpolator interpolator = BakedBezierInterpolator.FADE_IN_CURVE;
    if (alphaDiff < 0) interpolator = BakedBezierInterpolator.FADE_OUT_CURVE;

    animate().alpha(targetAlpha)
            .setDuration(duration)
            .setInterpolator(interpolator);

    if (mAnimatingView != null) {
        mAnimatingView.animate().alpha(targetAlpha)
                .setDuration(duration)
                .setInterpolator(interpolator);
    }
}
 
Example #13
Source File: SnackbarView.java    From delion with Apache License 2.0 6 votes vote down vote up
void dismiss() {
    // Disable action button during animation.
    mActionButtonView.setEnabled(false);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setDuration(mAnimationDuration);
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mParent.removeOnLayoutChangeListener(mLayoutListener);
            mParent.removeView(mView);
        }
    });
    Animator moveDown = ObjectAnimator.ofFloat(mView, View.TRANSLATION_Y,
            mView.getHeight() + getLayoutParams().bottomMargin);
    moveDown.setInterpolator(new DecelerateInterpolator());
    Animator fadeOut = ObjectAnimator.ofFloat(mView, View.ALPHA, 0f);
    fadeOut.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE);

    animatorSet.playTogether(fadeOut, moveDown);
    startAnimatorOnSurfaceView(animatorSet);
}
 
Example #14
Source File: CustomTabBottomBarDelegate.java    From delion with Apache License 2.0 6 votes vote down vote up
private void hideBottomBar() {
    if (mBottomBarView == null) return;
    ((ViewGroup) mBottomBarView.getParent()).removeView(mBottomBarView);
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.BOTTOM;
    final ViewGroup compositorView = mActivity.getCompositorViewHolder();
    compositorView.addView(mBottomBarView, lp);
    compositorView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                int oldLeft, int oldTop, int oldRight, int oldBottom) {
            compositorView.removeOnLayoutChangeListener(this);
            mBottomBarView.animate().alpha(0f).translationY(mBottomBarView.getHeight())
                    .setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE)
                    .setDuration(SLIDE_ANIMATION_DURATION_MS)
                    .withEndAction(new Runnable() {
                        @Override
                        public void run() {
                            ((ViewGroup) mBottomBarView.getParent()).removeView(mBottomBarView);
                            mBottomBarView = null;
                        }
                    }).start();
        }
    });
}
 
Example #15
Source File: FindResultBar.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/** Dismisses this results bar by removing it from the view hierarchy. */
public void dismiss() {
    mDismissing = true;
    mFindInPageBridge = null;
    if (mVisibilityAnimation != null && mVisibilityAnimation.isRunning()) {
        mVisibilityAnimation.cancel();
    }

    mVisibilityAnimation = ObjectAnimator.ofFloat(this, TRANSLATION_X,
            MathUtils.flipSignIf(mBarTouchWidth, LocalizationUtils.isLayoutRtl()));
    mVisibilityAnimation.setDuration(VISIBILITY_ANIMATION_DURATION_MS);
    mVisibilityAnimation.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE);
    mTab.getWindowAndroid().startAnimationOverContent(mVisibilityAnimation);
    mVisibilityAnimation.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);

            if (getParent() != null) ((ViewGroup) getParent()).removeView(FindResultBar.this);
        }
    });
}
 
Example #16
Source File: ToolbarProgressBarAnimatingView.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Start the animation if it hasn't been already.
 */
public void startAnimation() {
    mIsCanceled = false;
    if (!mAnimatorSet.isStarted()) {
        updateAnimationDuration();
        // Set the initial start delay to 0ms so it starts immediately.
        mAnimatorSet.setStartDelay(0);

        // Reset position.
        setScaleX(0.0f);
        setTranslationX(0.0f);
        mAnimatorSet.start();

        // Fade in to look nice on sites that trigger many loads that end quickly.
        animate().alpha(1.0f)
                .setDuration(500)
                .setInterpolator(BakedBezierInterpolator.FADE_IN_CURVE);
    }
}
 
Example #17
Source File: SimpleAnimationLayout.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Animate opening a tab in the foreground.
 *
 * @param id             The id of the new tab to animate.
 * @param sourceId       The id of the tab that spawned this new tab.
 * @param newIsIncognito true if the new tab is an incognito tab.
 * @param originX        The X coordinate of the last touch down event that spawned this tab.
 * @param originY        The Y coordinate of the last touch down event that spawned this tab.
 */
private void tabCreatedInForeground(
        int id, int sourceId, boolean newIsIncognito, float originX, float originY) {
    LayoutTab newLayoutTab = createLayoutTab(id, newIsIncognito, NO_CLOSE_BUTTON, NO_TITLE);
    if (mLayoutTabs == null || mLayoutTabs.length == 0) {
        mLayoutTabs = new LayoutTab[] {newLayoutTab};
    } else {
        mLayoutTabs = new LayoutTab[] {mLayoutTabs[0], newLayoutTab};
    }
    updateCacheVisibleIds(new LinkedList<Integer>(Arrays.asList(id, sourceId)));

    newLayoutTab.setBorderAlpha(0.0f);
    newLayoutTab.setStaticToViewBlend(1.f);

    forceAnimationToFinish();

    Interpolator interpolator = BakedBezierInterpolator.TRANSFORM_CURVE;
    addToAnimation(newLayoutTab, LayoutTab.Property.SCALE, 0.f, 1.f,
            FOREGROUND_ANIMATION_DURATION, 0, false, interpolator);
    addToAnimation(newLayoutTab, LayoutTab.Property.ALPHA, 0.f, 1.f,
            FOREGROUND_ANIMATION_DURATION, 0, false, interpolator);
    addToAnimation(newLayoutTab, LayoutTab.Property.X, originX, 0.f,
            FOREGROUND_ANIMATION_DURATION, 0, false, interpolator);
    addToAnimation(newLayoutTab, LayoutTab.Property.Y, originY, 0.f,
            FOREGROUND_ANIMATION_DURATION, 0, false, interpolator);

    mTabModelSelector.selectModel(newIsIncognito);
    startHiding(id, false);

    if (mForegroundTabCreationAnimationDisabled) forceAnimationToFinish();
}
 
Example #18
Source File: WebsiteSettingsPopup.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Create an animator to slide in the entire dialog from the top of the screen.
 */
private Animator createDialogSlideAnimator(boolean isEnter) {
    final float animHeight = -1f * mContainer.getHeight();
    ObjectAnimator translateAnim;
    if (isEnter) {
        mContainer.setTranslationY(animHeight);
        translateAnim = ObjectAnimator.ofFloat(mContainer, View.TRANSLATION_Y, 0f);
        translateAnim.setInterpolator(BakedBezierInterpolator.FADE_IN_CURVE);
    } else {
        translateAnim = ObjectAnimator.ofFloat(mContainer, View.TRANSLATION_Y, animHeight);
        translateAnim.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE);
    }
    translateAnim.setDuration(FADE_DURATION);
    return translateAnim;
}
 
Example #19
Source File: FadingBackgroundView.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Triggers a fade in of the omnibox results background creating a new animation if necessary.
 */
public void showFadingOverlay() {
    if (mOverlayFadeInAnimator == null) {
        mOverlayFadeInAnimator = ObjectAnimator.ofFloat(this, ALPHA, 1f);
        mOverlayFadeInAnimator.setDuration(FADE_DURATION_MS);
        mOverlayFadeInAnimator.setInterpolator(
                BakedBezierInterpolator.FADE_IN_CURVE);
    }

    runFadeOverlayAnimation(mOverlayFadeInAnimator);
}
 
Example #20
Source File: NumberRollView.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Sets a number to display.
 * @param animate Whether it should smoothly animate to the number.
 */
public void setNumber(int number, boolean animate) {
    if (mLastRollAnimator != null) mLastRollAnimator.cancel();

    if (animate) {
        Animator rollAnimator = ObjectAnimator.ofFloat(this, NUMBER_PROPERTY, number);
        rollAnimator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
        rollAnimator.start();
        mLastRollAnimator = rollAnimator;
    } else {
        setNumberRoll(number);
    }
}
 
Example #21
Source File: LoadingView.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    animate().alpha(0.0f).setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE)
            .setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    setVisibility(GONE);
                }
            });
}
 
Example #22
Source File: LayoutTab.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the {@link LayoutTab} from data extracted from a {@link Tab}.
 * As this function may be expensive and can be delayed we initialize it as a separately.
 *
 * @param backgroundColor       The color of the page background.
 * @param fallbackThumbnailId   The id of a cached thumbnail to show if the current
 *                              thumbnail is unavailable, or {@link Tab.INVALID_TAB_ID}
 *                              if none exists.
 * @param shouldStall           Whether the tab should display a desaturated thumbnail and
 *                              wait for the content layer to load.
 * @param canUseLiveTexture     Whether the tab can use a live texture when being displayed.
 * @return True if the init requires the compositor to update.
 */
public boolean initFromHost(int backgroundColor, boolean shouldStall, boolean canUseLiveTexture,
        int toolbarBackgroundColor, int textBoxBackgroundColor, float textBoxAlpha) {
    mBackgroundColor = backgroundColor;

    boolean needsUpdate = false;

    // If the toolbar color changed, animate between the old and new colors.
    if (mToolbarBackgroundColor != toolbarBackgroundColor && isVisible()
            && mInitFromHostCalled) {
        ChromeAnimation.Animation<ChromeAnimation.Animatable<?>>  themeColorAnimation =
                createAnimation(this, Property.TOOLBAR_COLOR, 0.0f, 1.0f,
                ToolbarPhone.THEME_COLOR_TRANSITION_DURATION, 0, false,
                BakedBezierInterpolator.TRANSFORM_CURVE);

        mInitialThemeColor = mToolbarBackgroundColor;
        mFinalThemeColor = toolbarBackgroundColor;

        if (mCurrentAnimations != null) {
            mCurrentAnimations.updateAndFinish();
        }

        mCurrentAnimations = new ChromeAnimation<ChromeAnimation.Animatable<?>>();
        mCurrentAnimations.add(themeColorAnimation);
        mCurrentAnimations.start();
        needsUpdate = true;
    } else {
        // If the layout tab isn't visible, just set the toolbar color without animating.
        mToolbarBackgroundColor = toolbarBackgroundColor;
    }

    mTextBoxBackgroundColor = textBoxBackgroundColor;
    mTextBoxAlpha = textBoxAlpha;
    mShouldStall = shouldStall;
    mCanUseLiveTexture = canUseLiveTexture;
    mInitFromHostCalled = true;

    return needsUpdate;
}
 
Example #23
Source File: StackViewAnimation.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private Animator createNewTabOpenedAnimator(
        StackTab[] tabs, ViewGroup container, TabModel model, int focusIndex) {
    Tab tab = model.getTabAt(focusIndex);
    if (tab == null || !tab.isNativePage()) return null;

    View view = tab.getView();
    if (view == null) return null;

    // Set up the view hierarchy
    if (view.getParent() != null) ((ViewGroup) view.getParent()).removeView(view);
    ViewGroup bgView = new FrameLayout(view.getContext());
    bgView.setBackgroundColor(tab.getBackgroundColor());
    bgView.addView(view);
    container.addView(
            bgView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    // Update any compositor state that needs to change
    if (tabs != null && focusIndex >= 0 && focusIndex < tabs.length) {
        tabs[focusIndex].setAlpha(0.f);
    }

    // Build the view animations
    PropertyValuesHolder xScale = PropertyValuesHolder.ofFloat(View.SCALE_X, 0.f, 1.f);
    PropertyValuesHolder yScale = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.f, 1.f);
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 0.f, 1.f);
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(
            bgView, xScale, yScale, alpha);

    animator.setDuration(TAB_OPENED_ANIMATION_DURATION);
    animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_FOLLOW_THROUGH_CURVE);

    float insetPx = TAB_OPENED_PIVOT_INSET_DP * mDpToPx;

    bgView.setPivotY(TAB_OPENED_PIVOT_INSET_DP);
    bgView.setPivotX(LocalizationUtils.isLayoutRtl() ? mWidthDp * mDpToPx - insetPx : insetPx);
    return animator;
}
 
Example #24
Source File: SimpleAnimationLayout.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Animate the closing of a tab
 */
@Override
public void onTabClosed(long time, int id, int nextId, boolean incognito) {
    super.onTabClosed(time, id, nextId, incognito);

    if (mClosedTab != null) {
        TabModel nextModel = mTabModelSelector.getModelForTabId(nextId);
        if (nextModel != null) {
            LayoutTab nextLayoutTab =
                    createLayoutTab(nextId, nextModel.isIncognito(), NO_CLOSE_BUTTON, NO_TITLE);
            nextLayoutTab.setDrawDecoration(false);

            mLayoutTabs = new LayoutTab[] {nextLayoutTab, mClosedTab};
            updateCacheVisibleIds(
                    new LinkedList<Integer>(Arrays.asList(nextId, mClosedTab.getId())));
        } else {
            mLayoutTabs = new LayoutTab[] {mClosedTab};
        }

        forceAnimationToFinish();
        mAnimatedTab = mClosedTab;
        addToAnimation(this, Property.DISCARD_AMOUNT, 0, getDiscardRange(),
                TAB_CLOSED_ANIMATION_DURATION, 0, false,
                BakedBezierInterpolator.FADE_OUT_CURVE);

        mClosedTab = null;
        if (nextModel != null) {
            mTabModelSelector.selectModel(nextModel.isIncognito());
        }
    }
    startHiding(nextId, false);
}
 
Example #25
Source File: LoadingView.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    animate().alpha(0.0f).setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE)
            .setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    setVisibility(GONE);
                }
            });
}
 
Example #26
Source File: NumberRollView.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Sets a number to display.
 * @param animate Whether it should smoothly animate to the number.
 */
public void setNumber(int number, boolean animate) {
    if (mLastRollAnimator != null) mLastRollAnimator.cancel();

    if (animate) {
        Animator rollAnimator = ObjectAnimator.ofFloat(this, NUMBER_PROPERTY, number);
        rollAnimator.setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE);
        rollAnimator.start();
        mLastRollAnimator = rollAnimator;
    } else {
        setNumberRoll(number);
    }
}
 
Example #27
Source File: PageInfoPopup.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Create an animator to slide in the entire dialog from the top of the screen.
 */
private Animator createDialogSlideAnimator(boolean isEnter) {
    final float animHeight = (mIsBottomPopup ? 1f : -1f) * mContainer.getHeight();
    ObjectAnimator translateAnim;
    if (isEnter) {
        mContainer.setTranslationY(animHeight);
        translateAnim = ObjectAnimator.ofFloat(mContainer, View.TRANSLATION_Y, 0f);
        translateAnim.setInterpolator(BakedBezierInterpolator.FADE_IN_CURVE);
    } else {
        translateAnim = ObjectAnimator.ofFloat(mContainer, View.TRANSLATION_Y, animHeight);
        translateAnim.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE);
    }
    translateAnim.setDuration(FADE_DURATION);
    return translateAnim;
}
 
Example #28
Source File: FadingBackgroundView.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Triggers a fade out of the omnibox results background creating a new animation if necessary.
 */
public void hideFadingOverlay(boolean fadeOut) {
    if (mOverlayFadeOutAnimator == null) {
        mOverlayFadeOutAnimator = ObjectAnimator.ofFloat(this, ALPHA, 0f);
        mOverlayFadeOutAnimator.setDuration(FADE_DURATION_MS);
        mOverlayFadeOutAnimator.setInterpolator(BakedBezierInterpolator.FADE_OUT_CURVE);
    }

    mOverlayFadeOutAnimator.setFloatValues(getAlpha(), 0f);
    runFadeOverlayAnimation(mOverlayFadeOutAnimator);
    if (!fadeOut) mOverlayFadeOutAnimator.end();
}
 
Example #29
Source File: CustomTabBottomBarDelegate.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void hideBottomBar() {
    if (mBottomBarView == null) return;
    mBottomBarView.animate().alpha(0f).translationY(mBottomBarView.getHeight())
            .setInterpolator(BakedBezierInterpolator.TRANSFORM_CURVE)
            .setDuration(SLIDE_ANIMATION_DURATION_MS)
            .withEndAction(new Runnable() {
                @Override
                public void run() {
                    ((ViewGroup) mBottomBarView.getParent()).removeView(mBottomBarView);
                    mBottomBarView = null;
                }
            }).start();
    mFullscreenManager.setBottomControlsHeight(0);
}
 
Example #30
Source File: LocationBarTablet.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @param button The {@link View} of the button to show.
 * @return An animator to run for the given view when showing buttons in the unfocused location
 *         bar. This should also be used to create animators for showing toolbar buttons.
 */
public ObjectAnimator createShowButtonAnimator(View button) {
    if (button.getVisibility() != View.VISIBLE) {
        button.setAlpha(0.f);
    }
    ObjectAnimator buttonAnimator = ObjectAnimator.ofFloat(button, View.ALPHA, 1.f);
    buttonAnimator.setInterpolator(BakedBezierInterpolator.FADE_IN_CURVE);
    buttonAnimator.setStartDelay(ICON_FADE_ANIMATION_DELAY_MS);
    buttonAnimator.setDuration(ICON_FADE_ANIMATION_DURATION_MS);
    return buttonAnimator;
}