[Android] Hide FAB on scroll
Geoffrey Métais
git at videolan.org
Mon Feb 13 12:11:27 CET 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Feb 13 10:08:17 2017 +0100| [dddcf4497157cfcce38ad4bd84bcb672eb25bce9] | committer: Geoffrey Métais
Hide FAB on scroll
> https://code.videolan.org/videolan/vlc-android/commit/dddcf4497157cfcce38ad4bd84bcb672eb25bce9
---
.../vlc/gui/audio/AudioAlbumsSongsFragment.java | 4 ----
.../vlc/gui/browser/BaseBrowserFragment.java | 2 +-
.../vlc/gui/browser/MediaBrowserFragment.java | 2 +-
.../gui/helpers/FloatingActionButtonBehavior.java | 25 ++++++++++++++++++++++
4 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
index c2a7e67..d6e70f8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
@@ -46,7 +46,6 @@ import org.videolan.medialibrary.media.MediaWrapper;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.PlaylistActivity;
-import org.videolan.vlc.gui.SecondaryActivity;
import org.videolan.vlc.gui.dialogs.SavePlaylistDialog;
import org.videolan.vlc.gui.helpers.AudioUtil;
import org.videolan.vlc.gui.helpers.UiTools;
@@ -335,9 +334,6 @@ public class AudioAlbumsSongsFragment extends BaseAudioBrowser implements SwipeR
}
@Override
- public void setFabPlayVisibility(boolean enable) {}
-
- @Override
public void onTabSelected(TabLayout.Tab tab) {
mFastScroller.setRecyclerView(mLists[tab.getPosition()]);
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
index 2eaf010..628ce6c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -766,7 +766,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
mFabPlay.setVisibility(View.VISIBLE);
mFabPlay.setOnClickListener(this);
} else {
- mFabPlay.setVisibility(View.INVISIBLE);
+ mFabPlay.setVisibility(View.GONE);
mFabPlay.setOnClickListener(null);
}
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java
index 7868000..ec4230b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.java
@@ -104,7 +104,7 @@ public abstract class MediaBrowserFragment extends PlaybackServiceFragment imple
public void setFabPlayVisibility(boolean enable) {
if (mFabPlay != null)
- mFabPlay.setVisibility(enable ? View.VISIBLE : View.INVISIBLE);
+ mFabPlay.setVisibility(enable ? View.VISIBLE : View.GONE);
}
public void onFabPlayClick(View view) {}
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 ad66f1d..d2cd080 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/FloatingActionButtonBehavior.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/FloatingActionButtonBehavior.java
@@ -41,8 +41,19 @@ public class FloatingActionButtonBehavior extends FloatingActionButton.Behavior
private static final String TAG = "VLC/FloatingActionButtonBehavior";
+ // Listener to workaroud AppCompat 25.x bug
+ // FAB doesn't receive any callback when set to GONE.
+ private final FloatingActionButton.OnVisibilityChangedListener mOnVisibilityChangedListener;
+
public FloatingActionButtonBehavior(Context context, AttributeSet attrs) {
super(context, attrs);
+ mOnVisibilityChangedListener = new FloatingActionButton.OnVisibilityChangedListener() {
+ @Override
+ public void onHidden(FloatingActionButton fab) {
+ fab.setVisibility(View.INVISIBLE);
+ }
+
+ };
}
@Override
@@ -51,6 +62,11 @@ public class FloatingActionButtonBehavior extends FloatingActionButton.Behavior
}
@Override
+ public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View directTargetChild, View target, int nestedScrollAxes) {
+ return true;
+ }
+
+ @Override
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();
@@ -59,4 +75,13 @@ public class FloatingActionButtonBehavior extends FloatingActionButton.Behavior
} 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);
+ if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE)
+ child.hide(mOnVisibilityChangedListener);
+ else if (dyConsumed < 0 && child.getVisibility() == View.INVISIBLE)
+ child.show();
+ }
}
More information about the Android
mailing list