Search in sources :

Example 66 with AnimatorSet

use of android.animation.AnimatorSet in project Klyph by jonathangerbaud.

the class DefaultHeaderTransformer method hideHeaderView.

@Override
public boolean hideHeaderView() {
    final boolean changeVis = mHeaderView.getVisibility() != View.GONE;
    if (changeVis) {
        Animator animator;
        if (mContentLayout.getAlpha() >= 0.5f) {
            // If the content layout is showing, translate and fade out
            animator = new AnimatorSet();
            ObjectAnimator transAnim = ObjectAnimator.ofFloat(mContentLayout, "translationY", 0f, -mContentLayout.getHeight());
            ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(mHeaderView, "alpha", 1f, 0f);
            ((AnimatorSet) animator).playTogether(transAnim, alphaAnim);
        } else {
            // If the content layout isn't showing (minimized), just fade out
            animator = ObjectAnimator.ofFloat(mHeaderView, "alpha", 1f, 0f);
        }
        animator.setDuration(mAnimationDuration);
        animator.addListener(new HideAnimationCallback());
        animator.start();
    }
    return changeVis;
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet)

Example 67 with AnimatorSet

use of android.animation.AnimatorSet in project KJFrameForAndroid by kymjs.

the class KJDragGridView method createTranslationAnimations.

/**
     * 创建移动动画
     * 
     * @param view
     * @param startX
     * @param endX
     * @param startY
     * @param endY
     * @return
     */
private AnimatorSet createTranslationAnimations(View view, float startX, float endX, float startY, float endY) {
    ObjectAnimator animX = ObjectAnimator.ofFloat(view, "translationX", startX, endX);
    ObjectAnimator animY = ObjectAnimator.ofFloat(view, "translationY", startY, endY);
    AnimatorSet animSetXY = new AnimatorSet();
    animSetXY.playTogether(animX, animY);
    return animSetXY;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet)

Example 68 with AnimatorSet

use of android.animation.AnimatorSet in project Klyph by jonathangerbaud.

the class KlyphAnimationAdapter method hideView.

private void hideView(View view) {
    ObjectAnimator animator = ObjectAnimator.ofFloat(view, "alpha", 0);
    AnimatorSet set = new AnimatorSet();
    set.play(animator);
    set.setDuration(0);
    set.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet)

Example 69 with AnimatorSet

use of android.animation.AnimatorSet in project Fairphone by Kwamecorp.

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 70 with AnimatorSet

use of android.animation.AnimatorSet in project Fairphone by Kwamecorp.

the class AppsCustomizeTabHost method onTabChanged.

@Override
public void onTabChanged(String tabId) {
    final AppsCustomizePagedView.ContentType type = getContentTypeForTabTag(tabId);
    // Animate the changing of the tab content by fading pages in and out
    final Resources res = getResources();
    final int duration = res.getInteger(R.integer.config_tabTransitionDuration);
    // We post a runnable here because there is a delay while the first page is loading and
    // the feedback from having changed the tab almost feels better than having it stick
    post(new Runnable() {

        @Override
        public void run() {
            if (mAppsCustomizePane.getMeasuredWidth() <= 0 || mAppsCustomizePane.getMeasuredHeight() <= 0) {
                reloadCurrentPage();
                return;
            }
            // Take the visible pages and re-parent them temporarily to mAnimatorBuffer
            // and then cross fade to the new pages
            int[] visiblePageRange = new int[2];
            mAppsCustomizePane.getVisiblePages(visiblePageRange);
            if (visiblePageRange[0] == -1 && visiblePageRange[1] == -1) {
                // If we can't get the visible page ranges, then just skip the animation
                reloadCurrentPage();
                return;
            }
            ArrayList<View> visiblePages = new ArrayList<View>();
            for (int i = visiblePageRange[0]; i <= visiblePageRange[1]; i++) {
                visiblePages.add(mAppsCustomizePane.getPageAt(i));
            }
            // We want the pages to be rendered in exactly the same way as they were when
            // their parent was mAppsCustomizePane -- so set the scroll on mAnimationBuffer
            // to be exactly the same as mAppsCustomizePane, and below, set the left/top
            // parameters to be correct for each of the pages
            mAnimationBuffer.scrollTo(mAppsCustomizePane.getScrollX(), 0);
            // add the pages to mAnimationBuffer in reverse order to match that behavior
            for (int i = visiblePages.size() - 1; i >= 0; i--) {
                View child = visiblePages.get(i);
                if (child instanceof PagedViewCellLayout) {
                    ((PagedViewCellLayout) child).resetChildrenOnKeyListeners();
                } else if (child instanceof PagedViewGridLayout) {
                    ((PagedViewGridLayout) child).resetChildrenOnKeyListeners();
                }
                PagedViewWidget.setDeletePreviewsWhenDetachedFromWindow(false);
                mAppsCustomizePane.removeView(child);
                PagedViewWidget.setDeletePreviewsWhenDetachedFromWindow(true);
                mAnimationBuffer.setAlpha(1f);
                mAnimationBuffer.setVisibility(View.VISIBLE);
                LayoutParams p = new FrameLayout.LayoutParams(child.getMeasuredWidth(), child.getMeasuredHeight());
                p.setMargins((int) child.getLeft(), (int) child.getTop(), 0, 0);
                mAnimationBuffer.addView(child, p);
            }
            // Toggle the new content
            onTabChangedStart();
            onTabChangedEnd(type);
            // Animate the transition
            ObjectAnimator outAnim = LauncherAnimUtils.ofFloat(mAnimationBuffer, "alpha", 0f);
            outAnim.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    mAnimationBuffer.setVisibility(View.GONE);
                    mAnimationBuffer.removeAllViews();
                }

                @Override
                public void onAnimationCancel(Animator animation) {
                    mAnimationBuffer.setVisibility(View.GONE);
                    mAnimationBuffer.removeAllViews();
                }
            });
            ObjectAnimator inAnim = LauncherAnimUtils.ofFloat(mAppsCustomizePane, "alpha", 1f);
            inAnim.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    reloadCurrentPage();
                }
            });
            final AnimatorSet animSet = LauncherAnimUtils.createAnimatorSet();
            animSet.playTogether(outAnim, inAnim);
            animSet.setDuration(duration);
            post(new Runnable() {

                public void run() {
                    animSet.start();
                }
            });
        }
    });
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) ArrayList(java.util.ArrayList) AnimatorSet(android.animation.AnimatorSet) TextView(android.widget.TextView) View(android.view.View) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) FrameLayout(android.widget.FrameLayout) Resources(android.content.res.Resources)

Aggregations

AnimatorSet (android.animation.AnimatorSet)491 ObjectAnimator (android.animation.ObjectAnimator)343 Animator (android.animation.Animator)285 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)144 View (android.view.View)109 ValueAnimator (android.animation.ValueAnimator)103 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)52 ArrayList (java.util.ArrayList)50 Rect (android.graphics.Rect)43 ViewGroup (android.view.ViewGroup)42 ImageView (android.widget.ImageView)36 TextView (android.widget.TextView)32 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)26 PropertyValuesHolder (android.animation.PropertyValuesHolder)25 Paint (android.graphics.Paint)25 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)25 Bitmap (android.graphics.Bitmap)17 Point (android.graphics.Point)15 OvershootInterpolator (android.view.animation.OvershootInterpolator)15 BitmapDrawable (android.graphics.drawable.BitmapDrawable)14