Search in sources :

Example 41 with PropertyValuesHolder

use of android.animation.PropertyValuesHolder in project android_packages_apps_Launcher2 by CyanogenMod.

the class LauncherTransitionable method shrinkAndFadeInFolderIcon.

private void shrinkAndFadeInFolderIcon(final FolderIcon fi) {
    if (fi == null)
        return;
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1.0f);
    PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f);
    final CellLayout cl = (CellLayout) fi.getParent().getParent();
    // We remove and re-draw the FolderIcon in-case it has changed
    mDragLayer.removeView(mFolderIconImageView);
    copyFolderIconToImage(fi);
    ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(mFolderIconImageView, alpha, scaleX, scaleY);
    oa.setDuration(getResources().getInteger(R.integer.config_folderAnimDuration));
    oa.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (cl != null) {
                cl.clearFolderLeaveBehind();
                // Remove the ImageView copy of the FolderIcon and make the original visible.
                mDragLayer.removeView(mFolderIconImageView);
                fi.setVisibility(View.VISIBLE);
            }
        }
    });
    oa.start();
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) PropertyValuesHolder(android.animation.PropertyValuesHolder)

Example 42 with PropertyValuesHolder

use of android.animation.PropertyValuesHolder in project android_packages_apps_Launcher2 by CyanogenMod.

the class Folder method animateClosed.

public void animateClosed() {
    if (!(getParent() instanceof DragLayer))
        return;
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0);
    PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 0.9f);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 0.9f);
    final ObjectAnimator oa = mOpenCloseAnimator = LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, scaleX, scaleY);
    oa.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            onCloseComplete();
            setLayerType(LAYER_TYPE_NONE, null);
            mState = STATE_SMALL;
        }

        @Override
        public void onAnimationStart(Animator animation) {
            sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, getContext().getString(R.string.folder_closed));
            mState = STATE_ANIMATING;
        }
    });
    oa.setDuration(mExpandDuration);
    setLayerType(LAYER_TYPE_HARDWARE, null);
    buildLayer();
    post(new Runnable() {

        public void run() {
            // Check if the animator changed in the meantime
            if (oa != mOpenCloseAnimator)
                return;
            oa.start();
        }
    });
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) PropertyValuesHolder(android.animation.PropertyValuesHolder)

Example 43 with PropertyValuesHolder

use of android.animation.PropertyValuesHolder in project android_packages_apps_Launcher2 by CyanogenMod.

the class Folder method animateOpen.

public void animateOpen() {
    positionAndSizeAsIcon();
    if (!(getParent() instanceof DragLayer))
        return;
    centerAboutIcon();
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1);
    PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f);
    final ObjectAnimator oa = mOpenCloseAnimator = LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, scaleX, scaleY);
    oa.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, String.format(getContext().getString(R.string.folder_opened), mContent.getCountX(), mContent.getCountY()));
            mState = STATE_ANIMATING;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mState = STATE_OPEN;
            setLayerType(LAYER_TYPE_NONE, null);
            Cling cling = mLauncher.showFirstRunFoldersCling();
            if (cling != null) {
                cling.bringToFront();
            }
            setFocusOnFirstChild();
        }
    });
    oa.setDuration(mExpandDuration);
    setLayerType(LAYER_TYPE_HARDWARE, null);
    buildLayer();
    post(new Runnable() {

        public void run() {
            // Check if the animator changed in the meantime
            if (oa != mOpenCloseAnimator)
                return;
            oa.start();
        }
    });
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) PropertyValuesHolder(android.animation.PropertyValuesHolder)

Example 44 with PropertyValuesHolder

use of android.animation.PropertyValuesHolder in project android_packages_apps_Launcher2 by CyanogenMod.

the class AppWidgetResizeFrame method snapToWidget.

public void snapToWidget(boolean animate) {
    final DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
    int xOffset = mCellLayout.getLeft() + mCellLayout.getPaddingLeft() + mDragLayer.getPaddingLeft() - mWorkspace.getScrollX();
    int yOffset = mCellLayout.getTop() + mCellLayout.getPaddingTop() + mDragLayer.getPaddingTop() - mWorkspace.getScrollY();
    int newWidth = mWidgetView.getWidth() + 2 * mBackgroundPadding - mWidgetPaddingLeft - mWidgetPaddingRight;
    int newHeight = mWidgetView.getHeight() + 2 * mBackgroundPadding - mWidgetPaddingTop - mWidgetPaddingBottom;
    int newX = mWidgetView.getLeft() - mBackgroundPadding + xOffset + mWidgetPaddingLeft;
    int newY = mWidgetView.getTop() - mBackgroundPadding + yOffset + 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, 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 45 with PropertyValuesHolder

use of android.animation.PropertyValuesHolder in project AndroidChromium by JackyAndroid.

the class StackViewAnimation method createNewTabOpenedAnimator.

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;
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) Tab(org.chromium.chrome.browser.tab.Tab) ViewGroup(android.view.ViewGroup) ObjectAnimator(android.animation.ObjectAnimator) FrameLayout(android.widget.FrameLayout) PropertyValuesHolder(android.animation.PropertyValuesHolder) View(android.view.View)

Aggregations

PropertyValuesHolder (android.animation.PropertyValuesHolder)210 ObjectAnimator (android.animation.ObjectAnimator)144 Animator (android.animation.Animator)96 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)70 ValueAnimator (android.animation.ValueAnimator)64 Paint (android.graphics.Paint)33 AnimatorSet (android.animation.AnimatorSet)25 NonNull (android.support.annotation.NonNull)18 LinearInterpolator (android.view.animation.LinearInterpolator)18 Interpolator (android.view.animation.Interpolator)16 ArrayList (java.util.ArrayList)16 ViewGroup (android.view.ViewGroup)14 View (android.view.View)12 IntEvaluator (android.animation.IntEvaluator)11 Point (android.graphics.Point)11 Keyframe (android.animation.Keyframe)10 TimeAnimator (android.animation.TimeAnimator)10 Path (android.graphics.Path)10 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)8 Rect (android.graphics.Rect)7