[Android] FAB Behavior: Update code for RecyclerViews

Geoffrey Métais git at videolan.org
Fri Jan 18 18:23:49 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Jan 18 18:21:33 2019 +0100| [cf212c83b0d64053d59e7b81b952beb8bff12ad7] | committer: Geoffrey Métais

FAB Behavior: Update code for RecyclerViews

> https://code.videolan.org/videolan/vlc-android/commit/cf212c83b0d64053d59e7b81b952beb8bff12ad7
---

 .../gui/helpers/FloatingActionButtonBehavior.java  | 27 ++++++++++++++--------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/FloatingActionButtonBehavior.java b/vlc-android/src/org/videolan/vlc/gui/helpers/FloatingActionButtonBehavior.java
index 19007e040..b8ebd269c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/FloatingActionButtonBehavior.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/FloatingActionButtonBehavior.java
@@ -25,17 +25,22 @@
 package org.videolan.vlc.gui.helpers;
 
 import android.content.Context;
-import androidx.annotation.Keep;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.View;
+
 import com.google.android.material.appbar.AppBarLayout;
-import androidx.coordinatorlayout.widget.CoordinatorLayout;
 import com.google.android.material.floatingactionbutton.FloatingActionButton;
 import com.google.android.material.snackbar.Snackbar;
-import androidx.core.view.ViewCompat;
-import android.util.AttributeSet;
-import android.view.View;
 
 import org.videolan.vlc.R;
 
+import androidx.annotation.Keep;
+import androidx.annotation.NonNull;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
+import androidx.core.view.ViewCompat;
+import androidx.recyclerview.widget.RecyclerView;
+
 @Keep
 public class FloatingActionButtonBehavior extends FloatingActionButton.Behavior {
 
@@ -58,11 +63,13 @@ public class FloatingActionButtonBehavior extends FloatingActionButton.Behavior
 
     @Override
     public boolean layoutDependsOn(CoordinatorLayout parent, FloatingActionButton child, View dependency) {
-        return dependency.getId() == R.id.audio_player_container || dependency instanceof Snackbar.SnackbarLayout || dependency instanceof AppBarLayout;
+        return dependency.getId() == R.id.audio_player_container
+                || dependency instanceof Snackbar.SnackbarLayout
+                || dependency instanceof RecyclerView;
     }
 
     @Override
-    public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View directTargetChild, View target, int nestedScrollAxes) {
+    public boolean onStartNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull FloatingActionButton child, @NonNull View directTargetChild, @NonNull View target, int axes, int type) {
         return true;
     }
 
@@ -70,15 +77,15 @@ public class FloatingActionButtonBehavior extends FloatingActionButton.Behavior
     public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton child, View dependency) {
         if (dependency.getId() == R.id.audio_player_container && dependency.getVisibility() == View.VISIBLE) {
             int childHeight = ((CoordinatorLayout.LayoutParams)child.getLayoutParams()).bottomMargin + child.getHeight();
-            ViewCompat.setY(child, ViewCompat.getY(dependency) - childHeight);
+            child.setY(dependency.getY()-childHeight);
             return true;
         } else
             return super.onDependentViewChanged(parent, child, dependency);
     }
 
     @Override
-    public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
-        super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
+    public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull FloatingActionButton child, @NonNull View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type) {
+        super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type);
         if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE)
             child.hide(mOnVisibilityChangedListener);
         else if (dyConsumed < 0 && child.getVisibility() == View.INVISIBLE)



More information about the Android mailing list