aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurelien Hubert <aurel.hubert@gmail.com>2016-04-27 14:01:57 +0200
committerAurelien Hubert <aurel.hubert@gmail.com>2016-04-27 14:01:57 +0200
commit04a8fd93b597813b5906e649c477bc39b7060bde (patch)
treeb1abe13eef357319970c0469ee5e308084f01178
parentc3a0a08d98a7ad026512be95ab048fe7a04f823e (diff)
downloadandroid_external_ahbottomnavigation-04a8fd93b597813b5906e649c477bc39b7060bde.tar.gz
android_external_ahbottomnavigation-04a8fd93b597813b5906e649c477bc39b7060bde.tar.bz2
android_external_ahbottomnavigation-04a8fd93b597813b5906e649c477bc39b7060bde.zip
Fixed #60 (touch ripple not visible)
-rw-r--r--ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java37
1 files changed, 28 insertions, 9 deletions
diff --git a/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java b/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java
index 80021e6..3abceb9 100644
--- a/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java
+++ b/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java
@@ -59,6 +59,7 @@ public class AHBottomNavigation extends FrameLayout {
private ArrayList<View> views = new ArrayList<>();
private AHBottomNavigationBehavior<AHBottomNavigation> bottomNavigationBehavior;
private View backgroundColorView;
+ private Animator circleRevealAnim;
private boolean colored = false;
private int[] notifications = {0, 0, 0, 0, 0};
private boolean isBehaviorTranslationSet = false;
@@ -473,20 +474,29 @@ public class AHBottomNavigation extends FrameLayout {
itemInactiveColor, itemActiveColor, forceTint);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && colored) {
- backgroundColorView.setBackgroundColor(items.get(itemIndex).getColor(context));
- int finalRadius = Math.max(getWidth(), getHeight());
+ int finalRadius = Math.max(getWidth(), getHeight());
int cx = (int) views.get(itemIndex).getX() + views.get(itemIndex).getWidth() / 2;
int cy = views.get(itemIndex).getHeight() / 2;
- Animator anim = ViewAnimationUtils.createCircularReveal(backgroundColorView, cx, cy, 0, finalRadius);
- anim.addListener(new Animator.AnimatorListener() {
+
+ if (circleRevealAnim != null && circleRevealAnim.isRunning()) {
+ circleRevealAnim.cancel();
+ setBackgroundColor(items.get(itemIndex).getColor(context));
+ backgroundColorView.setBackgroundColor(Color.TRANSPARENT);
+ }
+
+ circleRevealAnim = ViewAnimationUtils.createCircularReveal(backgroundColorView, cx, cy, 0, finalRadius);
+ circleRevealAnim.setStartDelay(5);
+ circleRevealAnim.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
+ backgroundColorView.setBackgroundColor(items.get(itemIndex).getColor(context));
}
@Override
public void onAnimationEnd(Animator animation) {
setBackgroundColor(items.get(itemIndex).getColor(context));
+ backgroundColorView.setBackgroundColor(Color.TRANSPARENT);
}
@Override
@@ -497,7 +507,7 @@ public class AHBottomNavigation extends FrameLayout {
public void onAnimationRepeat(Animator animation) {
}
});
- anim.start();
+ circleRevealAnim.start();
} else if (colored) {
AHHelper.updateViewBackgroundColor(this, currentColor,
items.get(itemIndex).getColor(context));
@@ -580,19 +590,28 @@ public class AHBottomNavigation extends FrameLayout {
itemInactiveColor, itemActiveColor, forceTint);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && colored) {
- backgroundColorView.setBackgroundColor(items.get(itemIndex).getColor(context));
int finalRadius = Math.max(getWidth(), getHeight());
int cx = (int) views.get(itemIndex).getX() + views.get(itemIndex).getWidth() / 2;
int cy = views.get(itemIndex).getHeight() / 2;
- Animator anim = ViewAnimationUtils.createCircularReveal(backgroundColorView, cx, cy, 0, finalRadius);
- anim.addListener(new Animator.AnimatorListener() {
+
+ if (circleRevealAnim != null && circleRevealAnim.isRunning()) {
+ circleRevealAnim.cancel();
+ setBackgroundColor(items.get(itemIndex).getColor(context));
+ backgroundColorView.setBackgroundColor(Color.TRANSPARENT);
+ }
+
+ circleRevealAnim = ViewAnimationUtils.createCircularReveal(backgroundColorView, cx, cy, 0, finalRadius);
+ circleRevealAnim.setStartDelay(5);
+ circleRevealAnim.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
+ backgroundColorView.setBackgroundColor(items.get(itemIndex).getColor(context));
}
@Override
public void onAnimationEnd(Animator animation) {
setBackgroundColor(items.get(itemIndex).getColor(context));
+ backgroundColorView.setBackgroundColor(Color.TRANSPARENT);
}
@Override
@@ -603,7 +622,7 @@ public class AHBottomNavigation extends FrameLayout {
public void onAnimationRepeat(Animator animation) {
}
});
- anim.start();
+ circleRevealAnim.start();
} else if (colored) {
AHHelper.updateViewBackgroundColor(this, currentColor,
items.get(itemIndex).getColor(context));