mirror of
https://github.com/material-components/material-components-android.git
synced 2026-02-20 08:39:55 +08:00
Move to using ValueAnimator directly instead of compat versions.
ValueAnimator can now be used directly given that our minSdk is 14. Bug: 32794064 Test: ./gradlew clean assemble still works Change-Id: Ibf0111b104eaea10acf33c8d54a3275fdfa0c1a4 PiperOrigin-RevId: 151641145
This commit is contained in:
parent
96436e4d8d
commit
d32ba949a8
@ -51,9 +51,9 @@ abstract class FloatingActionButtonImpl {
|
||||
float mPressedTranslationZ;
|
||||
|
||||
interface InternalVisibilityChangedListener {
|
||||
public void onShown();
|
||||
void onShown();
|
||||
|
||||
public void onHidden();
|
||||
void onHidden();
|
||||
}
|
||||
|
||||
static final int SHOW_HIDE_ANIM_DURATION = 200;
|
||||
@ -69,18 +69,13 @@ abstract class FloatingActionButtonImpl {
|
||||
|
||||
final VisibilityAwareImageButton mView;
|
||||
final ShadowViewDelegate mShadowViewDelegate;
|
||||
final ValueAnimatorCompat.Creator mAnimatorCreator;
|
||||
|
||||
private final Rect mTmpRect = new Rect();
|
||||
private ViewTreeObserver.OnPreDrawListener mPreDrawListener;
|
||||
|
||||
FloatingActionButtonImpl(
|
||||
VisibilityAwareImageButton view,
|
||||
ShadowViewDelegate shadowViewDelegate,
|
||||
ValueAnimatorCompat.Creator animatorCreator) {
|
||||
FloatingActionButtonImpl(VisibilityAwareImageButton view, ShadowViewDelegate shadowViewDelegate) {
|
||||
mView = view;
|
||||
mShadowViewDelegate = shadowViewDelegate;
|
||||
mAnimatorCreator = animatorCreator;
|
||||
}
|
||||
|
||||
abstract void setBackgroundDrawable(
|
||||
|
||||
@ -16,6 +16,9 @@
|
||||
|
||||
package android.support.design.widget;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.util.StateSet;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -24,12 +27,12 @@ final class StateListAnimator {
|
||||
private final ArrayList<Tuple> mTuples = new ArrayList<>();
|
||||
|
||||
private Tuple mLastMatch = null;
|
||||
ValueAnimatorCompat mRunningAnimator = null;
|
||||
ValueAnimator mRunningAnimator = null;
|
||||
|
||||
private final ValueAnimatorCompat.AnimatorListener mAnimationListener =
|
||||
new ValueAnimatorCompat.AnimatorListenerAdapter() {
|
||||
private final ValueAnimator.AnimatorListener mAnimationListener =
|
||||
new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(ValueAnimatorCompat animator) {
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
if (mRunningAnimator == animator) {
|
||||
mRunningAnimator = null;
|
||||
}
|
||||
@ -43,7 +46,7 @@ final class StateListAnimator {
|
||||
* @param specs The drawable state specs to match against
|
||||
* @param animator The animator to run when the specs match
|
||||
*/
|
||||
public void addState(int[] specs, ValueAnimatorCompat animator) {
|
||||
public void addState(int[] specs, ValueAnimator animator) {
|
||||
Tuple tuple = new Tuple(specs, animator);
|
||||
animator.addListener(mAnimationListener);
|
||||
mTuples.add(tuple);
|
||||
@ -100,9 +103,9 @@ final class StateListAnimator {
|
||||
|
||||
static class Tuple {
|
||||
final int[] mSpecs;
|
||||
final ValueAnimatorCompat mAnimator;
|
||||
final ValueAnimator mAnimator;
|
||||
|
||||
Tuple(int[] specs, ValueAnimatorCompat animator) {
|
||||
Tuple(int[] specs, ValueAnimator animator) {
|
||||
mSpecs = specs;
|
||||
mAnimator = animator;
|
||||
}
|
||||
|
||||
@ -1,214 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.support.design.widget;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
/**
|
||||
* This class offers a very small subset of {@code ValueAnimator}'s API, but works pre-v11 too.
|
||||
*
|
||||
* <p>You shouldn't not instantiate this directly. Instead use {@code ViewUtils.createAnimator()}.
|
||||
*/
|
||||
class ValueAnimatorCompat {
|
||||
|
||||
interface AnimatorUpdateListener {
|
||||
/**
|
||||
* Notifies the occurrence of another frame of the animation.
|
||||
*
|
||||
* @param animator The animation which was repeated.
|
||||
*/
|
||||
void onAnimationUpdate(ValueAnimatorCompat animator);
|
||||
}
|
||||
|
||||
/**
|
||||
* An animation listener receives notifications from an animation. Notifications indicate
|
||||
* animation related events, such as the end or the repetition of the animation.
|
||||
*/
|
||||
interface AnimatorListener {
|
||||
/**
|
||||
* Notifies the start of the animation.
|
||||
*
|
||||
* @param animator The started animation.
|
||||
*/
|
||||
void onAnimationStart(ValueAnimatorCompat animator);
|
||||
/**
|
||||
* Notifies the end of the animation. This callback is not invoked for animations with repeat
|
||||
* count set to INFINITE.
|
||||
*
|
||||
* @param animator The animation which reached its end.
|
||||
*/
|
||||
void onAnimationEnd(ValueAnimatorCompat animator);
|
||||
/**
|
||||
* Notifies the cancellation of the animation. This callback is not invoked for animations with
|
||||
* repeat count set to INFINITE.
|
||||
*
|
||||
* @param animator The animation which was canceled.
|
||||
*/
|
||||
void onAnimationCancel(ValueAnimatorCompat animator);
|
||||
}
|
||||
|
||||
static class AnimatorListenerAdapter implements AnimatorListener {
|
||||
@Override
|
||||
public void onAnimationStart(ValueAnimatorCompat animator) {}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(ValueAnimatorCompat animator) {}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(ValueAnimatorCompat animator) {}
|
||||
}
|
||||
|
||||
interface Creator {
|
||||
@NonNull
|
||||
ValueAnimatorCompat createAnimator();
|
||||
}
|
||||
|
||||
abstract static class Impl {
|
||||
interface AnimatorUpdateListenerProxy {
|
||||
void onAnimationUpdate();
|
||||
}
|
||||
|
||||
interface AnimatorListenerProxy {
|
||||
void onAnimationStart();
|
||||
|
||||
void onAnimationEnd();
|
||||
|
||||
void onAnimationCancel();
|
||||
}
|
||||
|
||||
abstract void start();
|
||||
|
||||
abstract boolean isRunning();
|
||||
|
||||
abstract void setInterpolator(Interpolator interpolator);
|
||||
|
||||
abstract void addListener(AnimatorListenerProxy listener);
|
||||
|
||||
abstract void addUpdateListener(AnimatorUpdateListenerProxy updateListener);
|
||||
|
||||
abstract void setIntValues(int from, int to);
|
||||
|
||||
abstract int getAnimatedIntValue();
|
||||
|
||||
abstract void setFloatValues(float from, float to);
|
||||
|
||||
abstract float getAnimatedFloatValue();
|
||||
|
||||
abstract void setDuration(long duration);
|
||||
|
||||
abstract void cancel();
|
||||
|
||||
abstract float getAnimatedFraction();
|
||||
|
||||
abstract void end();
|
||||
|
||||
abstract long getDuration();
|
||||
}
|
||||
|
||||
private final Impl mImpl;
|
||||
|
||||
ValueAnimatorCompat(Impl impl) {
|
||||
mImpl = impl;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
mImpl.start();
|
||||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
return mImpl.isRunning();
|
||||
}
|
||||
|
||||
public void setInterpolator(Interpolator interpolator) {
|
||||
mImpl.setInterpolator(interpolator);
|
||||
}
|
||||
|
||||
public void addUpdateListener(final AnimatorUpdateListener updateListener) {
|
||||
if (updateListener != null) {
|
||||
mImpl.addUpdateListener(
|
||||
new Impl.AnimatorUpdateListenerProxy() {
|
||||
@Override
|
||||
public void onAnimationUpdate() {
|
||||
updateListener.onAnimationUpdate(ValueAnimatorCompat.this);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mImpl.addUpdateListener(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void addListener(final AnimatorListener listener) {
|
||||
if (listener != null) {
|
||||
mImpl.addListener(
|
||||
new Impl.AnimatorListenerProxy() {
|
||||
@Override
|
||||
public void onAnimationStart() {
|
||||
listener.onAnimationStart(ValueAnimatorCompat.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd() {
|
||||
listener.onAnimationEnd(ValueAnimatorCompat.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel() {
|
||||
listener.onAnimationCancel(ValueAnimatorCompat.this);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mImpl.addListener(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void setIntValues(int from, int to) {
|
||||
mImpl.setIntValues(from, to);
|
||||
}
|
||||
|
||||
public int getAnimatedIntValue() {
|
||||
return mImpl.getAnimatedIntValue();
|
||||
}
|
||||
|
||||
public void setFloatValues(float from, float to) {
|
||||
mImpl.setFloatValues(from, to);
|
||||
}
|
||||
|
||||
public float getAnimatedFloatValue() {
|
||||
return mImpl.getAnimatedFloatValue();
|
||||
}
|
||||
|
||||
public void setDuration(long duration) {
|
||||
mImpl.setDuration(duration);
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
mImpl.cancel();
|
||||
}
|
||||
|
||||
public float getAnimatedFraction() {
|
||||
return mImpl.getAnimatedFraction();
|
||||
}
|
||||
|
||||
public void end() {
|
||||
mImpl.end();
|
||||
}
|
||||
|
||||
public long getDuration() {
|
||||
return mImpl.getDuration();
|
||||
}
|
||||
}
|
||||
@ -22,7 +22,6 @@ android {
|
||||
'base',
|
||||
'gingerbread',
|
||||
'honeycomb',
|
||||
'honeycomb-mr1',
|
||||
'ics',
|
||||
'lollipop',
|
||||
'src'
|
||||
|
||||
@ -16,6 +16,9 @@
|
||||
|
||||
package android.support.design.widget;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
@ -38,10 +41,8 @@ class FloatingActionButtonGingerbread extends FloatingActionButtonImpl {
|
||||
ShadowDrawableWrapper mShadowDrawable;
|
||||
|
||||
FloatingActionButtonGingerbread(
|
||||
VisibilityAwareImageButton view,
|
||||
ShadowViewDelegate shadowViewDelegate,
|
||||
ValueAnimatorCompat.Creator animatorCreator) {
|
||||
super(view, shadowViewDelegate, animatorCreator);
|
||||
VisibilityAwareImageButton view, ShadowViewDelegate shadowViewDelegate) {
|
||||
super(view, shadowViewDelegate);
|
||||
|
||||
mStateListAnimator = new StateListAnimator();
|
||||
|
||||
@ -213,8 +214,8 @@ class FloatingActionButtonGingerbread extends FloatingActionButtonImpl {
|
||||
mShadowDrawable.getPadding(rect);
|
||||
}
|
||||
|
||||
private ValueAnimatorCompat createAnimator(@NonNull ShadowAnimatorImpl impl) {
|
||||
final ValueAnimatorCompat animator = mAnimatorCreator.createAnimator();
|
||||
private ValueAnimator createAnimator(@NonNull ShadowAnimatorImpl impl) {
|
||||
final ValueAnimator animator = new ValueAnimator();
|
||||
animator.setInterpolator(ANIM_INTERPOLATOR);
|
||||
animator.setDuration(PRESSED_ANIM_DURATION);
|
||||
animator.addListener(impl);
|
||||
@ -223,14 +224,14 @@ class FloatingActionButtonGingerbread extends FloatingActionButtonImpl {
|
||||
return animator;
|
||||
}
|
||||
|
||||
private abstract class ShadowAnimatorImpl extends ValueAnimatorCompat.AnimatorListenerAdapter
|
||||
implements ValueAnimatorCompat.AnimatorUpdateListener {
|
||||
private abstract class ShadowAnimatorImpl extends AnimatorListenerAdapter
|
||||
implements ValueAnimator.AnimatorUpdateListener {
|
||||
private boolean mValidValues;
|
||||
private float mShadowSizeStart;
|
||||
private float mShadowSizeEnd;
|
||||
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimatorCompat animator) {
|
||||
public void onAnimationUpdate(ValueAnimator animator) {
|
||||
if (!mValidValues) {
|
||||
mShadowSizeStart = mShadowDrawable.getShadowSize();
|
||||
mShadowSizeEnd = getTargetShadowSize();
|
||||
@ -243,7 +244,7 @@ class FloatingActionButtonGingerbread extends FloatingActionButtonImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(ValueAnimatorCompat animator) {
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
mShadowDrawable.setShadowSize(mShadowSizeEnd);
|
||||
mValidValues = false;
|
||||
}
|
||||
|
||||
@ -1,218 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.support.design.widget;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.SystemClock;
|
||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||
import android.view.animation.Interpolator;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/** A 'fake' ValueAnimator implementation which uses a Runnable. */
|
||||
class ValueAnimatorCompatImplGingerbread extends ValueAnimatorCompat.Impl {
|
||||
|
||||
private static final int HANDLER_DELAY = 10;
|
||||
private static final int DEFAULT_DURATION = 200;
|
||||
|
||||
private static final Handler sHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
private long mStartTime;
|
||||
private boolean mIsRunning;
|
||||
private float mAnimatedFraction;
|
||||
|
||||
private final int[] mIntValues = new int[2];
|
||||
private final float[] mFloatValues = new float[2];
|
||||
|
||||
private long mDuration = DEFAULT_DURATION;
|
||||
private Interpolator mInterpolator;
|
||||
private ArrayList<AnimatorListenerProxy> mListeners;
|
||||
private ArrayList<AnimatorUpdateListenerProxy> mUpdateListeners;
|
||||
|
||||
private final Runnable mRunnable =
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
update();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if (mIsRunning) {
|
||||
// If we're already running, ignore
|
||||
return;
|
||||
}
|
||||
if (mInterpolator == null) {
|
||||
mInterpolator = new AccelerateDecelerateInterpolator();
|
||||
}
|
||||
mIsRunning = true;
|
||||
|
||||
// Reset the animated fraction
|
||||
mAnimatedFraction = 0f;
|
||||
|
||||
startInternal();
|
||||
}
|
||||
|
||||
final void startInternal() {
|
||||
mStartTime = SystemClock.uptimeMillis();
|
||||
dispatchAnimationUpdate();
|
||||
dispatchAnimationStart();
|
||||
// Now start our animation ticker
|
||||
sHandler.postDelayed(mRunnable, HANDLER_DELAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return mIsRunning;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInterpolator(Interpolator interpolator) {
|
||||
mInterpolator = interpolator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(AnimatorListenerProxy listener) {
|
||||
if (mListeners == null) {
|
||||
mListeners = new ArrayList<>();
|
||||
}
|
||||
mListeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addUpdateListener(AnimatorUpdateListenerProxy updateListener) {
|
||||
if (mUpdateListeners == null) {
|
||||
mUpdateListeners = new ArrayList<>();
|
||||
}
|
||||
mUpdateListeners.add(updateListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIntValues(int from, int to) {
|
||||
mIntValues[0] = from;
|
||||
mIntValues[1] = to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAnimatedIntValue() {
|
||||
return AnimationUtils.lerp(mIntValues[0], mIntValues[1], getAnimatedFraction());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFloatValues(float from, float to) {
|
||||
mFloatValues[0] = from;
|
||||
mFloatValues[1] = to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAnimatedFloatValue() {
|
||||
return AnimationUtils.lerp(mFloatValues[0], mFloatValues[1], getAnimatedFraction());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDuration(long duration) {
|
||||
mDuration = duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
mIsRunning = false;
|
||||
sHandler.removeCallbacks(mRunnable);
|
||||
|
||||
dispatchAnimationCancel();
|
||||
dispatchAnimationEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAnimatedFraction() {
|
||||
return mAnimatedFraction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end() {
|
||||
if (mIsRunning) {
|
||||
mIsRunning = false;
|
||||
sHandler.removeCallbacks(mRunnable);
|
||||
// Set our animated fraction to 1
|
||||
mAnimatedFraction = 1f;
|
||||
dispatchAnimationUpdate();
|
||||
dispatchAnimationEnd();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDuration() {
|
||||
return mDuration;
|
||||
}
|
||||
|
||||
final void update() {
|
||||
if (mIsRunning) {
|
||||
// Update the animated fraction
|
||||
final long elapsed = SystemClock.uptimeMillis() - mStartTime;
|
||||
final float linearFraction = MathUtils.constrain(elapsed / (float) mDuration, 0f, 1f);
|
||||
mAnimatedFraction =
|
||||
mInterpolator != null ? mInterpolator.getInterpolation(linearFraction) : linearFraction;
|
||||
|
||||
// If we're running, dispatch to the update listeners
|
||||
dispatchAnimationUpdate();
|
||||
|
||||
// Check to see if we've passed the animation duration
|
||||
if (SystemClock.uptimeMillis() >= (mStartTime + mDuration)) {
|
||||
mIsRunning = false;
|
||||
|
||||
dispatchAnimationEnd();
|
||||
}
|
||||
}
|
||||
|
||||
if (mIsRunning) {
|
||||
// If we're still running, post another delayed runnable
|
||||
sHandler.postDelayed(mRunnable, HANDLER_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
private void dispatchAnimationUpdate() {
|
||||
if (mUpdateListeners != null) {
|
||||
for (int i = 0, count = mUpdateListeners.size(); i < count; i++) {
|
||||
mUpdateListeners.get(i).onAnimationUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dispatchAnimationStart() {
|
||||
if (mListeners != null) {
|
||||
for (int i = 0, count = mListeners.size(); i < count; i++) {
|
||||
mListeners.get(i).onAnimationStart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dispatchAnimationCancel() {
|
||||
if (mListeners != null) {
|
||||
for (int i = 0, count = mListeners.size(); i < count; i++) {
|
||||
mListeners.get(i).onAnimationCancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dispatchAnimationEnd() {
|
||||
if (mListeners != null) {
|
||||
for (int i = 0, count = mListeners.size(); i < count; i++) {
|
||||
mListeners.get(i).onAnimationEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,125 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.support.design.widget;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
@RequiresApi(12)
|
||||
class ValueAnimatorCompatImplHoneycombMr1 extends ValueAnimatorCompat.Impl {
|
||||
|
||||
private final ValueAnimator mValueAnimator;
|
||||
|
||||
ValueAnimatorCompatImplHoneycombMr1() {
|
||||
mValueAnimator = new ValueAnimator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
mValueAnimator.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return mValueAnimator.isRunning();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInterpolator(Interpolator interpolator) {
|
||||
mValueAnimator.setInterpolator(interpolator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addUpdateListener(final AnimatorUpdateListenerProxy updateListener) {
|
||||
mValueAnimator.addUpdateListener(
|
||||
new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator valueAnimator) {
|
||||
updateListener.onAnimationUpdate();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(final AnimatorListenerProxy listener) {
|
||||
mValueAnimator.addListener(
|
||||
new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animator) {
|
||||
listener.onAnimationStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
listener.onAnimationEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animator) {
|
||||
listener.onAnimationCancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIntValues(int from, int to) {
|
||||
mValueAnimator.setIntValues(from, to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAnimatedIntValue() {
|
||||
return (int) mValueAnimator.getAnimatedValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFloatValues(float from, float to) {
|
||||
mValueAnimator.setFloatValues(from, to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAnimatedFloatValue() {
|
||||
return (float) mValueAnimator.getAnimatedValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDuration(long duration) {
|
||||
mValueAnimator.setDuration(duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
mValueAnimator.cancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAnimatedFraction() {
|
||||
return mValueAnimator.getAnimatedFraction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end() {
|
||||
mValueAnimator.end();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDuration() {
|
||||
return mValueAnimator.getDuration();
|
||||
}
|
||||
}
|
||||
@ -29,11 +29,8 @@ class FloatingActionButtonIcs extends FloatingActionButtonGingerbread {
|
||||
|
||||
private float mRotation;
|
||||
|
||||
FloatingActionButtonIcs(
|
||||
VisibilityAwareImageButton view,
|
||||
ShadowViewDelegate shadowViewDelegate,
|
||||
ValueAnimatorCompat.Creator animatorCreator) {
|
||||
super(view, shadowViewDelegate, animatorCreator);
|
||||
FloatingActionButtonIcs(VisibilityAwareImageButton view, ShadowViewDelegate shadowViewDelegate) {
|
||||
super(view, shadowViewDelegate);
|
||||
mRotation = mView.getRotation();
|
||||
}
|
||||
|
||||
|
||||
@ -38,10 +38,8 @@ class FloatingActionButtonLollipop extends FloatingActionButtonIcs {
|
||||
private InsetDrawable mInsetDrawable;
|
||||
|
||||
FloatingActionButtonLollipop(
|
||||
VisibilityAwareImageButton view,
|
||||
ShadowViewDelegate shadowViewDelegate,
|
||||
ValueAnimatorCompat.Creator animatorCreator) {
|
||||
super(view, shadowViewDelegate, animatorCreator);
|
||||
VisibilityAwareImageButton view, ShadowViewDelegate shadowViewDelegate) {
|
||||
super(view, shadowViewDelegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -19,6 +19,7 @@ package android.support.design.widget;
|
||||
import static android.support.annotation.RestrictTo.Scope.GROUP_ID;
|
||||
import static android.support.design.widget.ViewUtils.objectEquals;
|
||||
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Rect;
|
||||
@ -772,7 +773,7 @@ public class AppBarLayout extends LinearLayout {
|
||||
private boolean mSkipNestedPreScroll;
|
||||
private boolean mWasNestedFlung;
|
||||
|
||||
private ValueAnimatorCompat mOffsetAnimator;
|
||||
private ValueAnimator mOffsetAnimator;
|
||||
|
||||
private int mOffsetToChildIndexOnLayout = INVALID_POSITION;
|
||||
private boolean mOffsetToChildIndexOnLayoutIsMinHeight;
|
||||
@ -821,7 +822,8 @@ public class AppBarLayout extends LinearLayout {
|
||||
int dy,
|
||||
int[] consumed) {
|
||||
if (dy != 0 && !mSkipNestedPreScroll) {
|
||||
int min, max;
|
||||
int min;
|
||||
int max;
|
||||
if (dy < 0) {
|
||||
// We're scrolling down
|
||||
min = -child.getTotalScrollRange();
|
||||
@ -955,13 +957,14 @@ public class AppBarLayout extends LinearLayout {
|
||||
}
|
||||
|
||||
if (mOffsetAnimator == null) {
|
||||
mOffsetAnimator = ViewUtils.createAnimator();
|
||||
mOffsetAnimator = new ValueAnimator();
|
||||
mOffsetAnimator.setInterpolator(AnimationUtils.DECELERATE_INTERPOLATOR);
|
||||
mOffsetAnimator.addUpdateListener(
|
||||
new ValueAnimatorCompat.AnimatorUpdateListener() {
|
||||
new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimatorCompat animator) {
|
||||
setHeaderTopBottomOffset(coordinatorLayout, child, animator.getAnimatedIntValue());
|
||||
public void onAnimationUpdate(ValueAnimator animator) {
|
||||
setHeaderTopBottomOffset(
|
||||
coordinatorLayout, child, (int) animator.getAnimatedValue());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
@ -19,6 +19,9 @@ package android.support.design.widget;
|
||||
import static android.support.annotation.RestrictTo.Scope.GROUP_ID;
|
||||
import static android.support.design.widget.AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Build;
|
||||
@ -498,30 +501,30 @@ public abstract class BaseTransientBottomBar<B extends BaseTransientBottomBar<B>
|
||||
ViewCompat.setTranslationY(mView, viewHeight);
|
||||
}
|
||||
|
||||
final ValueAnimatorCompat animator = ViewUtils.createAnimator();
|
||||
final ValueAnimator animator = new ValueAnimator();
|
||||
animator.setIntValues(viewHeight, 0);
|
||||
animator.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR);
|
||||
animator.setDuration(ANIMATION_DURATION);
|
||||
animator.addListener(
|
||||
new ValueAnimatorCompat.AnimatorListenerAdapter() {
|
||||
new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(ValueAnimatorCompat animator) {
|
||||
public void onAnimationStart(Animator animator) {
|
||||
mContentViewCallback.animateContentIn(
|
||||
ANIMATION_DURATION - ANIMATION_FADE_DURATION, ANIMATION_FADE_DURATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(ValueAnimatorCompat animator) {
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
onViewShown();
|
||||
}
|
||||
});
|
||||
animator.addUpdateListener(
|
||||
new ValueAnimatorCompat.AnimatorUpdateListener() {
|
||||
new ValueAnimator.AnimatorUpdateListener() {
|
||||
private int previousAnimatedIntValue = viewHeight;
|
||||
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimatorCompat animator) {
|
||||
int currentAnimatedIntValue = animator.getAnimatedIntValue();
|
||||
public void onAnimationUpdate(ValueAnimator animator) {
|
||||
int currentAnimatedIntValue = (int) animator.getAnimatedValue();
|
||||
if (USE_OFFSET_API) {
|
||||
// On JB versions of the platform sometimes View.setTranslationY does not
|
||||
// result in layout / draw pass
|
||||
@ -558,29 +561,29 @@ public abstract class BaseTransientBottomBar<B extends BaseTransientBottomBar<B>
|
||||
|
||||
private void animateViewOut(final int event) {
|
||||
if (Build.VERSION.SDK_INT >= 12) {
|
||||
final ValueAnimatorCompat animator = ViewUtils.createAnimator();
|
||||
final ValueAnimator animator = new ValueAnimator();
|
||||
animator.setIntValues(0, mView.getHeight());
|
||||
animator.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR);
|
||||
animator.setDuration(ANIMATION_DURATION);
|
||||
animator.addListener(
|
||||
new ValueAnimatorCompat.AnimatorListenerAdapter() {
|
||||
new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(ValueAnimatorCompat animator) {
|
||||
public void onAnimationStart(Animator animator) {
|
||||
mContentViewCallback.animateContentOut(0, ANIMATION_FADE_DURATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(ValueAnimatorCompat animator) {
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
onViewHidden(event);
|
||||
}
|
||||
});
|
||||
animator.addUpdateListener(
|
||||
new ValueAnimatorCompat.AnimatorUpdateListener() {
|
||||
new ValueAnimator.AnimatorUpdateListener() {
|
||||
private int previousAnimatedIntValue = 0;
|
||||
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimatorCompat animator) {
|
||||
int currentAnimatedIntValue = animator.getAnimatedIntValue();
|
||||
public void onAnimationUpdate(ValueAnimator animator) {
|
||||
int currentAnimatedIntValue = (int) animator.getAnimatedValue();
|
||||
if (USE_OFFSET_API) {
|
||||
// On JB versions of the platform sometimes View.setTranslationY does not
|
||||
// result in layout / draw pass
|
||||
|
||||
@ -20,6 +20,7 @@ import static android.support.annotation.RestrictTo.Scope.GROUP_ID;
|
||||
import static android.support.design.widget.MathUtils.constrain;
|
||||
import static android.support.design.widget.ViewUtils.objectEquals;
|
||||
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.TypedArray;
|
||||
@ -127,7 +128,7 @@ public class CollapsingToolbarLayout extends FrameLayout {
|
||||
Drawable mStatusBarScrim;
|
||||
private int mScrimAlpha;
|
||||
private boolean mScrimsAreShown;
|
||||
private ValueAnimatorCompat mScrimAnimator;
|
||||
private ValueAnimator mScrimAnimator;
|
||||
private long mScrimAnimationDuration;
|
||||
private int mScrimVisibleHeightTrigger = -1;
|
||||
|
||||
@ -592,17 +593,17 @@ public class CollapsingToolbarLayout extends FrameLayout {
|
||||
private void animateScrim(int targetAlpha) {
|
||||
ensureToolbar();
|
||||
if (mScrimAnimator == null) {
|
||||
mScrimAnimator = ViewUtils.createAnimator();
|
||||
mScrimAnimator = new ValueAnimator();
|
||||
mScrimAnimator.setDuration(mScrimAnimationDuration);
|
||||
mScrimAnimator.setInterpolator(
|
||||
targetAlpha > mScrimAlpha
|
||||
? AnimationUtils.FAST_OUT_LINEAR_IN_INTERPOLATOR
|
||||
: AnimationUtils.LINEAR_OUT_SLOW_IN_INTERPOLATOR);
|
||||
mScrimAnimator.addUpdateListener(
|
||||
new ValueAnimatorCompat.AnimatorUpdateListener() {
|
||||
new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimatorCompat animator) {
|
||||
setScrimAlpha(animator.getAnimatedIntValue());
|
||||
public void onAnimationUpdate(ValueAnimator animator) {
|
||||
setScrimAlpha((int) animator.getAnimatedValue());
|
||||
}
|
||||
});
|
||||
} else if (mScrimAnimator.isRunning()) {
|
||||
|
||||
@ -247,6 +247,7 @@ public class FloatingActionButton extends VisibilityAwareImageButton {
|
||||
*
|
||||
* @param tint the tint to apply, may be {@code null} to clear tint
|
||||
*/
|
||||
@Override
|
||||
public void setBackgroundTintList(@Nullable ColorStateList tint) {
|
||||
if (mBackgroundTint != tint) {
|
||||
mBackgroundTint = tint;
|
||||
@ -273,6 +274,7 @@ public class FloatingActionButton extends VisibilityAwareImageButton {
|
||||
*
|
||||
* @param tintMode the blending mode used to apply the tint, may be {@code null} to clear tint
|
||||
*/
|
||||
@Override
|
||||
public void setBackgroundTintMode(@Nullable PorterDuff.Mode tintMode) {
|
||||
if (mBackgroundTintMode != tintMode) {
|
||||
mBackgroundTintMode = tintMode;
|
||||
@ -732,7 +734,8 @@ public class FloatingActionButton extends VisibilityAwareImageButton {
|
||||
final CoordinatorLayout.LayoutParams lp =
|
||||
(CoordinatorLayout.LayoutParams) fab.getLayoutParams();
|
||||
|
||||
int offsetTB = 0, offsetLR = 0;
|
||||
int offsetTB = 0;
|
||||
int offsetLR = 0;
|
||||
|
||||
if (fab.getRight() >= parent.getWidth() - lp.rightMargin) {
|
||||
// If we're on the right edge, shift it the right
|
||||
@ -792,14 +795,11 @@ public class FloatingActionButton extends VisibilityAwareImageButton {
|
||||
private FloatingActionButtonImpl createImpl() {
|
||||
final int sdk = Build.VERSION.SDK_INT;
|
||||
if (sdk >= 21) {
|
||||
return new FloatingActionButtonLollipop(
|
||||
this, new ShadowDelegateImpl(), ViewUtils.DEFAULT_ANIMATOR_CREATOR);
|
||||
return new FloatingActionButtonLollipop(this, new ShadowDelegateImpl());
|
||||
} else if (sdk >= 14) {
|
||||
return new FloatingActionButtonIcs(
|
||||
this, new ShadowDelegateImpl(), ViewUtils.DEFAULT_ANIMATOR_CREATOR);
|
||||
return new FloatingActionButtonIcs(this, new ShadowDelegateImpl());
|
||||
} else {
|
||||
return new FloatingActionButtonGingerbread(
|
||||
this, new ShadowDelegateImpl(), ViewUtils.DEFAULT_ANIMATOR_CREATOR);
|
||||
return new FloatingActionButtonGingerbread(this, new ShadowDelegateImpl());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -21,6 +21,9 @@ import static android.support.v4.view.ViewPager.SCROLL_STATE_DRAGGING;
|
||||
import static android.support.v4.view.ViewPager.SCROLL_STATE_IDLE;
|
||||
import static android.support.v4.view.ViewPager.SCROLL_STATE_SETTLING;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
@ -266,7 +269,7 @@ public class TabLayout extends HorizontalScrollView {
|
||||
private final ArrayList<OnTabSelectedListener> mSelectedListeners = new ArrayList<>();
|
||||
private OnTabSelectedListener mCurrentVpSelectedListener;
|
||||
|
||||
private ValueAnimatorCompat mScrollAnimator;
|
||||
private ValueAnimator mScrollAnimator;
|
||||
|
||||
ViewPager mViewPager;
|
||||
private PagerAdapter mPagerAdapter;
|
||||
@ -1089,20 +1092,20 @@ public class TabLayout extends HorizontalScrollView {
|
||||
|
||||
private void ensureScrollAnimator() {
|
||||
if (mScrollAnimator == null) {
|
||||
mScrollAnimator = ViewUtils.createAnimator();
|
||||
mScrollAnimator = new ValueAnimator();
|
||||
mScrollAnimator.setInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
|
||||
mScrollAnimator.setDuration(ANIMATION_DURATION);
|
||||
mScrollAnimator.addUpdateListener(
|
||||
new ValueAnimatorCompat.AnimatorUpdateListener() {
|
||||
new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimatorCompat animator) {
|
||||
scrollTo(animator.getAnimatedIntValue(), 0);
|
||||
public void onAnimationUpdate(ValueAnimator animator) {
|
||||
scrollTo((int) animator.getAnimatedValue(), 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void setScrollAnimatorListener(ValueAnimatorCompat.AnimatorListener listener) {
|
||||
void setScrollAnimatorListener(ValueAnimator.AnimatorListener listener) {
|
||||
ensureScrollAnimator();
|
||||
mScrollAnimator.addListener(listener);
|
||||
}
|
||||
@ -1812,7 +1815,7 @@ public class TabLayout extends HorizontalScrollView {
|
||||
private int mIndicatorLeft = -1;
|
||||
private int mIndicatorRight = -1;
|
||||
|
||||
private ValueAnimatorCompat mIndicatorAnimator;
|
||||
private ValueAnimator mIndicatorAnimator;
|
||||
|
||||
SlidingTabStrip(Context context) {
|
||||
super(context);
|
||||
@ -1948,7 +1951,8 @@ public class TabLayout extends HorizontalScrollView {
|
||||
|
||||
private void updateIndicatorPosition() {
|
||||
final View selectedTitle = getChildAt(mSelectedPosition);
|
||||
int left, right;
|
||||
int left;
|
||||
int right;
|
||||
|
||||
if (selectedTitle != null && selectedTitle.getWidth() > 0) {
|
||||
left = selectedTitle.getLeft();
|
||||
@ -2021,14 +2025,14 @@ public class TabLayout extends HorizontalScrollView {
|
||||
}
|
||||
|
||||
if (startLeft != targetLeft || startRight != targetRight) {
|
||||
ValueAnimatorCompat animator = mIndicatorAnimator = ViewUtils.createAnimator();
|
||||
ValueAnimator animator = mIndicatorAnimator = new ValueAnimator();
|
||||
animator.setInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
|
||||
animator.setDuration(duration);
|
||||
animator.setFloatValues(0, 1);
|
||||
animator.addUpdateListener(
|
||||
new ValueAnimatorCompat.AnimatorUpdateListener() {
|
||||
new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimatorCompat animator) {
|
||||
public void onAnimationUpdate(ValueAnimator animator) {
|
||||
final float fraction = animator.getAnimatedFraction();
|
||||
setIndicatorPosition(
|
||||
AnimationUtils.lerp(startLeft, targetLeft, fraction),
|
||||
@ -2036,9 +2040,9 @@ public class TabLayout extends HorizontalScrollView {
|
||||
}
|
||||
});
|
||||
animator.addListener(
|
||||
new ValueAnimatorCompat.AnimatorListenerAdapter() {
|
||||
new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(ValueAnimatorCompat animator) {
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
mSelectedPosition = position;
|
||||
mSelectionOffset = 0f;
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
|
||||
package android.support.design.widget;
|
||||
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Canvas;
|
||||
@ -165,7 +166,7 @@ public class TextInputLayout extends LinearLayout {
|
||||
final CollapsingTextHelper mCollapsingTextHelper = new CollapsingTextHelper(this);
|
||||
|
||||
private boolean mHintAnimationEnabled;
|
||||
private ValueAnimatorCompat mAnimator;
|
||||
private ValueAnimator mAnimator;
|
||||
|
||||
private boolean mHasReconstructedEditTextBackground;
|
||||
private boolean mInDrawableStateChanged;
|
||||
@ -1413,14 +1414,14 @@ public class TextInputLayout extends LinearLayout {
|
||||
return;
|
||||
}
|
||||
if (mAnimator == null) {
|
||||
mAnimator = ViewUtils.createAnimator();
|
||||
mAnimator = new ValueAnimator();
|
||||
mAnimator.setInterpolator(AnimationUtils.LINEAR_INTERPOLATOR);
|
||||
mAnimator.setDuration(ANIMATION_DURATION);
|
||||
mAnimator.addUpdateListener(
|
||||
new ValueAnimatorCompat.AnimatorUpdateListener() {
|
||||
new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimatorCompat animator) {
|
||||
mCollapsingTextHelper.setExpansionFraction(animator.getAnimatedFloatValue());
|
||||
public void onAnimationUpdate(ValueAnimator animator) {
|
||||
mCollapsingTextHelper.setExpansionFraction((float) animator.getAnimatedValue());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -17,25 +17,9 @@
|
||||
package android.support.design.widget;
|
||||
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.Build;
|
||||
|
||||
class ViewUtils {
|
||||
|
||||
static final ValueAnimatorCompat.Creator DEFAULT_ANIMATOR_CREATOR =
|
||||
new ValueAnimatorCompat.Creator() {
|
||||
@Override
|
||||
public ValueAnimatorCompat createAnimator() {
|
||||
return new ValueAnimatorCompat(
|
||||
Build.VERSION.SDK_INT >= 12
|
||||
? new ValueAnimatorCompatImplHoneycombMr1()
|
||||
: new ValueAnimatorCompatImplGingerbread());
|
||||
}
|
||||
};
|
||||
|
||||
static ValueAnimatorCompat createAnimator() {
|
||||
return DEFAULT_ANIMATOR_CREATOR.createAnimator();
|
||||
}
|
||||
|
||||
static boolean objectEquals(Object a, Object b) {
|
||||
return (a == b) || (a != null && a.equals(b));
|
||||
}
|
||||
|
||||
@ -32,6 +32,8 @@ import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.os.Build;
|
||||
import android.support.design.testapp.R;
|
||||
import android.support.test.annotation.UiThreadTest;
|
||||
@ -295,14 +297,14 @@ public class TabLayoutTest {
|
||||
|
||||
TabLayoutScrollIdlingResource(final TabLayout tabLayout) {
|
||||
tabLayout.setScrollAnimatorListener(
|
||||
new ValueAnimatorCompat.AnimatorListenerAdapter() {
|
||||
new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(ValueAnimatorCompat animator) {
|
||||
public void onAnimationStart(Animator animator) {
|
||||
setIdle(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(ValueAnimatorCompat animator) {
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
setIdle(true);
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user