Search in sources :

Example 36 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project loadtoast by code-mc.

the class LoadToast method slideUp.

private void slideUp() {
    ViewPropertyAnimator.animate(mView).setStartDelay(1000).alpha(0f).translationY(-mView.getHeight() + mTranslationY).setInterpolator(new AccelerateInterpolator()).setDuration(300).start();
    mVisible = false;
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator)

Example 37 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project cw-advandroid by commonsguy.

the class SlidingPanel method toggle.

public void toggle() {
    TranslateAnimation anim = null;
    AnimationSet set = new AnimationSet(true);
    isOpen = !isOpen;
    if (isOpen) {
        setVisibility(View.VISIBLE);
        anim = new TranslateAnimation(0.0f, 0.0f, getHeight(), 0.0f);
    } else {
        anim = new TranslateAnimation(0.0f, 0.0f, 0.0f, getHeight());
        anim.setAnimationListener(collapseListener);
        set.addAnimation(fadeOut);
    }
    set.addAnimation(anim);
    set.setDuration(speed);
    set.setInterpolator(new AccelerateInterpolator(1.0f));
    startAnimation(set);
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) TranslateAnimation(android.view.animation.TranslateAnimation) AnimationSet(android.view.animation.AnimationSet)

Example 38 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project Swipeable-Cards by kikoso.

the class CardContainer method onTouchEvent.

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (mTopCard == null) {
        return false;
    }
    if (mGestureDetector.onTouchEvent(event)) {
        return true;
    }
    Log.d("Touch Event", MotionEvent.actionToString(event.getActionMasked()) + " ");
    final int pointerIndex;
    final float x, y;
    final float dx, dy;
    switch(event.getActionMasked()) {
        case MotionEvent.ACTION_DOWN:
            mTopCard.getHitRect(childRect);
            pointerIndex = event.getActionIndex();
            x = event.getX(pointerIndex);
            y = event.getY(pointerIndex);
            if (!childRect.contains((int) x, (int) y)) {
                return false;
            }
            mLastTouchX = x;
            mLastTouchY = y;
            mActivePointerId = event.getPointerId(pointerIndex);
            float[] points = new float[] { x - mTopCard.getLeft(), y - mTopCard.getTop() };
            mTopCard.getMatrix().invert(mMatrix);
            mMatrix.mapPoints(points);
            mTopCard.setPivotX(points[0]);
            mTopCard.setPivotY(points[1]);
            break;
        case MotionEvent.ACTION_MOVE:
            pointerIndex = event.findPointerIndex(mActivePointerId);
            x = event.getX(pointerIndex);
            y = event.getY(pointerIndex);
            dx = x - mLastTouchX;
            dy = y - mLastTouchY;
            if (Math.abs(dx) > mTouchSlop || Math.abs(dy) > mTouchSlop) {
                mDragging = true;
            }
            if (!mDragging) {
                return true;
            }
            mTopCard.setTranslationX(mTopCard.getTranslationX() + dx);
            mTopCard.setTranslationY(mTopCard.getTranslationY() + dy);
            mTopCard.setRotation(40 * mTopCard.getTranslationX() / (getWidth() / 2.f));
            mLastTouchX = x;
            mLastTouchY = y;
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            if (!mDragging) {
                return true;
            }
            mDragging = false;
            mActivePointerId = INVALID_POINTER_ID;
            ValueAnimator animator = ObjectAnimator.ofPropertyValuesHolder(mTopCard, PropertyValuesHolder.ofFloat("translationX", 0), PropertyValuesHolder.ofFloat("translationY", 0), PropertyValuesHolder.ofFloat("rotation", (float) Math.toDegrees(mRandom.nextGaussian() * DISORDERED_MAX_ROTATION_RADIANS)), PropertyValuesHolder.ofFloat("pivotX", mTopCard.getWidth() / 2.f), PropertyValuesHolder.ofFloat("pivotY", mTopCard.getHeight() / 2.f)).setDuration(250);
            animator.setInterpolator(new AccelerateInterpolator());
            animator.start();
            break;
        case MotionEvent.ACTION_POINTER_UP:
            pointerIndex = event.getActionIndex();
            final int pointerId = event.getPointerId(pointerIndex);
            if (pointerId == mActivePointerId) {
                final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
                mLastTouchX = event.getX(newPointerIndex);
                mLastTouchY = event.getY(newPointerIndex);
                mActivePointerId = event.getPointerId(newPointerIndex);
            }
            break;
    }
    return true;
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ValueAnimator(android.animation.ValueAnimator)

Example 39 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project Fairphone by Kwamecorp.

the class FolderIcon method onDrop.

private void onDrop(final ShortcutInfo item, DragView animateView, Rect finalRect, float scaleRelativeToDragLayer, int index, Runnable postAnimationRunnable, DragObject d) {
    item.cellX = -1;
    item.cellY = -1;
    // will not have a view to animate
    if (animateView != null) {
        DragLayer dragLayer = mLauncher.getDragLayer();
        Rect from = new Rect();
        dragLayer.getViewRectRelativeToSelf(animateView, from);
        Rect to = finalRect;
        if (to == null) {
            to = new Rect();
            Workspace workspace = mLauncher.getWorkspace();
            // Set cellLayout and this to it's final state to compute final animation locations
            workspace.setFinalTransitionTransform((CellLayout) getParent().getParent());
            float scaleX = getScaleX();
            float scaleY = getScaleY();
            setScaleX(1.0f);
            setScaleY(1.0f);
            scaleRelativeToDragLayer = dragLayer.getDescendantRectRelativeToSelf(this, to);
            // Finished computing final animation locations, restore current state
            setScaleX(scaleX);
            setScaleY(scaleY);
            workspace.resetTransitionTransform((CellLayout) getParent().getParent());
        }
        int[] center = new int[2];
        float scale = getLocalCenterForIndex(index, center);
        center[0] = (int) Math.round(scaleRelativeToDragLayer * center[0]);
        center[1] = (int) Math.round(scaleRelativeToDragLayer * center[1]);
        to.offset(center[0] - animateView.getMeasuredWidth() / 2, center[1] - animateView.getMeasuredHeight() / 2);
        float finalAlpha = index < NUM_ITEMS_IN_PREVIEW ? 0.5f : 0f;
        float finalScale = scale * scaleRelativeToDragLayer;
        dragLayer.animateView(animateView, from, to, finalAlpha, 1, 1, finalScale, finalScale, DROP_IN_ANIMATION_DURATION, new DecelerateInterpolator(2), new AccelerateInterpolator(2), postAnimationRunnable, DragLayer.ANIMATION_END_DISAPPEAR, null);
        addItem(item);
        mHiddenItems.add(item);
        postDelayed(new Runnable() {

            public void run() {
                mHiddenItems.remove(item);
                invalidate();
            }
        }, DROP_IN_ANIMATION_DURATION);
    } else {
        addItem(item);
    }
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) Rect(android.graphics.Rect) AccelerateInterpolator(android.view.animation.AccelerateInterpolator)

Example 40 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project Euclid by Yalantis.

the class EuclidActivity method getCloseProfileAnimatorSet.

/**
     * This method creates if needed the set of transition animations, which hides profile toolbar, profile avatar
     * and profile details views. Also it calls notifyDataSetChanged() on the ListView's adapter,
     * so it starts slide-in left animation on list items.
     *
     * @return - animator set that starts transition animations.
     */
private AnimatorSet getCloseProfileAnimatorSet() {
    if (mCloseProfileAnimatorSet == null) {
        Animator profileToolbarAnimator = ObjectAnimator.ofFloat(mToolbarProfile, View.X, 0, mToolbarProfile.getWidth());
        Animator profilePhotoAnimator = ObjectAnimator.ofFloat(mOverlayListItemView, View.X, 0, mOverlayListItemView.getWidth());
        profilePhotoAnimator.setStartDelay(getStepDelayHideDetailsAnimation());
        Animator profileButtonAnimator = ObjectAnimator.ofFloat(mButtonProfile, View.X, mInitialProfileButtonX, mOverlayListItemView.getWidth() + mInitialProfileButtonX);
        profileButtonAnimator.setStartDelay(getStepDelayHideDetailsAnimation() * 2);
        Animator profileDetailsAnimator = ObjectAnimator.ofFloat(mProfileDetails, View.X, 0, mToolbarProfile.getWidth());
        profileDetailsAnimator.setStartDelay(getStepDelayHideDetailsAnimation() * 2);
        List<Animator> profileAnimators = new ArrayList<>();
        profileAnimators.add(profileToolbarAnimator);
        profileAnimators.add(profilePhotoAnimator);
        profileAnimators.add(profileButtonAnimator);
        profileAnimators.add(profileDetailsAnimator);
        mCloseProfileAnimatorSet = new AnimatorSet();
        mCloseProfileAnimatorSet.playTogether(profileAnimators);
        mCloseProfileAnimatorSet.setDuration(getAnimationDurationCloseProfileDetails());
        mCloseProfileAnimatorSet.setInterpolator(new AccelerateInterpolator());
        mCloseProfileAnimatorSet.addListener(new Animator.AnimatorListener() {

            @Override
            public void onAnimationStart(Animator animation) {
                if (mListViewAnimator != null) {
                    mListViewAnimator.reset();
                    mListViewAnimationAdapter.notifyDataSetChanged();
                }
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                mToolbarProfile.setVisibility(View.INVISIBLE);
                mButtonProfile.setVisibility(View.INVISIBLE);
                mProfileDetails.setVisibility(View.INVISIBLE);
                mListView.setEnabled(true);
                mListViewAnimator.disableAnimations();
                mState = EuclidState.Closed;
            }

            @Override
            public void onAnimationCancel(Animator animation) {
            }

            @Override
            public void onAnimationRepeat(Animator animation) {
            }
        });
    }
    return mCloseProfileAnimatorSet;
}
Also used : Animator(android.animation.Animator) SupportAnimator(io.codetail.animation.SupportAnimator) ViewAnimator(com.nhaarman.listviewanimations.appearance.ViewAnimator) ObjectAnimator(android.animation.ObjectAnimator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ArrayList(java.util.ArrayList) AnimatorSet(android.animation.AnimatorSet)

Aggregations

AccelerateInterpolator (android.view.animation.AccelerateInterpolator)186 Animator (android.animation.Animator)62 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)54 View (android.view.View)52 ObjectAnimator (android.animation.ObjectAnimator)41 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)40 ImageView (android.widget.ImageView)26 AnimatorSet (android.animation.AnimatorSet)24 TextView (android.widget.TextView)23 Animation (android.view.animation.Animation)21 ValueAnimator (android.animation.ValueAnimator)17 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)14 LinearInterpolator (android.view.animation.LinearInterpolator)14 TranslateAnimation (android.view.animation.TranslateAnimation)14 OvershootInterpolator (android.view.animation.OvershootInterpolator)13 Point (android.graphics.Point)12 Paint (android.graphics.Paint)10 Interpolator (android.view.animation.Interpolator)9 AlphaAnimation (android.view.animation.AlphaAnimation)8 AnticipateOvershootInterpolator (android.view.animation.AnticipateOvershootInterpolator)8