aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurelien Hubert <aurel.hubert@gmail.com>2016-03-31 10:39:46 +0200
committerAurelien Hubert <aurel.hubert@gmail.com>2016-03-31 10:39:46 +0200
commit1ef39a604da35f38bae0bebb37403e037c76f141 (patch)
tree0cbbf4f4fbc5a4c2f5b34a1b769ee7621229504c
parent5b30f66f9346bba93acec99d17c7a87ef8cf9a47 (diff)
downloadandroid_external_ahbottomnavigation-1ef39a604da35f38bae0bebb37403e037c76f141.tar.gz
android_external_ahbottomnavigation-1ef39a604da35f38bae0bebb37403e037c76f141.tar.bz2
android_external_ahbottomnavigation-1ef39a604da35f38bae0bebb37403e037c76f141.zip
Fixed crash when setForceTitlesDisplay(true)
Improved UI
-rw-r--r--ahbottomnavigation/build.gradle6
-rw-r--r--ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java38
-rw-r--r--demo/src/main/java/com/aurelhubert/ahbottomnavigation/demo/DemoActivity.java2
3 files changed, 27 insertions, 19 deletions
diff --git a/ahbottomnavigation/build.gradle b/ahbottomnavigation/build.gradle
index 7601711..b2419bc 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 = '1.0.1'
+ libraryVersion = '1.0.2'
developerId = 'aurelhubert'
developerName = 'Aurelien Hubert'
@@ -31,8 +31,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
- versionCode 11
- versionName "1.0.1"
+ versionCode 12
+ versionName "1.0.2"
}
buildTypes {
release {
diff --git a/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java b/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java
index a03055c..eb0fa4f 100644
--- a/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java
+++ b/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java
@@ -570,6 +570,10 @@ public class AHBottomNavigation extends FrameLayout {
float textSizeMin = getResources().getDimension(R.dimen.bottom_navigation_notification_text_size_min);
for (int i = 0; i < views.size(); i++) {
TextView notification = (TextView) views.get(i).findViewById(R.id.bottom_navigation_notification);
+
+ String currentValue = notification.getText().toString();
+ boolean animate = !currentValue.equals(String.valueOf(notifications[i]));
+
if (updateStyle) {
notification.setTextColor(notificationTextColor);
if (notificationTypeface != null) {
@@ -598,12 +602,14 @@ public class AHBottomNavigation extends FrameLayout {
if (notifications[i] == 0 && notification.getText().length() > 0) {
notification.setText("");
- notification.animate()
- .scaleX(0)
- .scaleY(0)
- .alpha(0)
- .setDuration(150)
- .start();
+ if (animate) {
+ notification.animate()
+ .scaleX(0)
+ .scaleY(0)
+ .alpha(0)
+ .setDuration(150)
+ .start();
+ }
} else if (notifications[i] > 0) {
if (notifications[i] >= 100) {
notification.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeMin);
@@ -612,14 +618,16 @@ public class AHBottomNavigation extends FrameLayout {
notification.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
notification.setText(String.valueOf(notifications[i]));
}
- notification.setScaleX(0);
- notification.setScaleY(0);
- notification.animate()
- .scaleX(1)
- .scaleY(1)
- .alpha(1)
- .setDuration(150)
- .start();
+ if (animate) {
+ notification.setScaleX(0);
+ notification.setScaleY(0);
+ notification.animate()
+ .scaleX(1)
+ .scaleY(1)
+ .alpha(1)
+ .setDuration(150)
+ .start();
+ }
}
}
}
@@ -773,7 +781,7 @@ public class AHBottomNavigation extends FrameLayout {
if (views.size() == 0) {
currentItem = position;
} else {
- if (items.size() == MIN_ITEMS) {
+ if (items.size() == MIN_ITEMS || forceTitlesDisplay) {
updateItems(position);
} else {
updateSmallItems(position);
diff --git a/demo/src/main/java/com/aurelhubert/ahbottomnavigation/demo/DemoActivity.java b/demo/src/main/java/com/aurelhubert/ahbottomnavigation/demo/DemoActivity.java
index 31f73f3..b146eda 100644
--- a/demo/src/main/java/com/aurelhubert/ahbottomnavigation/demo/DemoActivity.java
+++ b/demo/src/main/java/com/aurelhubert/ahbottomnavigation/demo/DemoActivity.java
@@ -75,7 +75,7 @@ public class DemoActivity extends AppCompatActivity {
handler.postDelayed(new Runnable() {
@Override
public void run() {
- bottomNavigation.setNotification(4, 1);
+ bottomNavigation.setNotification(16, 1);
}
}, 2000);
}