aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurelien Hubert <aurel.hubert@gmail.com>2016-03-19 12:40:12 +0100
committerAurelien Hubert <aurel.hubert@gmail.com>2016-03-19 12:40:12 +0100
commit5ce8eae6955905e3bd201965f834612a0598e120 (patch)
treecb1b6a2d31b36e9f38db8fade3dced996a481464
parent1ff5faa9fc69e9dcda7f0378058ee820b693998b (diff)
downloadandroid_external_ahbottomnavigation-5ce8eae6955905e3bd201965f834612a0598e120.tar.gz
android_external_ahbottomnavigation-5ce8eae6955905e3bd201965f834612a0598e120.tar.bz2
android_external_ahbottomnavigation-5ce8eae6955905e3bd201965f834612a0598e120.zip
Add a new interface (with wasSelected attribute)
Update demo
-rw-r--r--ahbottomnavigation/build.gradle2
-rw-r--r--ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java68
-rw-r--r--demo/src/main/java/aurelhubert/com/ahbottomnavigation/DemoActivity.java13
3 files changed, 54 insertions, 29 deletions
diff --git a/ahbottomnavigation/build.gradle b/ahbottomnavigation/build.gradle
index 7ae1833..159fcef 100644
--- a/ahbottomnavigation/build.gradle
+++ b/ahbottomnavigation/build.gradle
@@ -13,7 +13,7 @@ ext {
siteUrl = 'https://github.com/aurelhubert/ahbottomnavigation'
gitUrl = 'https://github.com/aurelhubert/ahbottomnavigation.git'
- libraryVersion = '0.1.1'
+ libraryVersion = '0.1.2'
developerId = 'aurelhubert'
developerName = 'Aurelien Hubert'
diff --git a/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java b/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java
index 446ffba..32c7b4f 100644
--- a/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java
+++ b/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java
@@ -33,6 +33,7 @@ public class AHBottomNavigation extends FrameLayout {
// Listener
private AHBottomNavigationListener listener;
+ private OnTabSelectedListener tabSelectedListener;
// Variables
private Context context;
@@ -323,8 +324,8 @@ public class AHBottomNavigation extends FrameLayout {
private void updateItems(final int itemIndex) {
if (currentItem == itemIndex) {
- if (listener != null) {
- listener.onCurrentTabSelected(itemIndex);
+ if (tabSelectedListener != null) {
+ tabSelectedListener.onTabSelected(itemIndex, true);
}
return;
}
@@ -405,6 +406,9 @@ public class AHBottomNavigation extends FrameLayout {
if (listener != null) {
listener.onTabSelected(itemIndex);
}
+ if (tabSelectedListener != null) {
+ tabSelectedListener.onTabSelected(itemIndex, false);
+ }
}
/**
@@ -413,8 +417,8 @@ public class AHBottomNavigation extends FrameLayout {
private void updateSmallItems(final int itemIndex) {
if (currentItem == itemIndex) {
- if (listener != null) {
- listener.onCurrentTabSelected(itemIndex);
+ if (tabSelectedListener != null) {
+ tabSelectedListener.onTabSelected(itemIndex, true);
}
return;
}
@@ -494,6 +498,9 @@ public class AHBottomNavigation extends FrameLayout {
if (listener != null) {
listener.onTabSelected(itemIndex);
}
+ if (tabSelectedListener != null) {
+ tabSelectedListener.onTabSelected(itemIndex, false);
+ }
}
@@ -558,20 +565,6 @@ public class AHBottomNavigation extends FrameLayout {
/**
- * Set the GraphView listener
- */
- public void setAHBottomNavigationListener(AHBottomNavigationListener listener) {
- this.listener = listener;
- }
-
- /**
- * Remove the GraphView listener
- */
- public void removeAHBottomNavigationListener() {
- this.listener = null;
- }
-
- /**
* Return the bottom navigation background color
*
* @return The bottom navigation background color
@@ -658,6 +651,36 @@ public class AHBottomNavigation extends FrameLayout {
}
}
+ /**
+ * Set the GraphView listener
+ */
+ @Deprecated
+ public void setAHBottomNavigationListener(AHBottomNavigationListener listener) {
+ this.listener = listener;
+ }
+
+ /**
+ * Remove the GraphView listener
+ */
+ @Deprecated
+ public void removeAHBottomNavigationListener() {
+ this.listener = null;
+ }
+
+ /**
+ * Set AHOnTabSelectedListener
+ */
+ public void setOnTabSelectedListener(OnTabSelectedListener tabSelectedListener) {
+ this.tabSelectedListener = tabSelectedListener;
+ }
+
+ /**
+ * Remove AHOnTabSelectedListener
+ */
+ public void removeOnTabSelectedListener() {
+ this.tabSelectedListener = null;
+ }
+
////////////////
// INTERFACES //
////////////////
@@ -665,9 +688,16 @@ public class AHBottomNavigation extends FrameLayout {
/**
* Interface for Bottom Navigation
*/
+ @Deprecated
public interface AHBottomNavigationListener {
void onTabSelected(int position);
- void onCurrentTabSelected(int position);
+ }
+
+ /**
+ *
+ */
+ public interface OnTabSelectedListener {
+ void onTabSelected(int position, boolean wasSelected);
}
} \ No newline at end of file
diff --git a/demo/src/main/java/aurelhubert/com/ahbottomnavigation/DemoActivity.java b/demo/src/main/java/aurelhubert/com/ahbottomnavigation/DemoActivity.java
index 437762c..96d5793 100644
--- a/demo/src/main/java/aurelhubert/com/ahbottomnavigation/DemoActivity.java
+++ b/demo/src/main/java/aurelhubert/com/ahbottomnavigation/DemoActivity.java
@@ -45,15 +45,10 @@ public class DemoActivity extends AppCompatActivity {
bottomNavigation.addItems(items);
bottomNavigation.setAccentColor(Color.parseColor("#F63D2B"));
bottomNavigation.setInactiveColor(Color.parseColor("#747474"));
- bottomNavigation.setAHBottomNavigationListener(new AHBottomNavigation.AHBottomNavigationListener() {
+ bottomNavigation.setOnTabSelectedListener(new AHBottomNavigation.OnTabSelectedListener() {
@Override
- public void onTabSelected(int position) {
- currentItem.setText("Current item: " + position);
- }
-
- @Override
- public void onCurrentTabSelected(int position) {
- currentItem.setText("Click on current item (" + position + ")");
+ public void onTabSelected(int position, boolean wasSelected) {
+ currentItem.setText("Current item: " + position + "\n(was selected: " + wasSelected + ")");
}
});
@@ -76,7 +71,7 @@ public class DemoActivity extends AppCompatActivity {
}
}
});
-
+
}
}