From 85cc5f9b9778e0b4b2e460531d3176dcd02973eb Mon Sep 17 00:00:00 2001 From: Aurelien Hubert Date: Wed, 25 May 2016 11:43:04 +0200 Subject: Fixed bug with BehaviorTranslation --- .../ahbottomnavigation/AHBottomNavigation.java | 6 +++++- .../ahbottomnavigation/AHBottomNavigationBehavior.java | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java b/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java index 238ab0f..a3dd16f 100644 --- a/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java +++ b/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java @@ -961,7 +961,11 @@ public class AHBottomNavigation extends FrameLayout { this.behaviorTranslationEnabled = behaviorTranslationEnabled; if (getParent() instanceof CoordinatorLayout) { ViewGroup.LayoutParams params = getLayoutParams(); - bottomNavigationBehavior = new AHBottomNavigationBehavior<>(behaviorTranslationEnabled); + if (bottomNavigationBehavior == null) { + bottomNavigationBehavior = new AHBottomNavigationBehavior<>(behaviorTranslationEnabled); + } else { + bottomNavigationBehavior.setBehaviorTranslationEnabled(behaviorTranslationEnabled); + } ((CoordinatorLayout.LayoutParams) params).setBehavior(bottomNavigationBehavior); if (needHideBottomNavigation) { needHideBottomNavigation = false; diff --git a/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigationBehavior.java b/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigationBehavior.java index 43d6d39..5e5b900 100644 --- a/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigationBehavior.java +++ b/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigationBehavior.java @@ -94,8 +94,15 @@ public class AHBottomNavigationBehavior extends VerticalScrollin handleDirection(child, scrollDirection); } - + /** + * Handle scroll direction + * @param child + * @param scrollDirection + */ private void handleDirection(V child, int scrollDirection) { + if (!behaviorTranslationEnabled) { + return; + } if (scrollDirection == ScrollDirection.SCROLL_DIRECTION_DOWN && hidden) { hidden = false; animateOffset(child, 0, false, true); @@ -219,6 +226,14 @@ public class AHBottomNavigationBehavior extends VerticalScrollin this.mTabLayoutId = tabId; } + /** + * Enable or not the behavior translation + * @param behaviorTranslationEnabled + */ + public void setBehaviorTranslationEnabled(boolean behaviorTranslationEnabled) { + this.behaviorTranslationEnabled = behaviorTranslationEnabled; + } + /** * Hide AHBottomNavigation with animation * @param view -- cgit v1.2.3