android.view.animation.PathInterpolator Java Examples

The following examples show how to use android.view.animation.PathInterpolator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MotionSpecTest.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
@Test
public void validateSetOfObjectAnimatorTranslationMotionTiming() {
  MotionSpec spec =
      MotionSpec.createFromResource(
          activityTestRule.getActivity(), R.animator.valid_set_of_object_animator_motion_spec);
  MotionTiming translation = spec.getTiming("translation");

  assertEquals(11, translation.getDelay());
  assertEquals(13, translation.getDuration());
  if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
    assertThat(translation.getInterpolator(), instanceOf(PathInterpolator.class));
  } else {
    assertThat(translation.getInterpolator(), instanceOf(FastOutSlowInInterpolator.class));
  }
  assertEquals(17, translation.getRepeatCount());
  assertEquals(ValueAnimator.REVERSE, translation.getRepeatMode());
}
 
Example #2
Source File: MotionSpecTest.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
@Test
public void validateSetOfObjectAnimatorAlphaMotionTiming() {
  MotionSpec spec =
      MotionSpec.createFromResource(
          activityTestRule.getActivity(), R.animator.valid_set_of_object_animator_motion_spec);
  MotionTiming alpha = spec.getTiming("alpha");

  assertEquals(3, alpha.getDelay());
  assertEquals(5, alpha.getDuration());
  if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
    assertThat(alpha.getInterpolator(), instanceOf(PathInterpolator.class));
  } else {
    assertThat(alpha.getInterpolator(), instanceOf(FastOutLinearInInterpolator.class));
  }
  assertEquals(7, alpha.getRepeatCount());
  assertEquals(ValueAnimator.RESTART, alpha.getRepeatMode());
}
 
Example #3
Source File: AbsSlidingMusicPanelActivity.java    From Orin with GNU General Public License v3.0 6 votes vote down vote up
private void animateNavigationBarColor(int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (navigationBarColorAnimator != null) navigationBarColorAnimator.cancel();
        navigationBarColorAnimator = ValueAnimator
                .ofArgb(getWindow().getNavigationBarColor(), color)
                .setDuration(ViewUtil.PHONOGRAPH_ANIM_TIME);
        navigationBarColorAnimator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
        navigationBarColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @TargetApi(Build.VERSION_CODES.LOLLIPOP)
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                AbsSlidingMusicPanelActivity.super.setNavigationbarColor((Integer) animation.getAnimatedValue());
            }
        });
        navigationBarColorAnimator.start();
    }
}
 
Example #4
Source File: ViewUtil.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
private static Animator createColorAnimator(Object target, String propertyName, @ColorInt int startColor, @ColorInt int endColor) {
    ObjectAnimator animator;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        animator = ObjectAnimator.ofArgb(target, propertyName, startColor, endColor);
    } else {
        animator = ObjectAnimator.ofInt(target, propertyName, startColor, endColor);
        animator.setEvaluator(new ArgbEvaluator());
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        animator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
    }
    animator.setDuration(PHONOGRAPH_ANIM_TIME);
    return animator;
}
 
Example #5
Source File: AnimationUtils.java    From proteus with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
Interpolator createInterpolator(Context c) {
  if (null != controlX2 && null != controlY2) {
    return new PathInterpolator(controlX1, controlY1, controlX2, controlY2);
  } else {
    return new PathInterpolator(controlX1, controlY1);
  }
}
 
Example #6
Source File: CircularProgressBar.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public CircularProgressBar(Context context, AttributeSet attrs) {
	super(context, attrs);
	paint = new Paint(Paint.ANTI_ALIAS_FLAG);
	paint.setStyle(Paint.Style.STROKE);
	paint.setStrokeCap(Paint.Cap.SQUARE);
	paint.setStrokeJoin(Paint.Join.MITER);
	if (C.API_LOLLIPOP) {
		Path startPath = new Path();
		startPath.lineTo(0.5f, 0f);
		startPath.cubicTo(0.7f, 0f, 0.6f, 1f, 1f, 1f);
		lollipopStartInterpolator = new PathInterpolator(startPath);
		Path endPath = new Path();
		endPath.cubicTo(0.2f, 0f, 0.1f, 1f, 0.5f, 1f);
		endPath.lineTo(1f, 1f);
		lollipopEndInterpolator = new PathInterpolator(endPath);
		indeterminateDrawable = null;
		indeterminateDuration = 0;
	} else {
		lollipopStartInterpolator = null;
		lollipopEndInterpolator = null;
		TypedArray typedArray = context.obtainStyledAttributes(android.R.style.Widget_Holo_ProgressBar_Large,
				new int[] {android.R.attr.indeterminateDrawable, android.R.attr.indeterminateDuration});
		indeterminateDrawable = typedArray.getDrawable(0);
		indeterminateDuration = typedArray.getInteger(1, 3500);
		typedArray.recycle();
	}
}
 
Example #7
Source File: PullableWrapper.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
public LollipopView(Wrapped wrapped, boolean top) {
	this.wrapped = new WeakReference<>(wrapped);
	this.top = top;
	Path startPath = new Path();
	startPath.lineTo(0.5f, 0f);
	startPath.cubicTo(0.7f, 0f, 0.6f, 1f, 1f, 1f);
	startInterpolator = new PathInterpolator(startPath);
	Path endPath = new Path();
	endPath.cubicTo(0.2f, 0f, 0.1f, 1f, 0.5f, 1f);
	endPath.lineTo(1f, 1f);
	endInterpolator = new PathInterpolator(endPath);
	ringPaint.setStyle(Paint.Style.STROKE);
	ringPaint.setStrokeCap(Paint.Cap.SQUARE);
	ringPaint.setStrokeJoin(Paint.Join.MITER);
}
 
Example #8
Source File: ViewUtil.java    From Phonograph with GNU General Public License v3.0 5 votes vote down vote up
private static Animator createColorAnimator(Object target, String propertyName, @ColorInt int startColor, @ColorInt int endColor) {
    ObjectAnimator animator;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        animator = ObjectAnimator.ofArgb(target, propertyName, startColor, endColor);
    } else {
        animator = ObjectAnimator.ofInt(target, propertyName, startColor, endColor);
        animator.setEvaluator(new ArgbEvaluator());
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        animator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
    }
    animator.setDuration(PHONOGRAPH_ANIM_TIME);
    return animator;
}
 
Example #9
Source File: AbsSlidingMusicPanelActivity.java    From Phonograph with GNU General Public License v3.0 5 votes vote down vote up
private void animateNavigationBarColor(int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (navigationBarColorAnimator != null) navigationBarColorAnimator.cancel();
        navigationBarColorAnimator = ValueAnimator
                .ofArgb(getWindow().getNavigationBarColor(), color)
                .setDuration(ViewUtil.PHONOGRAPH_ANIM_TIME);
        navigationBarColorAnimator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
        navigationBarColorAnimator.addUpdateListener(animation -> AbsSlidingMusicPanelActivity.super.setNavigationbarColor((Integer) animation.getAnimatedValue()));
        navigationBarColorAnimator.start();
    }
}
 
Example #10
Source File: BezierSpline.java    From AndroidPhotoFilters with Apache License 2.0 5 votes vote down vote up
private static int[] getOutputPointsForNewerDevices(Point[] knots) {

        Point[] controlPoints = calculateControlPoints(knots);
        Path path = new Path();
        path.moveTo(0, 0);
        path.lineTo(knots[0].x / 255.0f, knots[0].y / 255.0f);
        path.moveTo(knots[0].x / 255.0f, knots[0].y / 255.0f);

        for (int index = 1; index < knots.length; index++) {
            path.quadTo(
                    controlPoints[index - 1].x / 255.0f,
                    controlPoints[index - 1].y / 255.0f,
                    knots[index].x / 255.0f,
                    knots[index].y / 255.0f
            );
            path.moveTo(knots[index].x / 255.0f, knots[index].y / 255.0f);
        }

        path.lineTo(1, 1);
        path.moveTo(1, 1);

        float[] allPoints = new float[256];

        for (int x = 0; x < 256; x++) {
            PathInterpolator pathInterpolator = new PathInterpolator(path);
            allPoints[x] = 255.0f * pathInterpolator.getInterpolation((float) x / 255.0f);
        }

        allPoints[0] = knots[0].y;
        allPoints[255] = knots[knots.length - 1].y;
        return validateCurve(allPoints);
    }
 
Example #11
Source File: ViewUtil.java    From VinylMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
private static Animator createColorAnimator(Object target, String propertyName, @ColorInt int startColor, @ColorInt int endColor) {
    ObjectAnimator animator;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        animator = ObjectAnimator.ofArgb(target, propertyName, startColor, endColor);
    } else {
        animator = ObjectAnimator.ofInt(target, propertyName, startColor, endColor);
        animator.setEvaluator(new ArgbEvaluator());
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        animator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
    }
    animator.setDuration(VINYL_MUSIC_PLAYER_ANIM_TIME);
    return animator;
}
 
Example #12
Source File: AbsSlidingMusicPanelActivity.java    From VinylMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
private void animateNavigationBarColor(int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (navigationBarColorAnimator != null) navigationBarColorAnimator.cancel();
        navigationBarColorAnimator = ValueAnimator
                .ofArgb(getWindow().getNavigationBarColor(), color)
                .setDuration(ViewUtil.VINYL_MUSIC_PLAYER_ANIM_TIME);
        navigationBarColorAnimator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
        navigationBarColorAnimator.addUpdateListener(animation -> AbsSlidingMusicPanelActivity.super.setNavigationbarColor((Integer) animation.getAnimatedValue()));
        navigationBarColorAnimator.start();
    }
}
 
Example #13
Source File: AbsSlidingMusicPanelActivity.java    From Music-Player with GNU General Public License v3.0 5 votes vote down vote up
private void animateNavigationBarColor(int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (navigationBarColorAnimator != null) navigationBarColorAnimator.cancel();
        navigationBarColorAnimator = ValueAnimator
                .ofArgb(getWindow().getNavigationBarColor(), color)
                .setDuration(ViewUtil.MUSIC_ANIM_TIME);
        navigationBarColorAnimator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
        navigationBarColorAnimator.addUpdateListener(animation -> AbsSlidingMusicPanelActivity.super.setNavigationbarColor((Integer) animation.getAnimatedValue()));
        navigationBarColorAnimator.start();
    }
}
 
Example #14
Source File: PathInterpolatorCompat.java    From android-dialer with Apache License 2.0 5 votes vote down vote up
public static Interpolator create(
    float controlX1, float controlY1, float controlX2, float controlY2) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    return new PathInterpolator(controlX1, controlY1, controlX2, controlY2);
  }
  return new PathInterpolatorBase(controlX1, controlY1, controlX2, controlY2);
}
 
Example #15
Source File: ViewUtil.java    From Orin with GNU General Public License v3.0 5 votes vote down vote up
private static Animator createColorAnimator(Object target, String propertyName, @ColorInt int startColor, @ColorInt int endColor) {
    ObjectAnimator animator;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        animator = ObjectAnimator.ofArgb(target, propertyName, startColor, endColor);
    } else {
        animator = ObjectAnimator.ofInt(target, propertyName, startColor, endColor);
        animator.setEvaluator(new ArgbEvaluator());
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        animator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
    }
    animator.setDuration(PHONOGRAPH_ANIM_TIME);
    return animator;
}
 
Example #16
Source File: BezierSpline.java    From AndroidPhotoFilters with Apache License 2.0 5 votes vote down vote up
private static int[] getOutputPointsForNewerDevices(Point[] knots) {

        Point[] controlPoints = calculateControlPoints(knots);
        Path path = new Path();
        path.moveTo(0, 0);
        path.lineTo(knots[0].x / 255.0f, knots[0].y / 255.0f);
        path.moveTo(knots[0].x / 255.0f, knots[0].y / 255.0f);

        for (int index = 1; index < knots.length; index++) {
            path.quadTo(
                    controlPoints[index - 1].x / 255.0f,
                    controlPoints[index - 1].y / 255.0f,
                    knots[index].x / 255.0f,
                    knots[index].y / 255.0f
            );
            path.moveTo(knots[index].x / 255.0f, knots[index].y / 255.0f);
        }

        path.lineTo(1, 1);
        path.moveTo(1, 1);

        float[] allPoints = new float[256];

        for (int x = 0; x < 256; x++) {
            PathInterpolator pathInterpolator = new PathInterpolator(path);
            allPoints[x] = 255.0f * pathInterpolator.getInterpolation((float) x / 255.0f);
        }

        allPoints[0] = knots[0].y;
        allPoints[255] = knots[knots.length - 1].y;
        return validateCurve(allPoints);
    }
 
Example #17
Source File: FlingAnimationUtils.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
private AnimatorProperties getDismissingProperties(float currValue, float endValue,
        float velocity, float maxDistance) {
    float maxLengthSeconds = (float) (mMaxLengthSeconds
            * Math.pow(Math.abs(endValue - currValue) / maxDistance, 0.5f));
    float diff = Math.abs(endValue - currValue);
    float velAbs = Math.abs(velocity);
    float y2 = calculateLinearOutFasterInY2(velAbs);

    float startGradient = y2 / LINEAR_OUT_FASTER_IN_X2;
    Interpolator mLinearOutFasterIn = new PathInterpolator(0, 0, LINEAR_OUT_FASTER_IN_X2, y2);
    float durationSeconds = startGradient * diff / velAbs;
    if (durationSeconds <= maxLengthSeconds) {
        mAnimatorProperties.interpolator = mLinearOutFasterIn;
    } else if (velAbs >= mMinVelocityPxPerSecond) {

        // Cross fade between linear-out-faster-in and linear interpolator with current
        // velocity.
        durationSeconds = maxLengthSeconds;
        VelocityInterpolator velocityInterpolator
                = new VelocityInterpolator(durationSeconds, velAbs, diff);
        InterpolatorInterpolator superInterpolator = new InterpolatorInterpolator(
                velocityInterpolator, mLinearOutFasterIn, Interpolators.LINEAR_OUT_SLOW_IN);
        mAnimatorProperties.interpolator = superInterpolator;
    } else {

        // Just use a normal interpolator which doesn't take the velocity into account.
        durationSeconds = maxLengthSeconds;
        mAnimatorProperties.interpolator = Interpolators.FAST_OUT_LINEAR_IN;
    }
    mAnimatorProperties.duration = (long) (durationSeconds * 1000);
    return mAnimatorProperties;
}
 
Example #18
Source File: FlingAnimationUtils.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
private Interpolator getInterpolator(float startGradient, float velocityFactor) {
    if (startGradient != mCachedStartGradient
            || velocityFactor != mCachedVelocityFactor) {
        float speedup = mSpeedUpFactor * (1.0f - velocityFactor);
        mInterpolator = new PathInterpolator(speedup,
                speedup * startGradient,
                mLinearOutSlowInX2, mY2);
        mCachedStartGradient = startGradient;
        mCachedVelocityFactor = velocityFactor;
    }
    return mInterpolator;
}
 
Example #19
Source File: ViewUtil.java    From Music-Player with GNU General Public License v3.0 5 votes vote down vote up
private static Animator createColorAnimator(Object target, String propertyName, @ColorInt int startColor, @ColorInt int endColor) {
    ObjectAnimator animator;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        animator = ObjectAnimator.ofArgb(target, propertyName, startColor, endColor);
    } else {
        animator = ObjectAnimator.ofInt(target, propertyName, startColor, endColor);
        animator.setEvaluator(new ArgbEvaluator());
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        animator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
    }
    animator.setDuration(MUSIC_ANIM_TIME);
    return animator;
}
 
Example #20
Source File: PathInterpolatorCompatApi21.java    From RxTools-master with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Interpolator create(float controlX1, float controlY1,
                                  float controlX2, float controlY2) {
    return new PathInterpolator(controlX1, controlY1, controlX2, controlY2);
}
 
Example #21
Source File: PathInterpolatorCompatApi21.java    From RxTools-master with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Interpolator create(float controlX, float controlY) {
    return new PathInterpolator(controlX, controlY);
}
 
Example #22
Source File: PathInterpolatorCompatApi21.java    From RxTools-master with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Interpolator create(Path path) {
    return new PathInterpolator(path);
}