-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add OnCameraTrackingChangedListener to NavigationMapboxMap (#1386)
- Loading branch information
1 parent
267fba6
commit c7ae8e9
Showing
7 changed files
with
105 additions
and
91 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
...m/mapbox/services/android/navigation/ui/v5/NavigationOnCameraTrackingChangedListener.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,34 @@ | ||
package com.mapbox.services.android.navigation.ui.v5; | ||
|
||
import android.support.design.widget.BottomSheetBehavior; | ||
|
||
import com.mapbox.mapboxsdk.plugins.locationlayer.OnCameraTrackingChangedListener; | ||
|
||
/** | ||
* Listener used to detect user interaction with the map while driving. | ||
* <p> | ||
* If the camera tracking is dismissed, we notify the presenter to adjust UI accordingly. | ||
*/ | ||
public class NavigationOnCameraTrackingChangedListener implements OnCameraTrackingChangedListener { | ||
|
||
private final NavigationPresenter navigationPresenter; | ||
private final BottomSheetBehavior summaryBehavior; | ||
|
||
NavigationOnCameraTrackingChangedListener(NavigationPresenter navigationPresenter, | ||
BottomSheetBehavior summaryBehavior) { | ||
this.navigationPresenter = navigationPresenter; | ||
this.summaryBehavior = summaryBehavior; | ||
} | ||
|
||
@Override | ||
public void onCameraTrackingDismissed() { | ||
if (summaryBehavior.getState() != BottomSheetBehavior.STATE_HIDDEN) { | ||
navigationPresenter.onCameraTrackingDismissed(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onCameraTrackingChanged(int currentMode) { | ||
// Intentionally empty | ||
} | ||
} |
23 changes: 0 additions & 23 deletions
23
...src/main/java/com/mapbox/services/android/navigation/ui/v5/NavigationOnFlingListener.java
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
.../src/main/java/com/mapbox/services/android/navigation/ui/v5/NavigationOnMoveListener.java
This file was deleted.
Oops, something went wrong.
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
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
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
42 changes: 42 additions & 0 deletions
42
...pbox/services/android/navigation/ui/v5/NavigationOnCameraTrackingChangedListenerTest.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,42 @@ | ||
package com.mapbox.services.android.navigation.ui.v5; | ||
|
||
import android.support.design.widget.BottomSheetBehavior; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class NavigationOnCameraTrackingChangedListenerTest { | ||
|
||
@Test | ||
public void onCameraTrackingDismissed_presenterNotifiedWithVisibleBottomsheet() { | ||
NavigationPresenter presenter = mock(NavigationPresenter.class); | ||
BottomSheetBehavior behavior = mock(BottomSheetBehavior.class); | ||
when(behavior.getState()).thenReturn(BottomSheetBehavior.STATE_EXPANDED); | ||
NavigationOnCameraTrackingChangedListener listener = new NavigationOnCameraTrackingChangedListener( | ||
presenter, behavior | ||
); | ||
|
||
listener.onCameraTrackingDismissed(); | ||
|
||
verify(presenter).onCameraTrackingDismissed(); | ||
} | ||
|
||
@Test | ||
public void onCameraTrackingDismissed_ignoredWithHiddenBottomsheet() { | ||
NavigationPresenter presenter = mock(NavigationPresenter.class); | ||
BottomSheetBehavior behavior = mock(BottomSheetBehavior.class); | ||
when(behavior.getState()).thenReturn(BottomSheetBehavior.STATE_HIDDEN); | ||
NavigationOnCameraTrackingChangedListener listener = new NavigationOnCameraTrackingChangedListener( | ||
presenter, behavior | ||
); | ||
|
||
listener.onCameraTrackingDismissed(); | ||
|
||
verify(presenter, times(0)).onCameraTrackingDismissed(); | ||
} | ||
} |