Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Java
  • Loading branch information
yaakovschectman committed Sep 9, 2024
commit e54cc9dbc7bc4933a5d72e667742aa5cc11c1a02
Original file line number Diff line number Diff line change
Expand Up @@ -341,47 +341,46 @@ static CameraPosition toCameraPosition(Object o) {
}

static CameraUpdate cameraUpdateFromPigeon(Messages.PlatformCameraUpdate update, float density) {
Messages.PlatformNewCameraPosition newCameraPosition = update.getNewCameraPosition();
if (newCameraPosition != null) {
Object cameraUpdate = update.getCameraUpdate();
if (cameraUpdate instanceof Messages.PlatformCameraUpdateNewCameraPosition) {
Messages.PlatformCameraUpdateNewCameraPosition newCameraPosition = (Messages.PlatformCameraUpdateNewCameraPosition) cameraUpdate;
return CameraUpdateFactory.newCameraPosition(
cameraPositionFromPigeon(newCameraPosition.getCameraPosition()));
}
Messages.PlatformNewLatLng newLatLng = update.getNewLatLng();
if (newLatLng != null) {
if (cameraUpdate instanceof Messages.PlatformCameraUpdateNewLatLng) {
Messages.PlatformCameraUpdateNewLatLng newLatLng = (Messages.PlatformCameraUpdateNewLatLng) cameraUpdate;
return CameraUpdateFactory.newLatLng(latLngFromPigeon(newLatLng.getLatLng()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may not be following the types here but is it possible to make this CameraUpdateFactory.newLatLng(latLngFromPigeon(newLatLng); It seems, based on names alone that we should not need so many unboxing/reboxing of lat long data.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newLatLng is an instance of PlatformNewLatLng, which represents the camera move update to the new position. latLngFromPigeon accepts a PlatformLatLng, which is just a boxed pair of numeric coordinates, not a PlatformNewLatLng. I intend to add a CameraUpdate prefix to the relevant classes, including PlatformNewLatLng, as per Stuart's comment, which I believe will make this more clear.

}
Messages.PlatformNewLatLngZoom newLatLngZoom = update.getNewLatLngZoom();
if (newLatLngZoom != null) {
if (cameraUpdate instanceof Messages.PlatformCameraUpdateNewLatLngZoom) {
Messages.PlatformCameraUpdateNewLatLngZoom newLatLngZoom = (Messages.PlatformCameraUpdateNewLatLngZoom) cameraUpdate;
return CameraUpdateFactory.newLatLngZoom(
latLngFromPigeon(newLatLngZoom.getLatLng()), newLatLngZoom.getZoom().floatValue());
}
Messages.PlatformNewLatLngBounds newLatLngBounds = update.getNewLatLngBounds();
if (newLatLngBounds != null) {
if (cameraUpdate instanceof Messages.PlatformCameraUpdateNewLatLngBounds) {
Messages.PlatformCameraUpdateNewLatLngBounds newLatLngBounds = (Messages.PlatformCameraUpdateNewLatLngBounds) cameraUpdate;
return CameraUpdateFactory.newLatLngBounds(
latLngBoundsFromPigeon(newLatLngBounds.getBounds()),
(int) (newLatLngBounds.getPadding() * density));
}
Messages.PlatformScrollBy scrollBy = update.getScrollBy();
if (scrollBy != null) {
if (cameraUpdate instanceof Messages.PlatformCameraUpdateScrollBy) {
Messages.PlatformCameraUpdateScrollBy scrollBy = (Messages.PlatformCameraUpdateScrollBy) cameraUpdate;
return CameraUpdateFactory.scrollBy(
scrollBy.getDx().floatValue() * density, scrollBy.getDy().floatValue() * density);
}
Messages.PlatformZoomBy zoomBy = update.getZoomBy();
if (zoomBy != null) {
if (cameraUpdate instanceof Messages.PlatformCameraUpdateZoomBy) {
Messages.PlatformCameraUpdateZoomBy zoomBy = (Messages.PlatformCameraUpdateZoomBy) cameraUpdate;
final Point focus = pointFromPigeon(zoomBy.getFocus(), density);
return (focus != null)
? CameraUpdateFactory.zoomBy(zoomBy.getAmount().floatValue(), focus)
: CameraUpdateFactory.zoomBy(zoomBy.getAmount().floatValue());
}
Messages.PlatformZoomTo zoomTo = update.getZoomTo();
if (zoomTo != null) {
if (cameraUpdate instanceof Messages.PlatformCameraUpdateZoomTo) {
Messages.PlatformCameraUpdateZoomTo zoomTo = (Messages.PlatformCameraUpdateZoomTo) cameraUpdate;
return CameraUpdateFactory.zoomTo(zoomTo.getZoom().floatValue());
}
if (update.getZoomIn()) {
return CameraUpdateFactory.zoomIn();
}
if (update.getZoomOut()) {
return CameraUpdateFactory.zoomOut();
if (cameraUpdate instanceof Messages.PlatformCameraUpdateZoom) {
Messages.PlatformCameraUpdateZoom zoom = (Messages.PlatformCameraUpdateZoom) cameraUpdate;
return (zoom.getOut()) ? CameraUpdateFactory.zoomOut() : CameraUpdateFactory.zoomIn();
}
throw new IllegalArgumentException("PlatformCameraUpdate must have one non-null member.");
}
Expand Down