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

Commit

Permalink
[android] #3244 - Adding @UIThread annotations and removing View.post…
Browse files Browse the repository at this point in the history
…() UIThread wrapping for Callback invoking. Restoring Callback Toasts in TestApp's CameraActivity.
  • Loading branch information
bleege committed Dec 18, 2015
1 parent f67f263 commit a17eb0a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,7 @@ public final CameraPosition getCameraPosition () {
* See CameraUpdateFactory for a set of updates.
* @param update The change that should be applied to the camera.
*/
@UiThread
public final void animateCamera (CameraUpdate update) {
animateCamera(update, 0, null);
}
Expand All @@ -1504,6 +1505,7 @@ public final void animateCamera (CameraUpdate update) {
* @param update The change that should be applied to the camera.
* @param callback The callback to invoke from the main thread when the animation stops. If the animation completes normally, onFinish() is called; otherwise, onCancel() is called. Do not update or animate the camera from within onCancel().
*/
@UiThread
public final void animateCamera (CameraUpdate update, MapView.CancelableCallback callback) {
animateCamera(update, 0, callback);
}
Expand All @@ -1515,6 +1517,7 @@ public final void animateCamera (CameraUpdate update, MapView.CancelableCallback
* @param durationMs The duration of the animation in milliseconds. This must be strictly positive, otherwise an IllegalArgumentException will be thrown.
* @param callback An optional callback to be notified from the main thread when the animation stops. If the animation stops due to its natural completion, the callback will be notified with onFinish(). If the animation stops due to interruption by a later camera movement or a user gesture, onCancel() will be called. The callback should not attempt to move or animate the camera in its cancellation method. If a callback isn't required, leave it as null.
*/
@UiThread
public final void animateCamera (CameraUpdate update, int durationMs, final MapView.CancelableCallback callback) {

if (update.getTarget() == null) {
Expand All @@ -1531,13 +1534,7 @@ public final void animateCamera (CameraUpdate update, int durationMs, final MapV
@Override
public void onMapChanged(@MapChange int change) {
if (change == REGION_DID_CHANGE_ANIMATED || change == REGION_DID_CHANGE) {
// Invoke callback on UI Thread
view.post(new Runnable() {
@Override
public void run() {
callback.onFinish();
}
});
callback.onFinish();

// Clean up after self
removeOnMapChangedListener(this);
Expand Down Expand Up @@ -2416,6 +2413,7 @@ public void deselectMarker(@NonNull Marker marker) {
* @param pitch Pitch in Radians
* @param zoom Zoom Level
*/
@UiThread
public void jumpTo(double bearing, LatLng center, double pitch, double zoom) {
mNativeMapView.jumpTo(bearing, center, pitch, zoom);
}
Expand All @@ -2430,6 +2428,7 @@ public void jumpTo(double bearing, LatLng center, double pitch, double zoom) {
* @param pitch Pitch in Radians
* @param zoom Zoom Level
*/
@UiThread
public void easeTo(double bearing, LatLng center, long duration, double pitch, double zoom) {
mNativeMapView.easeTo(bearing, center, duration, pitch, zoom);
}
Expand All @@ -2442,6 +2441,7 @@ public void easeTo(double bearing, LatLng center, long duration, double pitch,
* @param pitch Pitch in Radians
* @param zoom Zoom Level
*/
@UiThread
public void flyTo(double bearing, LatLng center, long duration, double pitch, double zoom) {
mNativeMapView.flyTo(bearing, center, duration, pitch, zoom);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,13 @@ public void onClick(View view) {
@Override
public void onCancel() {
Log.i(TAG, "Duration onCancel Callback called.");
Toast.makeText(CameraActivity.this, "Duration onCancel Callback called.", Toast.LENGTH_LONG).show();
}

@Override
public void onFinish() {
Log.i(TAG, "Duration onFinish Callback called.");
Toast.makeText(CameraActivity.this, "Duration onFinish Callback called.", Toast.LENGTH_LONG).show();
}
};

Expand Down

0 comments on commit a17eb0a

Please sign in to comment.