Example usage for android.view.animation OvershootInterpolator OvershootInterpolator

List of usage examples for android.view.animation OvershootInterpolator OvershootInterpolator

Introduction

In this page you can find the example usage for android.view.animation OvershootInterpolator OvershootInterpolator.

Prototype

public OvershootInterpolator() 

Source Link

Usage

From source file:com.test.slidebutton.SlideButton.java

/**
 * max_leftmin_left//from w  ww.  j  a  va 2s  .c  om
 * @param toRight
 */
private void moveTo(final boolean toRight) {
    ObjectAnimator anim = ObjectAnimator.ofInt(this, "sliderCurrentLeft", sliderCurrentLeft,
            toRight ? max_left : min_left);
    anim.setInterpolator(new OvershootInterpolator());
    anim.setDuration(200);
    anim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (toRight) {
                isOpen = true;
                if (listener != null) {
                    listener.open();
                }
                sliderCurrentLeft = sliderMoveStartLeft = max_left;
            } else {
                isOpen = false;
                if (listener != null) {
                    listener.close();
                }
                sliderCurrentLeft = sliderMoveStartLeft = min_left;
            }
            invalidateView();
        }
    });
    anim.start();
}

From source file:com.github.jokar.rxupload.widget.ProgressDownloadView.java

public void drawSuccess() {
    mTarget = 100;//from w w  w.java 2s  . c  om

    final ObjectAnimator successAnim = ObjectAnimator.ofFloat(this, "flip", 1, -1);
    successAnim.setInterpolator(new OvershootInterpolator());
    successAnim.setDuration(ANIMATION_DURATION_BASE);

    ObjectAnimator anim = ObjectAnimator.ofFloat(this, "progress", getProgress(), mTarget);
    anim.setInterpolator(new DecelerateInterpolator());
    anim.setDuration((long) (ANIMATION_DURATION_BASE + Math.abs(mTarget * 10 - getProgress() * 10) / 2));
    anim.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mState = State.STATE_SUCCESS;
            successAnim.start();
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });
    anim.start();
}

From source file:com.alimuzaffar.lib.pin.PinEntryEditText.java

private void animatePopIn() {
    ValueAnimator va = ValueAnimator.ofFloat(1, getPaint().getTextSize());
    va.setDuration(200);/*  ww w.  j av  a 2  s . com*/
    va.setInterpolator(new OvershootInterpolator());
    va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mLastCharPaint.setTextSize((Float) animation.getAnimatedValue());
            PinEntryEditText.this.invalidate();
        }
    });
    if (getText().length() == mMaxLength && mOnPinEnteredListener != null) {
        va.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                mOnPinEnteredListener.onPinEntered(getText());
            }

            @Override
            public void onAnimationCancel(Animator animation) {
            }

            @Override
            public void onAnimationRepeat(Animator animation) {
            }
        });
    }
    va.start();
}

From source file:com.alimuzaffar.lib.pin.PinEntryEditText.java

private void animateBottomUp(CharSequence text, final int start) {
    mCharBottom[start] = mLineCoords[start].bottom - mTextBottomPadding;
    ValueAnimator animUp = ValueAnimator.ofFloat(mCharBottom[start] + getPaint().getTextSize(),
            mCharBottom[start]);/*w ww  .  j  av  a2 s  .  c  o  m*/
    animUp.setDuration(300);
    animUp.setInterpolator(new OvershootInterpolator());
    animUp.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            Float value = (Float) animation.getAnimatedValue();
            mCharBottom[start] = value;
            PinEntryEditText.this.invalidate();
        }
    });

    mLastCharPaint.setAlpha(255);
    ValueAnimator animAlpha = ValueAnimator.ofInt(0, 255);
    animAlpha.setDuration(300);
    animAlpha.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            Integer value = (Integer) animation.getAnimatedValue();
            mLastCharPaint.setAlpha(value);
        }
    });

    AnimatorSet set = new AnimatorSet();
    if (text.length() == mMaxLength && mOnPinEnteredListener != null) {
        set.addListener(new Animator.AnimatorListener() {

            @Override
            public void onAnimationStart(Animator animation) {
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                mOnPinEnteredListener.onPinEntered(getText());
            }

            @Override
            public void onAnimationCancel(Animator animation) {
            }

            @Override
            public void onAnimationRepeat(Animator animation) {

            }
        });
    }
    set.playTogether(animUp, animAlpha);
    set.start();
}

From source file:com.google.android.apps.muzei.MuzeiActivity.java

private void updateUiMode() {
    // TODO: this should really just use fragment transactions and transitions

    int newUiMode = UI_MODE_INTRO;
    if (mWallpaperActive) {
        newUiMode = UI_MODE_TUTORIAL;/*from  w  w  w . j  a va 2 s.  c om*/
        if (mSeenTutorial) {
            newUiMode = UI_MODE_ART_DETAIL;
        }
    }

    if (mUiMode == newUiMode) {
        return;
    }

    // Crossfade between main containers
    final View oldContainerView = getMainContainerForUiMode(mUiMode);
    final View newContainerView = getMainContainerForUiMode(newUiMode);

    if (oldContainerView != null) {
        oldContainerView.animate().alpha(0).setDuration(1000).withEndAction(new Runnable() {
            @Override
            public void run() {
                oldContainerView.setVisibility(View.GONE);
            }
        });
    }

    if (newContainerView != null) {
        if (newContainerView.getAlpha() == 1) {
            newContainerView.setAlpha(0);
        }
        newContainerView.setVisibility(View.VISIBLE);
        newContainerView.animate().alpha(1).setDuration(1000).withEndAction(null);
    }

    // Special work
    if (newUiMode == UI_MODE_INTRO) {
        final View activateButton = findViewById(R.id.activate_muzei_button);
        activateButton.setAlpha(0);
        final AnimatedMuzeiLogoFragment logoFragment = (AnimatedMuzeiLogoFragment) getFragmentManager()
                .findFragmentById(R.id.animated_logo_fragment);
        logoFragment.reset();
        logoFragment.setOnFillStartedCallback(new Runnable() {
            @Override
            public void run() {
                activateButton.animate().alpha(1f).setDuration(500);
            }
        });
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                logoFragment.start();
            }
        }, 1000);
    }

    if (mUiMode == UI_MODE_INTRO || newUiMode == UI_MODE_INTRO) {
        FragmentManager fm = getSupportFragmentManager();
        Fragment demoFragment = fm.findFragmentById(R.id.demo_view_container);
        if (newUiMode == UI_MODE_INTRO && demoFragment == null) {
            fm.beginTransaction()
                    .add(R.id.demo_view_container, MuzeiRendererFragment.createInstance(true, true)).commit();
        } else if (newUiMode != UI_MODE_INTRO && demoFragment != null) {
            fm.beginTransaction().remove(demoFragment).commit();
        }
    }

    if (newUiMode == UI_MODE_TUTORIAL) {
        float animateDistance = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100,
                getResources().getDisplayMetrics());
        View mainTextView = findViewById(R.id.tutorial_main_text);
        mainTextView.setAlpha(0);
        mainTextView.setTranslationY(-animateDistance / 5);

        View subTextView = findViewById(R.id.tutorial_sub_text);
        subTextView.setAlpha(0);
        subTextView.setTranslationY(-animateDistance / 5);

        final View affordanceView = findViewById(R.id.tutorial_icon_affordance);
        affordanceView.setAlpha(0);
        affordanceView.setTranslationY(animateDistance);

        View iconTextView = findViewById(R.id.tutorial_icon_text);
        iconTextView.setAlpha(0);
        iconTextView.setTranslationY(animateDistance);

        AnimatorSet set = new AnimatorSet();
        set.setStartDelay(500);
        set.setDuration(250);
        set.playTogether(ObjectAnimator.ofFloat(mainTextView, View.ALPHA, 1f),
                ObjectAnimator.ofFloat(subTextView, View.ALPHA, 1f));
        set.start();

        set = new AnimatorSet();
        set.setStartDelay(2000);

        // Bug in older versions where set.setInterpolator didn't work
        Interpolator interpolator = new OvershootInterpolator();
        ObjectAnimator a1 = ObjectAnimator.ofFloat(affordanceView, View.TRANSLATION_Y, 0);
        ObjectAnimator a2 = ObjectAnimator.ofFloat(iconTextView, View.TRANSLATION_Y, 0);
        ObjectAnimator a3 = ObjectAnimator.ofFloat(mainTextView, View.TRANSLATION_Y, 0);
        ObjectAnimator a4 = ObjectAnimator.ofFloat(subTextView, View.TRANSLATION_Y, 0);
        a1.setInterpolator(interpolator);
        a2.setInterpolator(interpolator);
        a3.setInterpolator(interpolator);
        a4.setInterpolator(interpolator);
        set.setDuration(500).playTogether(ObjectAnimator.ofFloat(affordanceView, View.ALPHA, 1f),
                ObjectAnimator.ofFloat(iconTextView, View.ALPHA, 1f), a1, a2, a3, a4);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            set.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    ImageView emanateView = (ImageView) findViewById(R.id.tutorial_icon_emanate);
                    AnimatedVectorDrawable avd = (AnimatedVectorDrawable) getResources()
                            .getDrawable(R.drawable.avd_tutorial_icon_emanate, getTheme());
                    emanateView.setImageDrawable(avd);
                    avd.start();
                }
            });
        }
        set.start();
    }

    mPanScaleProxyView.setVisibility(newUiMode == UI_MODE_ART_DETAIL ? View.VISIBLE : View.GONE);

    mUiMode = newUiMode;

    maybeUpdateArtDetailOpenedClosed();
}

From source file:org.quantumbadger.redreader.fragments.CommentListingFragment.java

@Override
public void onCommentListingRequestAllItemsDownloaded(final ArrayList<RedditCommentListItem> items) {

    mCommentListingManager.addComments(items);

    if (mFloatingToolbar != null) {
        mFloatingToolbar.setVisibility(View.VISIBLE);
        final Animation animation = AnimationUtils.loadAnimation(getContext(), R.anim.slide_in_from_bottom);
        animation.setInterpolator(new OvershootInterpolator());
        mFloatingToolbar.startAnimation(animation);
    }/*ww w  .j  a va2  s .  c o  m*/

    mUrlsToDownload.removeFirst();

    final LinearLayoutManager layoutManager = (LinearLayoutManager) mRecyclerView.getLayoutManager();

    if (mPreviousFirstVisibleItemPosition != null
            && layoutManager.getItemCount() > mPreviousFirstVisibleItemPosition) {

        layoutManager.scrollToPositionWithOffset(mPreviousFirstVisibleItemPosition, 0);

        mPreviousFirstVisibleItemPosition = null;
    }

    if (mUrlsToDownload.isEmpty()) {

        if (mCommentListingManager.getCommentCount() == 0) {

            final View emptyView = LayoutInflater.from(getContext()).inflate(R.layout.no_comments_yet,
                    mRecyclerView, false);

            if (mCommentListingManager.isSearchListing()) {
                ((TextView) emptyView.findViewById(R.id.empty_view_text)).setText(R.string.no_search_results);
            }

            mCommentListingManager.addViewToItems(emptyView);

        } else {

            final View blankView = new View(getContext());
            blankView.setMinimumWidth(1);
            blankView.setMinimumHeight(General.dpToPixels(getContext(), 96));
            mCommentListingManager.addViewToItems(blankView);
        }

        mCommentListingManager.setLoadingVisible(false);

    } else {
        makeNextRequest(getActivity());
    }
}

From source file:com.saphion.stencilweather.activities.MainActivity.java

@Override
public void onClick(final View view) {
    initiateActions(true);//  ww  w .j  a v  a  2  s  . c  o  m
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            switch (view.getId()) {
            case R.id.fab_graph:
                slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED);
                materialMenu.animateIconState(MaterialMenuDrawable.IconState.X);
                toolbar.getMenu().clear();
                actionBarContent(false);
                toolbar.setTitle(navAdapter.getItem(navSpinner.getSelectedItemPosition()));
                break;
            case R.id.fab_map:
                Intent mapIntent = new Intent(MainActivity.this, MapActivity.class);
                mapIntent.putExtra("position", navSpinner.getSelectedItemPosition());
                startActivity(mapIntent);
                finish();

                break;
            case R.id.fab_share:

                AlertDialog.Builder mBuilder = new AlertDialog.Builder(MainActivity.this);

                View mView = LayoutInflater.from(MainActivity.this).inflate(R.layout.share_weather_layout,
                        null);

                mBuilder.setView(mView);

                shareContainer = mView.findViewById(R.id.shareableContainer);

                final List<Drawable> packageIcons = new ArrayList<>();
                final List<String> appNames = new ArrayList<>();
                final List<String> packageNames = new ArrayList<>();
                final List<String> classNames = new ArrayList<>();
                final RecyclerView shareRecyclerView = (RecyclerView) mView.findViewById(R.id.rvWeatherShare);
                final View flShareableApps = mView.findViewById(R.id.flShareableApps);
                flShareableApps.setAlpha(0);
                shareRecyclerView.setVisibility(View.VISIBLE);

                new AsyncTask<Void, Void, Void>() {

                    @Override
                    protected Void doInBackground(Void... voids) {
                        Intent sendIntent = new Intent();
                        sendIntent.setAction(Intent.ACTION_SEND);
                        sendIntent.setType("image/jpeg");
                        List<ResolveInfo> resolveInfoList = getPackageManager()
                                .queryIntentActivities(sendIntent, 0);

                        Collections.sort(resolveInfoList,
                                new ResolveInfo.DisplayNameComparator(getPackageManager()));

                        for (ResolveInfo resolveInfo : resolveInfoList) {
                            Drawable icon = resolveInfo.loadIcon(getPackageManager());
                            String name = resolveInfo.loadLabel(getPackageManager()).toString();

                            packageIcons.add(icon);
                            appNames.add(name);
                            packageNames.add(resolveInfo.activityInfo.packageName);
                            classNames.add(resolveInfo.activityInfo.name);

                        }
                        return null;
                    }

                    @Override
                    protected void onPostExecute(Void aVoid) {
                        super.onPostExecute(aVoid);

                        ShareItemViewAdapter shareAdapter = new ShareItemViewAdapter(MainActivity.this,
                                packageIcons, appNames, packageNames, classNames);
                        LinearLayoutManager layoutManager = new LinearLayoutManager(MainActivity.this);
                        layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
                        shareRecyclerView.setLayoutManager(layoutManager);
                        shareRecyclerView.setAdapter(shareAdapter);

                        YoYo.with(Techniques.SlideInDown).duration(500).interpolate(new OvershootInterpolator())
                                .playOn(flShareableApps);

                    }
                }.execute();

                mShareDialog = mBuilder.create();
                mShareDialog.getWindow().setWindowAnimations(R.style.DialogAnimation);
                mShareDialog.getWindow()
                        .setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
                mShareDialog.show();

                break;
            }
        }
    }, 200);

}

From source file:self.philbrown.droidQuery.$.java

/**
 * This reusable chunk of code can set up the given animation using the given animation options
 * @param options the options used to manipulate how the animation behaves
 * @return the container for placing views that will be animated using the given options
 */// w w w . ja v a2  s  .  com
private AnimatorSet animationWithOptions(final AnimationOptions options, List<Animator> animators) {
    AnimatorSet animation = new AnimatorSet();
    animation.playTogether(animators);
    animation.setDuration(options.duration());
    animation.addListener(new AnimatorListener() {

        @Override
        public void onAnimationCancel(Animator animation) {
            if (options.fail() != null)
                options.fail().invoke($.this);
            if (options.complete() != null)
                options.complete().invoke($.this);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (options.success() != null)
                options.success().invoke($.this);
            if (options.complete() != null)
                options.complete().invoke($.this);
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }

        @Override
        public void onAnimationStart(Animator animation) {
        }

    });
    Interpolator interpolator = null;
    if (options.easing() == null)
        options.easing(Easing.LINEAR);
    final Easing easing = options.easing();
    switch (easing) {
    case ACCELERATE: {
        interpolator = new AccelerateInterpolator();
        break;
    }
    case ACCELERATE_DECELERATE: {
        interpolator = new AccelerateDecelerateInterpolator();
        break;
    }
    case ANTICIPATE: {
        interpolator = new AnticipateInterpolator();
        break;
    }
    case ANTICIPATE_OVERSHOOT: {
        interpolator = new AnticipateOvershootInterpolator();
        break;
    }
    case BOUNCE: {
        interpolator = new BounceInterpolator();
        break;
    }
    case DECELERATE: {
        interpolator = new DecelerateInterpolator();
        break;
    }
    case OVERSHOOT: {
        interpolator = new OvershootInterpolator();
        break;
    }
    //linear is default.
    case LINEAR:
    default:
        interpolator = new LinearInterpolator();
        break;
    }

    //allow custom interpolator
    if (options.specialEasing() != null)
        interpolator = options.specialEasing();

    animation.setInterpolator(interpolator);

    return animation;
}

From source file:ac.robinson.paperchains.PaperChainsActivity.java

private void animateRecordingInterface(int direction, View keyView) {
    mPlayButton.setVisibility(View.VISIBLE);
    mDeleteButton.setVisibility(View.VISIBLE);
    mSaveButton.setVisibility(View.VISIBLE);

    // animate the control buttons out to be equally spaced around the record button
    float buttonOffset = -mPlayButton.getWidth();
    PointF centre = new PointF(0, 0);
    PointF startingPoint = new PointF(0, buttonOffset);
    double radRot = Math.toRadians(-120);
    double cosRot = Math.cos(radRot);
    double sinRot = Math.sin(radRot);
    QRImageParser.rotatePoint(startingPoint, centre, cosRot, sinRot);
    float leftX = startingPoint.x;
    float leftY = startingPoint.y;
    QRImageParser.rotatePoint(startingPoint, centre, cosRot, sinRot);
    float rightX = startingPoint.x;
    float rightY = startingPoint.y;

    RelativeLayout parent;// w  ww.j  ava 2  s  . com
    AnimatorSet buttonAnimator = new AnimatorSet();
    switch (direction) {
    case 1: // out
        // on an outward animation, we want the three minor buttons to have priority so the record button's
        // larger click area doesn't capture their clicks
        mPlayButton.bringToFront();
        mDeleteButton.bringToFront();
        mSaveButton.bringToFront();
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
            // need to manually re-layout before KitKat
            parent = (RelativeLayout) mPlayButton.getParent();
            parent.requestLayout();
            parent.invalidate();
        }

        buttonAnimator.playTogether(ObjectAnimator.ofFloat(mDeleteButton, "translationX", 0, leftX),
                ObjectAnimator.ofFloat(mDeleteButton, "translationY", 0, leftY),
                ObjectAnimator.ofFloat(mSaveButton, "translationX", 0, rightX),
                ObjectAnimator.ofFloat(mSaveButton, "translationY", 0, rightY),
                ObjectAnimator.ofFloat(mPlayButton, "translationY", 0, buttonOffset));
        buttonAnimator.setInterpolator(new OvershootInterpolator());
        break;
    case -1: // in
        // keyView is the view we want to be at the front after an inward animation
        if (keyView != null) {
            keyView.bringToFront();
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
                // need to manually re-layout before KitKat
                parent = (RelativeLayout) keyView.getParent();
                parent.requestLayout();
                parent.invalidate();
            }
        }

        buttonAnimator.playTogether(ObjectAnimator.ofFloat(mDeleteButton, "translationX", leftX, 0),
                ObjectAnimator.ofFloat(mDeleteButton, "translationY", leftY, 0),
                ObjectAnimator.ofFloat(mSaveButton, "translationX", rightX, 0),
                ObjectAnimator.ofFloat(mSaveButton, "translationY", rightY, 0),
                ObjectAnimator.ofFloat(mPlayButton, "translationY", buttonOffset, 0));
        buttonAnimator.setInterpolator(new AnticipateInterpolator());
        break;
    }
    buttonAnimator.setDuration(BUTTON_ANIMATION_DURATION);
    buttonAnimator.start();
}