OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chrome.browser.widget; |
| 6 |
| 7 import android.view.animation.Interpolator; |
| 8 |
| 9 /** |
| 10 * An {@link Interpolator} that pulses a value based on the passed in {@link Int
erpolator}. The |
| 11 * pulse will fade in and out after a delay. |
| 12 */ |
| 13 public class PulseInterpolator implements Interpolator { |
| 14 private final Interpolator mInterpolator; |
| 15 |
| 16 /** |
| 17 * Creates a new {@link PulseInterpolator} instance. |
| 18 * @param interpolator The {@link Interpolator} responsible for handling the
fade out and in. |
| 19 */ |
| 20 public PulseInterpolator(Interpolator interpolator) { |
| 21 mInterpolator = interpolator; |
| 22 } |
| 23 |
| 24 @Override |
| 25 public float getInterpolation(float input) { |
| 26 if (input < 0.4f) return 0.f; |
| 27 if (input < 0.8f) return mInterpolator.getInterpolation((input - 0.4f) /
0.4f); |
| 28 return mInterpolator.getInterpolation(1.f - (input - 0.8f) / 0.2f); |
| 29 } |
| 30 } |
OLD | NEW |