Index: chrome/android/java/src/org/chromium/chrome/browser/appmenu/PulseInterpolator.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/appmenu/PulseInterpolator.java b/chrome/android/java/src/org/chromium/chrome/browser/appmenu/PulseInterpolator.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..99f898d6716f939d509db905a95dab4d59e3454f |
--- /dev/null |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/appmenu/PulseInterpolator.java |
@@ -0,0 +1,30 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+package org.chromium.chrome.browser.appmenu; |
+ |
+import android.view.animation.Interpolator; |
+ |
+/** |
+ * An {@link Interpolator} that pulses a value based on the passed in {@link Interpolator}. The |
+ * pulse will fade in and out after a delay. |
+ */ |
+public class PulseInterpolator implements Interpolator { |
+ private final Interpolator mInterpolator; |
+ |
+ /** |
+ * Creates a new {@link PulseInterpolator} instance. |
+ * @param interpolator The {@link Interpolator} responsible for handling the fade out and in. |
+ */ |
+ public PulseInterpolator(Interpolator interpolator) { |
+ mInterpolator = interpolator; |
+ } |
+ |
+ @Override |
+ public float getInterpolation(float input) { |
+ if (input < 0.4f) return 0.f; |
+ if (input < 0.8f) return mInterpolator.getInterpolation((input - 0.4f) / 0.4f); |
+ return mInterpolator.getInterpolation(1.f - (input - 0.8f) / 0.2f); |
+ } |
+} |