Example usage for android.animation ObjectAnimator setInterpolator

List of usage examples for android.animation ObjectAnimator setInterpolator

Introduction

In this page you can find the example usage for android.animation ObjectAnimator setInterpolator.

Prototype

@Override
public void setInterpolator(TimeInterpolator value) 

Source Link

Document

The time interpolator used in calculating the elapsed fraction of this animation.

Usage

From source file:com.waz.zclient.pages.main.profile.camera.CameraFragment.java

@Override
public void onAccentColorHasChanged(Object sender, int color) {
    colorOverlay.setBackgroundColor(color);
    float accentColorOpacity = ResourceUtils.getResourceFloat(getResources(),
            R.dimen.background_color_overlay_opacity);
    float accentColorOpacityOverdriven = ResourceUtils.getResourceFloat(getResources(),
            R.dimen.background_color_overlay_opacity_overdriven);
    ObjectAnimator anim = ObjectAnimator.ofFloat(colorOverlay, View.ALPHA, 0, accentColorOpacityOverdriven,
            accentColorOpacityOverdriven, accentColorOpacityOverdriven / 2, accentColorOpacity);
    anim.setInterpolator(new AccentColorInterpolator());
    anim.setDuration(//from  w  ww  .  j  a v a2 s . c  om
            getResources().getInteger(R.integer.background_accent_color_transition_animation_duration));
    anim.start();
    cameraBottomControl.setAccentColor(color);
}

From source file:com.alburivan.slickform.tooltip.SimpleTooltip.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void startAnimation() {
    final String property = mGravity == Gravity.TOP || mGravity == Gravity.BOTTOM ? "translationY"
            : "translationX";

    final ObjectAnimator anim1 = ObjectAnimator.ofFloat(mContentLayout, property, -mAnimationPadding,
            mAnimationPadding);/*from   w  ww.j  av  a 2 s .c  om*/
    anim1.setDuration(mAnimationDuration);
    anim1.setInterpolator(new AccelerateDecelerateInterpolator());

    final ObjectAnimator anim2 = ObjectAnimator.ofFloat(mContentLayout, property, mAnimationPadding,
            -mAnimationPadding);
    anim2.setDuration(mAnimationDuration);
    anim2.setInterpolator(new AccelerateDecelerateInterpolator());

    mAnimator = new AnimatorSet();
    mAnimator.playSequentially(anim1, anim2);
    mAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (!dismissed && isShowing()) {
                animation.start();
            }
        }
    });
    mAnimator.start();
}

From source file:com.gsoc.ijosa.liquidgalaxycontroller.PW.NearbyBeaconsFragment.java

private void showListView() {
    if (getListView() != null) {
        if (getListView().getVisibility() == View.VISIBLE) {
            return;
        }//  w w  w .j  ava2  s.  c o  m

        mSwipeRefreshWidget.setRefreshing(false);
        getListView().setAlpha(0f);
        getListView().setVisibility(View.VISIBLE);
        safeNotifyChange();
        ObjectAnimator alphaAnimation = ObjectAnimator.ofFloat(getListView(), "alpha", 0f, 1f);
        alphaAnimation.setDuration(400);
        alphaAnimation.setInterpolator(new DecelerateInterpolator());
        alphaAnimation.addListener(new AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                mScanningAnimationTextView.setAlpha(0f);
                mScanningAnimationDrawable.stop();
                arrowDownLayout.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animator animation) {
            }

            @Override
            public void onAnimationCancel(Animator animation) {
            }
        });
        alphaAnimation.start();
    }
}

From source file:com.android.tv.settings.dialog.SettingsLayoutFragment.java

private void performEntryTransition() {
    final View dialogView = getView();
    final View contentView = (View) dialogView.getTag(R.id.content_fragment);
    final View actionContainerView = dialogView.findViewById(R.id.action_fragment);

    mIntroAnimationInProgress = true;/*from   w  w w.ja  v  a  2  s  .  c o  m*/

    // Fade out the old activity.
    getActivity().overridePendingTransition(0, R.anim.lb_dialog_fade_out);

    int bgColor = contentView.getContext().getResources().getColor(R.color.lb_dialog_activity_background);
    final ColorDrawable bgDrawable = new ColorDrawable();
    bgDrawable.setColor(bgColor);
    bgDrawable.setAlpha(0);
    dialogView.setBackground(bgDrawable);
    dialogView.setVisibility(View.INVISIBLE);

    // We need to defer the remainder of the animation preparation until the first layout has
    // occurred, as we don't yet know the final location of the icon.
    contentView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            contentView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            // if we buildLayer() at this time, the texture is
            // actually not created delay a little so we can make
            // sure all hardware layer is created before animation,
            // in that way we can avoid the jittering of start
            // animation
            contentView.postOnAnimationDelayed(mEntryAnimationRunnable, mAnimateDelay);
        }

        Runnable mEntryAnimationRunnable = new Runnable() {
            @Override
            public void run() {
                if (!isAdded()) {
                    // We have been detached before this could run, so just bail.
                    return;
                }

                dialogView.setVisibility(View.VISIBLE);

                // Fade in the activity background protection
                ObjectAnimator oa = ObjectAnimator.ofInt(bgDrawable, "alpha", 255);
                oa.setDuration(mAnimateInDuration);
                oa.setStartDelay(mSecondaryAnimateDelay);
                oa.setInterpolator(new DecelerateInterpolator(1.0f));
                oa.start();

                boolean isRtl = ViewCompat.getLayoutDirection(contentView) == View.LAYOUT_DIRECTION_RTL;
                int startDist = isRtl ? mSlideInDistance : -mSlideInDistance;
                int endDist = isRtl ? -actionContainerView.getMeasuredWidth()
                        : actionContainerView.getMeasuredWidth();

                // Fade in and slide in the ContentFragment TextViews from the start.
                prepareAndAnimateView((View) contentView.getTag(R.id.title), startDist, false);
                prepareAndAnimateView((View) contentView.getTag(R.id.breadcrumb), startDist, false);
                prepareAndAnimateView((View) contentView.getTag(R.id.description), startDist, false);

                // Fade in and slide in the ActionFragment from the end.
                prepareAndAnimateView(actionContainerView, endDist, false);
                prepareAndAnimateView((View) contentView.getTag(R.id.icon), startDist, true);
            }
        };
    });
}

From source file:com.yekertech.tvbarsetting.dialog.SettingsLayoutFragment.java

private void performEntryTransition() {
    final View dialogView = getView();
    final View contentView = (View) dialogView.getTag(R.id.content_fragment);
    final View actionContainerView = dialogView.findViewById(R.id.action_fragment);

    mIntroAnimationInProgress = true;//from   w ww . j av a  2 s.  c om

    // Fade out the old activity.
    getActivity().overridePendingTransition(0, R.anim.lb_dialog_fade_out);

    int bgColor = contentView.getContext().getColor(R.color.lb_dialog_activity_background);
    final ColorDrawable bgDrawable = new ColorDrawable();
    bgDrawable.setColor(bgColor);
    bgDrawable.setAlpha(0);
    dialogView.setBackground(bgDrawable);
    dialogView.setVisibility(View.INVISIBLE);

    // We need to defer the remainder of the animation preparation until the first layout has
    // occurred, as we don't yet know the final location of the icon.
    contentView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            contentView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            // if we buildLayer() at this time, the texture is
            // actually not created delay a little so we can make
            // sure all hardware layer is created before animation,
            // in that way we can avoid the jittering of start
            // animation
            contentView.postOnAnimationDelayed(mEntryAnimationRunnable, mAnimateDelay);
        }

        final Runnable mEntryAnimationRunnable = new Runnable() {
            @Override
            public void run() {
                if (!isAdded()) {
                    // We have been detached before this could run, so just bail.
                    return;
                }

                dialogView.setVisibility(View.VISIBLE);

                // Fade in the activity background protection
                ObjectAnimator oa = ObjectAnimator.ofInt(bgDrawable, "alpha", 255);
                oa.setDuration(mAnimateInDuration);
                oa.setStartDelay(mSecondaryAnimateDelay);
                oa.setInterpolator(new DecelerateInterpolator(1.0f));
                oa.start();

                boolean isRtl = ViewCompat.getLayoutDirection(contentView) == ViewCompat.LAYOUT_DIRECTION_RTL;
                int startDist = isRtl ? mSlideInDistance : -mSlideInDistance;
                int endDist = isRtl ? -actionContainerView.getMeasuredWidth()
                        : actionContainerView.getMeasuredWidth();

                // Fade in and slide in the ContentFragment TextViews from the start.
                prepareAndAnimateView((View) contentView.getTag(R.id.title), startDist, false);
                prepareAndAnimateView((View) contentView.getTag(R.id.breadcrumb), startDist, false);
                prepareAndAnimateView((View) contentView.getTag(R.id.description), startDist, false);

                // Fade in and slide in the ActionFragment from the end.
                prepareAndAnimateView(actionContainerView, endDist, false);
                prepareAndAnimateView((View) contentView.getTag(R.id.icon), startDist, true);
            }
        };
    });
}

From source file:com.money.manager.ex.home.HomeFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    switch (loader.getId()) {
    case LOADER_ACCOUNT_BILLS:
        try {/*  w w w  .  j  av  a2s . com*/
            renderAccountsList(data);
        } catch (Exception e) {
            Timber.e(e, "rendering account list");
        }

        // set total for accounts in the main Drawer.
        EventBus.getDefault().post(new AccountsTotalLoadedEvent(txtTotalAccounts.getText().toString()));
        break;

    case LOADER_INCOME_EXPENSES:
        double income = 0, expenses = 0;
        if (data != null) {
            while (data.moveToNext()) {
                expenses = data.getDouble(data.getColumnIndex(IncomeVsExpenseReportEntity.Expenses));
                income = data.getDouble(data.getColumnIndex(IncomeVsExpenseReportEntity.Income));
            }
        }
        TextView txtIncome = (TextView) getActivity().findViewById(R.id.textViewIncome);
        TextView txtExpenses = (TextView) getActivity().findViewById(R.id.textViewExpenses);
        TextView txtDifference = (TextView) getActivity().findViewById(R.id.textViewDifference);
        // set value
        if (txtIncome != null)
            txtIncome.setText(mCurrencyService.getCurrencyFormatted(mCurrencyService.getBaseCurrencyId(),
                    MoneyFactory.fromDouble(income)));
        if (txtExpenses != null)
            txtExpenses.setText(mCurrencyService.getCurrencyFormatted(mCurrencyService.getBaseCurrencyId(),
                    MoneyFactory.fromDouble(Math.abs(expenses))));
        if (txtDifference != null)
            txtDifference.setText(mCurrencyService.getCurrencyFormatted(mCurrencyService.getBaseCurrencyId(),
                    MoneyFactory.fromDouble(income - Math.abs(expenses))));
        // manage progressbar
        final ProgressBar barIncome = (ProgressBar) getActivity().findViewById(R.id.progressBarIncome);
        final ProgressBar barExpenses = (ProgressBar) getActivity().findViewById(R.id.progressBarExpenses);

        if (barIncome != null && barExpenses != null) {
            barIncome.setMax((int) (Math.abs(income) + Math.abs(expenses)));
            barExpenses.setMax((int) (Math.abs(income) + Math.abs(expenses)));

            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
                ObjectAnimator animationIncome = ObjectAnimator.ofInt(barIncome, "progress",
                        (int) Math.abs(income));
                animationIncome.setDuration(1000); // 0.5 second
                animationIncome.setInterpolator(new DecelerateInterpolator());
                animationIncome.start();

                ObjectAnimator animationExpenses = ObjectAnimator.ofInt(barExpenses, "progress",
                        (int) Math.abs(expenses));
                animationExpenses.setDuration(1000); // 0.5 second
                animationExpenses.setInterpolator(new DecelerateInterpolator());
                animationExpenses.start();
            } else {
                barIncome.setProgress((int) Math.abs(income));
                barExpenses.setProgress((int) Math.abs(expenses));
            }
        }
        break;
    }

    // Close the cursor.
    MmxDatabaseUtils.closeCursor(data);
}

From source file:co.ceryle.radiorealbutton.library.RadioRealButtonGroup.java

private ObjectAnimator createAnimator(View view, String property, float value, boolean hasDelay,
        boolean hasDuration) {
    ObjectAnimator animator = ObjectAnimator.ofFloat(view, property, value);
    animator.setInterpolator(interpolatorSelector);
    if (hasDuration)
        animator.setDuration(animateSelectorDuration);
    else/*from   w  w  w.jav  a2 s.  com*/
        animator.setDuration(0);
    if (hasDelay)
        animator.setStartDelay(animateSelectorDelay);
    return animator;
}

From source file:com.android.clear.reminder.ItemAnimator.java

@Override
public boolean animateMove(final ViewHolder holder, int fromX, int fromY, int toX, int toY) {
    endAnimation(holder);//  w w w  .  jav  a  2  s  . c o  m

    final int deltaX = toX - fromX;
    final int deltaY = toY - fromY;
    final long moveDuration = getMoveDuration();

    if (deltaX == 0 && deltaY == 0) {
        dispatchMoveFinished(holder);
        return false;
    }

    final View view = holder.itemView;
    final float prevTranslationX = view.getTranslationX();
    final float prevTranslationY = view.getTranslationY();
    view.setTranslationX(-deltaX);
    view.setTranslationY(-deltaY);

    final ObjectAnimator moveAnimator;
    if (deltaX != 0 && deltaY != 0) {
        final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f);
        final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f);
        moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX, moveY);
    } else if (deltaX != 0) {
        final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f);
        moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX);
    } else {
        final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f);
        moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveY);
    }

    moveAnimator.setDuration(moveDuration);
    moveAnimator.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN);
    moveAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animator) {
            dispatchMoveStarting(holder);
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            animator.removeAllListeners();
            mAnimators.remove(holder);
            view.setTranslationX(prevTranslationX);
            view.setTranslationY(prevTranslationY);
            dispatchMoveFinished(holder);
        }
    });
    mMoveAnimatorsList.add(moveAnimator);
    mAnimators.put(holder, moveAnimator);

    return true;
}

From source file:com.sysdata.widget.accordion.ItemAnimator.java

@Override
public boolean animateMove(final ViewHolder holder, int fromX, int fromY, int toX, int toY) {
    endAnimation(holder);/*from  w ww .  jav a  2s  .  co m*/

    final int deltaX = toX - fromX;
    final int deltaY = toY - fromY;
    final long moveDuration = getMoveDuration();

    if (deltaX == 0 && deltaY == 0) {
        dispatchMoveFinished(holder);
        return false;
    }

    final View view = holder.itemView;
    final float prevTranslationX = view.getTranslationX();
    final float prevTranslationY = view.getTranslationY();
    view.setTranslationX(-deltaX);
    view.setTranslationY(-deltaY);

    final ObjectAnimator moveAnimator;
    if (deltaX != 0 && deltaY != 0) {
        final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f);
        final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f);
        moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX, moveY);
    } else if (deltaX != 0) {
        final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f);
        moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX);
    } else {
        final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f);
        moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveY);
    }

    moveAnimator.setDuration(moveDuration);
    moveAnimator.setInterpolator(new FastOutSlowInInterpolator());
    moveAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animator) {
            dispatchMoveStarting(holder);
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            animator.removeAllListeners();
            mAnimators.remove(holder);
            view.setTranslationX(prevTranslationX);
            view.setTranslationY(prevTranslationY);
            dispatchMoveFinished(holder);
        }
    });
    mMoveAnimatorsList.add(moveAnimator);
    mAnimators.put(holder, moveAnimator);

    return true;
}

From source file:com.box.myview.MyTopSnackBar.TSnackbar.java

/**
 * @param drawable/*from  w  ww .j  a  v a 2  s  . c  o m*/
 * @param left
 * @param right
 * @return
 */
public TSnackbar addIconProgressLoading(Drawable drawable, boolean left, boolean right) {
    final ObjectAnimator animator = ObjectAnimator.ofInt(drawable, "level", 0, 10000);
    animator.setDuration(1000);
    animator.setInterpolator(new LinearInterpolator());
    animator.setRepeatCount(ValueAnimator.INFINITE);
    animator.setRepeatMode(ValueAnimator.INFINITE);
    mView.setBackgroundColor(mContext.getResources().getColor(Prompt.SUCCESS.getBackgroundColor()));
    if (left) {
        mView.getMessageView().setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
    }
    if (right) {
        mView.getMessageView().setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null);
    }
    animator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (mCallback != null) {
                mCallback.onShown(TSnackbar.this);
            }
            SnackbarManager.getInstance().onShown(mManagerCallback);
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });
    animator.start();
    return this;
}