Search in sources :

Example 46 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project Carbon by ZieIony.

the class ShareToolbarActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_share_toolbar);
    final LinearLayout shareToolbar = (LinearLayout) findViewById(R.id.shareToolbar);
    final View root = shareToolbar.getRootView();
    findViewById(R.id.shareIcon).setOnClickListener(view -> {
        view.setVisibility(View.GONE);
        final ValueAnimator animator = ValueAnimator.ofFloat(0, 1);
        animator.setInterpolator(new AccelerateInterpolator());
        animator.addUpdateListener(animation -> {
            float frac = animator.getAnimatedFraction();
            float cornerRadius = MathUtils.lerp(shareToolbar.getHeight() / 2.0f, 0, frac);
            shareToolbar.setCornerRadius((int) cornerRadius);
            float left = MathUtils.lerp(root.getWidth() - shareToolbar.getHeight() - getResources().getDimension(R.dimen.carbon_padding), 0, frac);
            float right = MathUtils.lerp(root.getWidth() - getResources().getDimension(R.dimen.carbon_padding), root.getWidth(), frac);
            shareToolbar.layout((int) left, shareToolbar.getTop(), (int) right, shareToolbar.getBottom());
            shareToolbar.setElevation(frac);
            shareToolbar.setBackgroundColor(AnimUtils.lerpColor(frac, 0xff9ACE00, 0xffffffff));
            if (shareToolbar.getParent() != null)
                ((View) shareToolbar.getParent()).postInvalidate();
        });
        animator.setStartDelay(200);
        animator.setDuration(500);
        view.setEnabled(false);
        animator.start();
        final List<View> viewsWithTag = shareToolbar.findViewsWithTag("animate");
        view.getHandler().postDelayed(() -> {
            for (int i = 0; i < viewsWithTag.size(); i++) {
                final int finalI = i;
                view.getHandler().postDelayed(() -> viewsWithTag.get(finalI).setVisibility(View.VISIBLE), i * 40);
            }
        }, 500);
    });
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) View(android.view.View) LinearLayout(carbon.widget.LinearLayout)

Example 47 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project WoWoViewPager by Nightonke.

the class WoWoViewPager method setScrollDuration.

/**
     * set the duration of swiping in ms
     * @param scrollDuration duration in ms
     */
public void setScrollDuration(int scrollDuration) {
    this.scrollDuration = scrollDuration;
    try {
        Field mScroller;
        mScroller = ViewPager.class.getDeclaredField("mScroller");
        mScroller.setAccessible(true);
        WoWoScroller scroller = new WoWoScroller(this.getContext(), new AccelerateInterpolator());
        scroller.setmDuration(this.scrollDuration);
        mScroller.set(this, scroller);
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}
Also used : Field(java.lang.reflect.Field) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ViewPager(android.support.v4.view.ViewPager)

Example 48 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project Anki-Android by Ramblurr.

the class Reviewer method fillFlashcard.

public void fillFlashcard(boolean flip) {
    if (!flip) {
        Log.i(AnkiDroidApp.TAG, "base url = " + mBaseUrl);
        if (mCurrentSimpleInterface && mSimpleCard != null) {
            mSimpleCard.setText(mCardContent);
        } else if (!mUseQuickUpdate && mCard != null && mNextCard != null) {
            mNextCard.setBackgroundColor(mCurrentBackgroundColor);
            mNextCard.loadDataWithBaseURL(mBaseUrl, mCardContent.toString(), "text/html", "utf-8", null);
            mNextCard.setVisibility(View.VISIBLE);
            mCardFrame.removeView(mCard);
            mCard.destroy();
            mCard = mNextCard;
            mNextCard = createWebView();
            mNextCard.setVisibility(View.GONE);
            mCardFrame.addView(mNextCard, 0);
            // hunt for input issue 720, like android issue 3341
            if (AnkiDroidApp.SDK_VERSION <= 7) {
                mCard.setFocusableInTouchMode(true);
            }
        } else if (mCard != null) {
            mCard.loadDataWithBaseURL(mBaseUrl, mCardContent.toString(), "text/html", "utf-8", null);
            mCard.setBackgroundColor(mCurrentBackgroundColor);
        }
        if (mChangeBorderStyle) {
            switch(mCurrentBackgroundColor) {
                case Color.WHITE:
                    if (mInvertedColors) {
                        mInvertedColors = false;
                        invertColors(false);
                    }
                    break;
                case Color.BLACK:
                    if (!mInvertedColors) {
                        mInvertedColors = true;
                        invertColors(true);
                    }
                    break;
                default:
                    if (Themes.getTheme() != Themes.THEME_BLUE) {
                        mMainLayout.setBackgroundColor(mCurrentBackgroundColor);
                    }
                    if (mInvertedColors != mNightMode) {
                        mInvertedColors = mNightMode;
                        invertColors(mNightMode);
                    }
            }
        }
        if (!mShowAnimations && mShowTimer && mCardTimer.getVisibility() == View.INVISIBLE) {
            switchTopBarVisibility(View.VISIBLE);
        }
        if (!sDisplayAnswer) {
            updateForNewCard();
            if (mShowWhiteboard) {
                mWhiteboard.clear();
            }
            setNextCardAnimation(false);
        }
    } else {
        Animation3D rotation;
        boolean directionToLeft = true;
        switch(mNextAnimation) {
            case ANIMATION_TURN:
                rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 9, Animation3D.ANIMATION_TURN, true, true, this);
                rotation.setDuration(mAnimationDurationTurn);
                rotation.setInterpolator(new AccelerateDecelerateInterpolator());
                break;
            case ANIMATION_NEXT_CARD_FROM_LEFT:
                directionToLeft = false;
            case ANIMATION_NEXT_CARD_FROM_RIGHT:
                rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 0, Animation3D.ANIMATION_EXCHANGE_CARD, directionToLeft, true, this);
                rotation.setDuration(mAnimationDurationMove);
                rotation.setInterpolator(new AccelerateDecelerateInterpolator());
                break;
            case ANIMATION_SLIDE_OUT_TO_RIGHT:
                directionToLeft = false;
            case ANIMATION_SLIDE_OUT_TO_LEFT:
                fillFlashcard(false);
                rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 0, Animation3D.ANIMATION_SLIDE_OUT_CARD, directionToLeft, true, this);
                rotation.setDuration(mAnimationDurationMove);
                rotation.setInterpolator(new AccelerateInterpolator());
                switchTopBarVisibility(View.INVISIBLE);
                break;
            case ANIMATION_SLIDE_IN_FROM_LEFT:
                directionToLeft = false;
            case ANIMATION_SLIDE_IN_FROM_RIGHT:
                fillFlashcard(false);
                rotation = new Animation3D(mCardContainer.getWidth(), mCardContainer.getHeight(), 0, Animation3D.ANIMATION_SLIDE_IN_CARD, directionToLeft, true, this);
                rotation.setDuration(mAnimationDurationMove);
                rotation.setInterpolator(new DecelerateInterpolator());
                switchTopBarVisibility(View.VISIBLE);
                break;
            case ANIMATION_NO_ANIMATION:
            default:
                return;
        }
        rotation.reset();
        mCardContainer.setDrawingCacheEnabled(true);
        mCardContainer.setDrawingCacheBackgroundColor(Themes.getBackgroundColor());
        mCardContainer.clearAnimation();
        mCardContainer.startAnimation(rotation);
    }
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) Animation3D(com.ichi2.anim.Animation3D)

Example 49 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project paper-onboarding-android by Ramotion.

the class PaperOnboardingEngine method createBGAnimatorSet.

/**
     * @param color new background color for new
     * @return animator set with background color circular reveal animation
     */
protected AnimatorSet createBGAnimatorSet(final int color) {
    final View bgColorView = new ImageView(mAppContext);
    bgColorView.setLayoutParams(new RelativeLayout.LayoutParams(mRootLayout.getWidth(), mRootLayout.getHeight()));
    bgColorView.setBackgroundColor(color);
    mBackgroundContainer.addView(bgColorView);
    int[] pos = calculateCurrentCenterCoordinatesOfPagerElement(mActiveElementIndex);
    float finalRadius = mRootLayout.getWidth() > mRootLayout.getHeight() ? mRootLayout.getWidth() : mRootLayout.getHeight();
    AnimatorSet bgAnimSet = new AnimatorSet();
    Animator fadeIn = ObjectAnimator.ofFloat(bgColorView, "alpha", 0, 1);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Animator circularReveal = ViewAnimationUtils.createCircularReveal(bgColorView, pos[0], pos[1], 0, finalRadius);
        circularReveal.setInterpolator(new AccelerateInterpolator());
        bgAnimSet.playTogether(circularReveal, fadeIn);
    } else {
        bgAnimSet.playTogether(fadeIn);
    }
    bgAnimSet.setDuration(ANIM_BACKGROUND_TIME);
    bgAnimSet.addListener(new AnimatorEndListener() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mRootLayout.setBackgroundColor(color);
            bgColorView.setVisibility(View.GONE);
            mBackgroundContainer.removeView(bgColorView);
        }
    });
    return bgAnimSet;
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) AnimatorEndListener(com.ramotion.paperonboarding.listeners.AnimatorEndListener) RelativeLayout(android.widget.RelativeLayout) AnimatorSet(android.animation.AnimatorSet) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 50 with AccelerateInterpolator

use of android.view.animation.AccelerateInterpolator in project android_frameworks_base by ParanoidAndroid.

the class VelocityTest method testDragAcceleration.

@MediumTest
public void testDragAcceleration() {
    long t = System.currentTimeMillis();
    VelocityTracker vt = VelocityTracker.obtain();
    drag(vt, 100, 200, 100, 200, 15, t, 400, new AccelerateInterpolator());
    vt.computeCurrentVelocity(1000);
    assertGreater(250.0f, vt.getXVelocity());
    assertGreater(250.0f, vt.getYVelocity());
    vt.recycle();
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) VelocityTracker(android.view.VelocityTracker) MediumTest(android.test.suitebuilder.annotation.MediumTest)

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