-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55afb23
commit ce7d83d
Showing
3 changed files
with
62 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...in/java/com/mapbox/services/android/navigation/ui/v5/alert/AlertViewAnimatorListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.mapbox.services.android.navigation.ui.v5.alert; | ||
|
||
import android.animation.Animator; | ||
|
||
import java.lang.ref.WeakReference; | ||
|
||
class AlertViewAnimatorListener implements Animator.AnimatorListener { | ||
|
||
private final WeakReference<AlertView> alertViewWeakReference; | ||
|
||
AlertViewAnimatorListener(AlertView alertView) { | ||
this.alertViewWeakReference = new WeakReference<>(alertView); | ||
} | ||
|
||
@Override | ||
public void onAnimationStart(Animator animation) { | ||
} | ||
|
||
@Override | ||
public void onAnimationEnd(Animator animation) { | ||
hideAlertView(); | ||
} | ||
|
||
@Override | ||
public void onAnimationCancel(Animator animation) { | ||
} | ||
|
||
@Override | ||
public void onAnimationRepeat(Animator animation) { | ||
} | ||
|
||
private void hideAlertView() { | ||
AlertView alertView = alertViewWeakReference.get(); | ||
if (alertView != null) { | ||
alertView.hide(); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...ava/com/mapbox/services/android/navigation/ui/v5/alert/AlertViewAnimatorListenerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.mapbox.services.android.navigation.ui.v5.alert; | ||
|
||
import android.animation.Animator; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.verify; | ||
|
||
public class AlertViewAnimatorListenerTest { | ||
|
||
@Test | ||
public void onAnimationEnd_alertViewIsHidden() { | ||
AlertView alertView = mock(AlertView.class); | ||
AlertViewAnimatorListener listener = new AlertViewAnimatorListener(alertView); | ||
|
||
listener.onAnimationEnd(mock(Animator.class)); | ||
|
||
verify(alertView).hide(); | ||
} | ||
} |