Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] #4326 - making the code compatible with unit tests again
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun authored and bleege committed Mar 21, 2016
1 parent d329800 commit a0225d6
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,8 @@ public final void moveCamera(CameraUpdate update) {
*/
@UiThread
public final void moveCamera(CameraUpdate update, MapboxMap.CancelableCallback callback) {
CameraPosition position = update.getCameraPosition(this);
mMapView.jumpTo(position.bearing, position.target, position.tilt, position.zoom);
if (mOnCameraChangeListener != null) {
mOnCameraChangeListener.onCameraChange(mCameraPosition);
}
mCameraPosition = update.getCameraPosition(this);
mMapView.jumpTo(mCameraPosition.bearing, mCameraPosition.target, mCameraPosition.tilt, mCameraPosition.zoom);
if (callback != null) {
callback.onFinish();
}
Expand Down Expand Up @@ -289,8 +286,8 @@ public final void easeCamera(CameraUpdate update, int durationMs) {
*/
@UiThread
public final void easeCamera(CameraUpdate update, int durationMs, final MapboxMap.CancelableCallback callback) {
CameraPosition position = update.getCameraPosition(this);
mMapView.easeTo(position.bearing, position.target, getDurationNano(durationMs), position.tilt, position.zoom, new CancelableCallback() {
mCameraPosition = update.getCameraPosition(this);
mMapView.easeTo(mCameraPosition.bearing, mCameraPosition.target, getDurationNano(durationMs), mCameraPosition.tilt, mCameraPosition.zoom, new CancelableCallback() {
@Override
public void onCancel() {
if (callback != null) {
Expand Down Expand Up @@ -357,8 +354,8 @@ public final void animateCamera(CameraUpdate update, int durationMs) {
*/
@UiThread
public final void animateCamera(CameraUpdate update, int durationMs, final MapboxMap.CancelableCallback callback) {
CameraPosition cameraPosition = update.getCameraPosition(this);
mMapView.flyTo(cameraPosition.bearing, cameraPosition.target, getDurationNano(durationMs), cameraPosition.tilt, cameraPosition.zoom, new CancelableCallback() {
mCameraPosition = update.getCameraPosition(this);
mMapView.flyTo(mCameraPosition.bearing, mCameraPosition.target, getDurationNano(durationMs), mCameraPosition.tilt, mCameraPosition.zoom, new CancelableCallback() {
@Override
public void onCancel() {
if (callback != null) {
Expand Down Expand Up @@ -396,7 +393,12 @@ private long getDurationNano(long durationMs) {
*/
private void invalidateCameraPosition() {
mInvalidCameraPosition = false;
mCameraPosition = mMapView.invalidateCameraPosition();

CameraPosition cameraPosition = mMapView.invalidateCameraPosition();
if (cameraPosition != null) {
mCameraPosition = cameraPosition;
}

if (mOnCameraChangeListener != null) {
mOnCameraChangeListener.onCameraChange(mCameraPosition);
}
Expand Down

0 comments on commit a0225d6

Please sign in to comment.