This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[android] - Camera change listener v2.0
- Loading branch information
Showing
7 changed files
with
277 additions
and
30 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
...id/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.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,67 @@ | ||
package com.mapbox.mapboxsdk.maps; | ||
|
||
import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraIdleListener; | ||
import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveCanceledListener; | ||
import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener; | ||
import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveListener; | ||
|
||
class CameraChangeDispatcher implements MapboxMap.OnCameraMoveStartedListener, MapboxMap.OnCameraMoveListener, | ||
MapboxMap.OnCameraMoveCanceledListener, OnCameraIdleListener { | ||
|
||
private boolean idle = true; | ||
|
||
private OnCameraMoveStartedListener onCameraMoveStartedListener; | ||
private OnCameraMoveCanceledListener onCameraMoveCanceledListener; | ||
private OnCameraMoveListener onCameraMoveListener; | ||
private OnCameraIdleListener onCameraIdleListener; | ||
|
||
void setOnCameraMoveStartedListener(OnCameraMoveStartedListener onCameraMoveStartedListener) { | ||
this.onCameraMoveStartedListener = onCameraMoveStartedListener; | ||
} | ||
|
||
void setOnCameraMoveCanceledListener(OnCameraMoveCanceledListener onCameraMoveCanceledListener) { | ||
this.onCameraMoveCanceledListener = onCameraMoveCanceledListener; | ||
} | ||
|
||
void setOnCameraMoveListener(OnCameraMoveListener onCameraMoveListener) { | ||
this.onCameraMoveListener = onCameraMoveListener; | ||
} | ||
|
||
void setOnCameraIdleListener(OnCameraIdleListener onCameraIdleListener) { | ||
this.onCameraIdleListener = onCameraIdleListener; | ||
} | ||
|
||
@Override | ||
public void onCameraMoveStarted(int reason) { | ||
if (!idle) { | ||
return; | ||
} | ||
|
||
idle = false; | ||
if (onCameraMoveStartedListener != null) { | ||
onCameraMoveStartedListener.onCameraMoveStarted(reason); | ||
} | ||
} | ||
|
||
@Override | ||
public void onCameraMove() { | ||
if (onCameraMoveListener != null && !idle) { | ||
onCameraMoveListener.onCameraMove(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onCameraMoveCanceled() { | ||
if (onCameraMoveCanceledListener != null && !idle) { | ||
onCameraMoveCanceledListener.onCameraMoveCanceled(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onCameraIdle() { | ||
if (onCameraIdleListener != null && !idle) { | ||
idle = true; | ||
onCameraIdleListener.onCameraIdle(); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.