aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurelien Hubert <aurel.hubert@gmail.com>2016-05-25 11:43:04 +0200
committerAurelien Hubert <aurel.hubert@gmail.com>2016-05-25 11:43:04 +0200
commit85cc5f9b9778e0b4b2e460531d3176dcd02973eb (patch)
treec6eec5c92817f6ee2f59044062a7fc1a2e905952
parent060ca086c2b85affdea36ba78700e8ffcba35876 (diff)
downloadandroid_external_ahbottomnavigation-85cc5f9b9778e0b4b2e460531d3176dcd02973eb.tar.gz
android_external_ahbottomnavigation-85cc5f9b9778e0b4b2e460531d3176dcd02973eb.tar.bz2
android_external_ahbottomnavigation-85cc5f9b9778e0b4b2e460531d3176dcd02973eb.zip
Fixed bug with BehaviorTranslation
-rw-r--r--ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java6
-rw-r--r--ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigationBehavior.java17
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<V extends View> 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);
@@ -220,6 +227,14 @@ public class AHBottomNavigationBehavior<V extends View> extends VerticalScrollin
}
/**
+ * Enable or not the behavior translation
+ * @param behaviorTranslationEnabled
+ */
+ public void setBehaviorTranslationEnabled(boolean behaviorTranslationEnabled) {
+ this.behaviorTranslationEnabled = behaviorTranslationEnabled;
+ }
+
+ /**
* Hide AHBottomNavigation with animation
* @param view
* @param offset