Skip to content

Commit 934985e

Browse files
imhappidsn5ft
authored andcommittedMay 16, 2022
[FAB] Updated FAB to use new motion attributes.
PiperOrigin-RevId: 449046932
1 parent 265cb86 commit 934985e

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed
 

‎lib/java/com/google/android/material/floatingactionbutton/FloatingActionButtonImpl.java

+20-5
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ class FloatingActionButtonImpl {
8787
private static final float SPEC_HIDE_SCALE = 0f;
8888
private static final float SPEC_HIDE_ICON_SCALE = 0f;
8989

90+
private static final int SHOW_ANIM_DURATION_ATTR = R.attr.motionDurationLong2;
91+
private static final int SHOW_ANIM_EASING_ATTR = R.attr.motionEasingEmphasizedInterpolator;
92+
private static final int HIDE_ANIM_DURATION_ATTR = R.attr.motionDurationMedium1;
93+
private static final int HIDE_ANIM_EASING_ATTR =
94+
R.attr.motionEasingEmphasizedAccelerateInterpolator;
95+
9096
@Nullable ShapeAppearanceModel shapeAppearance;
9197
@Nullable MaterialShapeDrawable shapeDrawable;
9298
@Nullable Drawable rippleDrawable;
@@ -438,7 +444,11 @@ void hide(@Nullable final InternalVisibilityChangedListener listener, final bool
438444
} else {
439445
set =
440446
createDefaultAnimator(
441-
HIDE_OPACITY, HIDE_SCALE, HIDE_ICON_SCALE);
447+
HIDE_OPACITY,
448+
HIDE_SCALE,
449+
HIDE_ICON_SCALE,
450+
HIDE_ANIM_DURATION_ATTR,
451+
HIDE_ANIM_EASING_ATTR);
442452
}
443453

444454
set.addListener(
@@ -520,7 +530,11 @@ void show(@Nullable final InternalVisibilityChangedListener listener, final bool
520530
} else {
521531
set =
522532
createDefaultAnimator(
523-
SHOW_OPACITY, SHOW_SCALE, SHOW_ICON_SCALE);
533+
SHOW_OPACITY,
534+
SHOW_SCALE,
535+
SHOW_ICON_SCALE,
536+
SHOW_ANIM_DURATION_ATTR,
537+
SHOW_ANIM_EASING_ATTR);
524538
}
525539

526540
set.addListener(
@@ -614,7 +628,8 @@ public Matrix evaluate(
614628
* are changed.
615629
*/
616630
private AnimatorSet createDefaultAnimator(
617-
final float targetOpacity, final float targetScale, final float targetIconScale) {
631+
final float targetOpacity, final float targetScale, final float targetIconScale,
632+
final int duration, final int interpolator) {
618633
AnimatorSet set = new AnimatorSet();
619634
List<Animator> animators = new ArrayList<>();
620635
ValueAnimator animator = ValueAnimator.ofFloat(0F, 1F);
@@ -644,14 +659,14 @@ public void onAnimationUpdate(ValueAnimator animation) {
644659
set.setDuration(
645660
MotionUtils.resolveThemeDuration(
646661
view.getContext(),
647-
R.attr.motionDurationLong1,
662+
duration,
648663
view.getContext()
649664
.getResources()
650665
.getInteger(R.integer.material_motion_duration_long_1)));
651666
set.setInterpolator(
652667
MotionUtils.resolveThemeInterpolator(
653668
view.getContext(),
654-
R.attr.motionEasingStandard,
669+
interpolator,
655670
AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR));
656671
return set;
657672
}

0 commit comments

Comments
 (0)
Please sign in to comment.