33import android .animation .Animator ;
44import android .animation .AnimatorListenerAdapter ;
55import android .animation .ValueAnimator ;
6+ import android .annotation .SuppressLint ;
67import android .content .Context ;
78import android .support .annotation .NonNull ;
89import android .support .design .widget .CoordinatorLayout ;
910import android .support .design .widget .Snackbar ;
1011import android .support .v4 .view .ViewCompat ;
1112import android .util .AttributeSet ;
1213import android .view .View ;
13-
1414import java .util .List ;
1515
1616/**
@@ -27,6 +27,7 @@ public FloatingActionBehavior(Context context, AttributeSet attrs) {
2727 super ();
2828 }
2929
30+ @ SuppressLint ("RestrictedApi" )
3031 @ Override
3132 public boolean layoutDependsOn (CoordinatorLayout parent , View child , View dependency ) {
3233 return dependency instanceof Snackbar .SnackbarLayout ;
@@ -50,7 +51,7 @@ private void updateTranslation(CoordinatorLayout parent, View child, View depend
5051 float translationY = this .getTranslationY (parent , child );
5152 if (translationY != this .mTranslationY ) {
5253 ViewCompat .animate (child ).cancel ();
53- if (Math .abs (translationY - this .mTranslationY ) == ( float ) dependency .getHeight ()) {
54+ if (Math .abs (translationY - this .mTranslationY ) == dependency .getHeight ()) {
5455 ViewCompat .animate (child ).translationY (translationY );
5556 } else {
5657 child .setTranslationY (translationY );
@@ -60,6 +61,7 @@ private void updateTranslation(CoordinatorLayout parent, View child, View depend
6061 }
6162 }
6263
64+ @ SuppressLint ("RestrictedApi" )
6365 private float getTranslationY (CoordinatorLayout parent , View child ) {
6466 float minOffset = 0.0F ;
6567 List <?> dependencies = parent .getDependencies (child );
@@ -68,7 +70,7 @@ private float getTranslationY(CoordinatorLayout parent, View child) {
6870 for (int z = dependencies .size (); i < z ; ++i ) {
6971 View view = (View ) dependencies .get (i );
7072 if (view instanceof Snackbar .SnackbarLayout && parent .doViewsOverlap (child , view )) {
71- minOffset = Math .min (minOffset , view .getTranslationY () - ( float ) view .getHeight ());
73+ minOffset = Math .min (minOffset , view .getTranslationY () - view .getHeight ());
7274 }
7375 }
7476
@@ -95,17 +97,14 @@ public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNul
9597 mAnimFlag = true ;
9698 ValueAnimator animator = ValueAnimator .ofFloat (1 , 0 );
9799 animator .setDuration (300 );
98- animator .addUpdateListener (new ValueAnimator .AnimatorUpdateListener () {
99- @ Override
100- public void onAnimationUpdate (ValueAnimator animation ) {
101- float scale = (float ) animation .getAnimatedValue ();
102- child .setScaleX (scale );
103- child .setScaleY (scale );
104- if (scale != 0 ) {
105- return ;
106- }
107- child .setVisibility (View .INVISIBLE );
100+ animator .addUpdateListener (animation -> {
101+ float scale = (float ) animation .getAnimatedValue ();
102+ child .setScaleX (scale );
103+ child .setScaleY (scale );
104+ if (scale != 0 ) {
105+ return ;
108106 }
107+ child .setVisibility (View .INVISIBLE );
109108 });
110109 animator .addListener (new AnimatorListenerAdapter () {
111110
@@ -128,13 +127,10 @@ public void onAnimationEnd(Animator animation) {
128127 child .setVisibility (View .VISIBLE );
129128 ValueAnimator animator = ValueAnimator .ofFloat (0 , 1 );
130129 animator .setDuration (300 );
131- animator .addUpdateListener (new ValueAnimator .AnimatorUpdateListener () {
132- @ Override
133- public void onAnimationUpdate (ValueAnimator animation ) {
134- float scale = (float ) animation .getAnimatedValue ();
135- child .setScaleX (scale );
136- child .setScaleY (scale );
137- }
130+ animator .addUpdateListener (animation -> {
131+ float scale = (float ) animation .getAnimatedValue ();
132+ child .setScaleX (scale );
133+ child .setScaleY (scale );
138134 });
139135 animator .addListener (new AnimatorListenerAdapter () {
140136
0 commit comments