From 8ab6a25cfd28edc18064ad62eb2bdda6b4fe9834 Mon Sep 17 00:00:00 2001 From: mar-v-in Date: Fri, 9 Jan 2015 22:57:04 +0100 Subject: [PATCH] Full Tile support in Api --- .../android/gms/maps/model/MarkerOptions.java | 17 ++++++------- .../google/android/gms/maps/model/Tile.aidl | 3 +++ .../gms/maps/model/TileOverlayOptions.java | 24 +++++++++++++++++-- .../model/internal/ITileProviderDelegate.aidl | 7 ++++++ 4 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 src/com/google/android/gms/maps/model/Tile.aidl create mode 100644 src/com/google/android/gms/maps/model/internal/ITileProviderDelegate.aidl diff --git a/src/com/google/android/gms/maps/model/MarkerOptions.java b/src/com/google/android/gms/maps/model/MarkerOptions.java index 4da6246..b268373 100644 --- a/src/com/google/android/gms/maps/model/MarkerOptions.java +++ b/src/com/google/android/gms/maps/model/MarkerOptions.java @@ -37,11 +37,8 @@ public class MarkerOptions implements SafeParcelable { * This is a IBinder to the remote BitmapDescriptor created using BitmapDescriptorFactory */ @SafeParceled(5) - private IBinder icon; - /** - * The real BitmapDescriptor. Not transferred through Parcel. - */ - private BitmapDescriptor iconDescriptor; + private IBinder iconBinder; + private BitmapDescriptor icon; @SafeParceled(6) private float anchorU = 0.5F; @SafeParceled(7) @@ -167,10 +164,10 @@ public class MarkerOptions implements SafeParcelable { * custom icon is set. */ public BitmapDescriptor getIcon() { - if (iconDescriptor == null && icon != null) { - iconDescriptor = new BitmapDescriptor(ObjectWrapper.asInterface(icon)); + if (icon == null && iconBinder != null) { + icon = new BitmapDescriptor(ObjectWrapper.asInterface(iconBinder)); } - return iconDescriptor; + return icon; } /** @@ -234,8 +231,8 @@ public class MarkerOptions implements SafeParcelable { * @return the object for which the method was called, with the new icon set. */ public MarkerOptions icon(BitmapDescriptor icon) { - this.iconDescriptor = icon; - this.icon = icon == null ? null : icon.getRemoteObject().asBinder(); + this.icon = icon; + this.iconBinder = icon == null ? null : icon.getRemoteObject().asBinder(); return this; } diff --git a/src/com/google/android/gms/maps/model/Tile.aidl b/src/com/google/android/gms/maps/model/Tile.aidl new file mode 100644 index 0000000..54f1872 --- /dev/null +++ b/src/com/google/android/gms/maps/model/Tile.aidl @@ -0,0 +1,3 @@ +package com.google.android.gms.maps.model; + +parcelable Tile; diff --git a/src/com/google/android/gms/maps/model/TileOverlayOptions.java b/src/com/google/android/gms/maps/model/TileOverlayOptions.java index 6fad3fd..b38a5dc 100644 --- a/src/com/google/android/gms/maps/model/TileOverlayOptions.java +++ b/src/com/google/android/gms/maps/model/TileOverlayOptions.java @@ -16,19 +16,33 @@ package com.google.android.gms.maps.model; +import android.os.IBinder; import android.os.Parcel; +import android.os.RemoteException; +import com.google.android.gms.maps.model.internal.ITileProviderDelegate; import org.microg.safeparcel.SafeParcelUtil; import org.microg.safeparcel.SafeParcelable; +import org.microg.safeparcel.SafeParceled; /** * Defines options for a TileOverlay. */ public class TileOverlayOptions implements SafeParcelable { + @SafeParceled(1) + private final int versionCode = 1; + /** + * This is a IBinder to the {@link #tileProvider}, built using {@link ITileProviderDelegate}. + */ + @SafeParceled(2) + private IBinder tileProviderBinder; private TileProvider tileProvider; + @SafeParceled(3) private boolean visible = true; - private boolean fadeIn = true; + @SafeParceled(4) private float zIndex; + @SafeParceled(5) + private boolean fadeIn = true; /** * Creates a new set of tile overlay options. @@ -97,8 +111,14 @@ public class TileOverlayOptions implements SafeParcelable { * @param tileProvider the {@link TileProvider} to use for this tile overlay. * @return the object for which the method was called, with the new tile provider set. */ - public TileOverlayOptions tileProvider(TileProvider tileProvider) { + public TileOverlayOptions tileProvider(final TileProvider tileProvider) { this.tileProvider = tileProvider; + this.tileProviderBinder = new ITileProviderDelegate.Stub() { + @Override + public Tile getTile(int x, int y, int zoom) throws RemoteException { + return tileProvider.getTile(x, y, zoom); + } + }; return this; } diff --git a/src/com/google/android/gms/maps/model/internal/ITileProviderDelegate.aidl b/src/com/google/android/gms/maps/model/internal/ITileProviderDelegate.aidl new file mode 100644 index 0000000..d6dc516 --- /dev/null +++ b/src/com/google/android/gms/maps/model/internal/ITileProviderDelegate.aidl @@ -0,0 +1,7 @@ +package com.google.android.gms.maps.model.internal; + +import com.google.android.gms.maps.model.Tile; + +interface ITileProviderDelegate { + Tile getTile(int x, int y, int zoom); +}