mirror of
https://github.com/material-components/material-components-android.git
synced 2026-02-20 08:39:55 +08:00
Conditional use of workaround for 22-24 devices
Bug: 32136707 Test: ./gradlew support-design:connectedCheck --info --daemon -Pandroid.testInstrumentationRunnerArguments.class=android.support.design.widget.FloatingActionButtonTest Change-Id: Icdf198e9923af4baa1456496efdfc25b20abe582 PiperOrigin-RevId: 169627986
This commit is contained in:
parent
d78b8b4f72
commit
2ef4aeb4fd
@ -16,6 +16,7 @@
|
||||
|
||||
package android.support.design.widget;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.StateListAnimator;
|
||||
@ -31,6 +32,8 @@ import android.os.Build;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||
import android.view.View;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RequiresApi(21)
|
||||
class FloatingActionButtonImplLollipop extends FloatingActionButtonImpl {
|
||||
@ -119,15 +122,20 @@ class FloatingActionButtonImplLollipop extends FloatingActionButtonImpl {
|
||||
|
||||
// Animate translationZ to 0 if not pressed
|
||||
set = new AnimatorSet();
|
||||
set.playSequentially(
|
||||
ObjectAnimator.ofFloat(mView, "elevation", elevation).setDuration(0),
|
||||
// This is a no-op animation which exists here only for introducing the duration
|
||||
// because setting the delay (on the next animation) via "setDelay" or "after"
|
||||
// can trigger a NPE between android versions 22 and 24 (due to a framework
|
||||
// bug). The issue has been fixed in version 25.
|
||||
ObjectAnimator.ofFloat(mView, View.TRANSLATION_Z, mView.getTranslationZ())
|
||||
.setDuration(PRESSED_ANIM_DELAY),
|
||||
List<Animator> animators = new ArrayList<>();
|
||||
animators.add(ObjectAnimator.ofFloat(mView, "elevation", elevation).setDuration(0));
|
||||
if (Build.VERSION.SDK_INT >= 22 && Build.VERSION.SDK_INT <= 24) {
|
||||
// This is a no-op animation which exists here only for introducing the duration
|
||||
// because setting the delay (on the next animation) via "setDelay" or "after"
|
||||
// can trigger a NPE between android versions 22 and 24 (due to a framework
|
||||
// bug). The issue has been fixed in version 25.
|
||||
animators.add(
|
||||
ObjectAnimator.ofFloat(mView, View.TRANSLATION_Z, mView.getTranslationZ())
|
||||
.setDuration(PRESSED_ANIM_DELAY));
|
||||
}
|
||||
animators.add(
|
||||
ObjectAnimator.ofFloat(mView, View.TRANSLATION_Z, 0f).setDuration(PRESSED_ANIM_DURATION));
|
||||
set.playSequentially(animators.toArray(new Animator[0]));
|
||||
set.setInterpolator(ANIM_INTERPOLATOR);
|
||||
stateListAnimator.addState(ENABLED_STATE_SET, set);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user