Example usage for android.view.animation LinearInterpolator LinearInterpolator

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

Introduction

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

Prototype

public LinearInterpolator() 

Source Link

Usage

From source file:com.actionbarsherlock.internal.widget.IcsProgressBar.java

/**
 * <p>Start the indeterminate progress animation.</p>
 *//*from   ww  w.j  a  va2  s . c o  m*/
void startAnimation() {
    if (getVisibility() != VISIBLE) {
        return;
    }

    if (mIndeterminateDrawable instanceof Animatable) {
        mShouldStartAnimationDrawable = true;
        mAnimation = null;
    } else {
        if (mInterpolator == null) {
            mInterpolator = new LinearInterpolator();
        }

        mTransformation = new Transformation();
        mAnimation = new AlphaAnimation(0.0f, 1.0f);
        mAnimation.setRepeatMode(mBehavior);
        mAnimation.setRepeatCount(Animation.INFINITE);
        mAnimation.setDuration(mDuration);
        mAnimation.setInterpolator(mInterpolator);
        mAnimation.setStartTime(Animation.START_ON_FIRST_FRAME);
    }
    postInvalidate();
}

From source file:org.runbuddy.tomahawk.ui.fragments.ContentHeaderFragment.java

private void setupButtonAnimation(final View view) {
    if (view != null) {
        View moreButton = view.findViewById(R.id.button_panel);
        if (moreButton != null) {
            ViewUtils.afterViewGlobalLayout(new ViewUtils.ViewRunnable(moreButton) {
                @Override/*from w  w  w.j  a  v  a 2  s.c  o m*/
                public void run() {
                    // get resources first
                    Resources resources = TomahawkApp.getContext().getResources();
                    int buttonHeight = TomahawkApp.getContext().getResources()
                            .getDimensionPixelSize(R.dimen.show_context_menu_icon_height);
                    int largePadding = TomahawkApp.getContext().getResources()
                            .getDimensionPixelSize(R.dimen.padding_large);
                    int smallPadding = resources.getDimensionPixelSize(R.dimen.padding_small);
                    int actionBarHeight = resources
                            .getDimensionPixelSize(R.dimen.abc_action_bar_default_height_material);
                    View pageIndicator = view.findViewById(R.id.page_indicator);
                    int pageIndicatorHeight = 0;
                    if (pageIndicator != null && pageIndicator.getVisibility() == View.VISIBLE) {
                        pageIndicatorHeight = TomahawkApp.getContext().getResources()
                                .getDimensionPixelSize(R.dimen.pager_indicator_height);
                    }

                    // now calculate the animation goal and instantiate the animation
                    int initialY = view.getHeight() - buttonHeight - largePadding - pageIndicatorHeight;
                    ValueAnimator animator = ObjectAnimator
                            .ofFloat(getLayedOutView(), "y", initialY, actionBarHeight + smallPadding)
                            .setDuration(10000);
                    animator.setInterpolator(new LinearInterpolator());
                    addAnimator(ANIM_BUTTON_ID, animator);

                    refreshAnimations();
                }
            });
        }
    }
}

From source file:org.runbuddy.tomahawk.ui.fragments.ContentHeaderFragment.java

private void setupImageViewAnimation(final View view) {
    if (view != null) {
        ViewUtils.afterViewGlobalLayout(new ViewUtils.ViewRunnable(view) {
            @Override//from  w  w  w .ja  va2  s.com
            public void run() {
                // now calculate the animation goal and instantiate the animation
                int initialY = 0;
                ValueAnimator animator = ObjectAnimator
                        .ofFloat(getLayedOutView(), "y", initialY, view.getHeight() / -3).setDuration(10000);
                animator.setInterpolator(new LinearInterpolator());
                addAnimator(ANIM_IMAGEVIEW_ID, animator);

                refreshAnimations();
            }
        });
    }
}

From source file:org.runbuddy.tomahawk.ui.fragments.ContentHeaderFragment.java

private void setupPageIndicatorAnimation(final View view) {
    if (view != null) {
        final PageIndicator indicatorView = (PageIndicator) view.findViewById(R.id.page_indicator);
        if (indicatorView != null) {
            final Runnable r = new Runnable() {
                @Override//w ww  . j  a  v  a  2  s  . c o  m
                public void run() {
                    // now calculate the animation goal and instantiate the animation
                    int initialY = view.getHeight() - indicatorView.getHeight();
                    ValueAnimator animator = ObjectAnimator.ofFloat(indicatorView, "y", initialY,
                            mHeaderNonscrollableHeight - indicatorView.getHeight()).setDuration(10000);
                    animator.setInterpolator(new LinearInterpolator());
                    addAnimator(ANIM_PAGEINDICATOR_ID, animator);

                    refreshAnimations();
                }
            };
            r.run();
            indicatorView.setOnSizeChangedListener(new OnSizeChangedListener() {
                @Override
                public void onSizeChanged(int w, int h, int oldw, int oldh) {
                    r.run();
                }
            });
        }
    }
}

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.  j a va  2s . c  om*/
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:com.corporatetaxi.TaxiOntheWay_Activity.java

private void animateMarker(final Marker marker, final LatLng toPosition, final boolean hideMarker) {
    final Handler handler = new Handler();
    final long start = SystemClock.uptimeMillis();
    Projection proj = map.getProjection();
    Point startPoint = proj.toScreenLocation(marker.getPosition());
    final LatLng startLatLng = proj.fromScreenLocation(startPoint);//marker1.getPosition();
    final long duration = 600;

    final Interpolator interpolator = new LinearInterpolator();
    handler.post(new Runnable() {
        @Override/*w ww .ja  va 2 s.c o m*/
        public void run() {
            long elapsed = SystemClock.uptimeMillis() - start;
            float t = interpolator.getInterpolation((float) elapsed / duration);
            double lng = t * toPosition.longitude + (1 - t) * startLatLng.longitude;
            double lat = t * toPosition.latitude + (1 - t) * startLatLng.latitude;
            marker.setPosition(new LatLng(lat, lng));

            if (t < 1.0) {
                // Post again 16ms later.
                handler.postDelayed(this, 16);
            } else {
                if (hideMarker) {
                    marker.setVisible(false);
                } else {
                    marker.setVisible(true);
                }
            }
            map.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(lat, lng)));
        }
    });

}

From source file:com.actionbarsherlock.internal.nineoldandroids.animation.ValueAnimator.java

/**
 * The time interpolator used in calculating the elapsed fraction of this animation. The
 * interpolator determines whether the animation runs with linear or non-linear motion,
 * such as acceleration and deceleration. The default value is
 * {@link android.view.animation.AccelerateDecelerateInterpolator}
 *
 * @param value the interpolator to be used by this animation. A value of <code>null</code>
 * will result in linear interpolation./*w w  w . j  a  v  a 2  s  .  c  om*/
 */
@Override
public void setInterpolator(/*Time*/Interpolator value) {
    if (value != null) {
        mInterpolator = value;
    } else {
        mInterpolator = new LinearInterpolator();
    }
}

From source file:com.corporatetaxi.TaxiArrived_Acitivity.java

private void animateMarker(final Marker marker, final LatLng toPosition, final boolean hideMarker) {
    final Handler handler = new Handler();
    final long start = SystemClock.uptimeMillis();
    Projection proj = map.getProjection();
    Point startPoint = proj.toScreenLocation(marker.getPosition());
    final LatLng startLatLng = proj.fromScreenLocation(startPoint);
    final long duration = 1000;

    final Interpolator interpolator = new LinearInterpolator();
    handler.post(new Runnable() {
        @Override/*from   w  w  w  .  ja v  a  2s .  c o  m*/
        public void run() {
            long elapsed = SystemClock.uptimeMillis() - start;
            float t = interpolator.getInterpolation((float) elapsed / duration);
            double lng = t * toPosition.longitude + (1 - t) * startLatLng.longitude;
            double lat = t * toPosition.latitude + (1 - t) * startLatLng.latitude;
            marker.setPosition(new LatLng(lat, lng));

            if (t < 1.0) {
                // Post again 16ms later.
                handler.postDelayed(this, 16);
            } else {
                if (hideMarker) {
                    marker.setVisible(false);
                } else {
                    marker.setVisible(true);
                }
            }
            map.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(lat, lng)));
        }
    });
}

From source file:com.pdftron.pdf.controls.UserCropDialogFragment.java

private void showSpinner() {
    this.setCancelable(false);
    if (mSpinnerShowing) {
        return;/*from   ww  w  .j a  v a2s .  c o  m*/
    }
    mSpinnerShowing = true;

    mProgressBarHost.setVisibility(View.VISIBLE);
    mSpinnerAlphaAnimation = new AlphaAnimation(0.0f, 1.0f);
    mSpinnerAlphaAnimation.setDuration(500);
    mSpinnerAlphaAnimation.setInterpolator(new LinearInterpolator());
    mProgressBarHost.startAnimation(mSpinnerAlphaAnimation);
}

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

private void startSyncIconRotation(MenuItem item) {
    if (item == null)
        return;//from  www  .  j  a v  a2s.c om

    // define the animation for rotation
    Animation animation = new RotateAnimation(360.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setInterpolator(new LinearInterpolator());
    animation.setDuration(1200);
    //        animRotate = AnimationUtils.loadAnimation(this, R.anim.rotation);
    animation.setRepeatCount(Animation.INFINITE);

    ImageView imageView = new ImageView(this);
    UIHelper uiHelper = new UIHelper(this);
    imageView.setImageDrawable(
            uiHelper.getIcon(GoogleMaterial.Icon.gmd_cached).color(uiHelper.getToolbarItemColor()));
    imageView.setPadding(8, 8, 8, 8);
    //        imageView.setLayoutParams(new Toolbar.LayoutParams());

    imageView.startAnimation(animation);
    item.setActionView(imageView);
}