[android] Reuse Java Source objects by holding on to a strong reference in the C++ peer.

This commit is contained in:
Asheem Mamoowala
2017-11-13 16:06:26 -08:00
parent 3067b77c65
commit f06ebcc967
21 changed files with 187 additions and 197 deletions

View File

@@ -733,7 +733,7 @@ final class NativeMapView {
if (isDestroyedOn("addSource")) {
return;
}
nativeAddSource(source.getNativePtr());
nativeAddSource(source, source.getNativePtr());
}
@Nullable
@@ -741,14 +741,15 @@ final class NativeMapView {
if (isDestroyedOn("removeSource")) {
return null;
}
return nativeRemoveSourceById(sourceId);
Source source = getSource(sourceId);
return removeSource(source);
}
public Source removeSource(@NonNull Source source) {
if (isDestroyedOn("removeSource")) {
return null;
}
nativeRemoveSource(source.getNativePtr());
nativeRemoveSource(source, source.getNativePtr());
return source;
}
@@ -1027,11 +1028,9 @@ final class NativeMapView {
private native Source nativeGetSource(String sourceId);
private native void nativeAddSource(long nativeSourcePtr) throws CannotAddSourceException;
private native void nativeAddSource(Source source, long sourcePtr) throws CannotAddSourceException;
private native Source nativeRemoveSourceById(String sourceId);
private native void nativeRemoveSource(long sourcePtr);
private native void nativeRemoveSource(Source source, long sourcePtr);
private native void nativeAddImage(String name, int width, int height, float pixelRatio,
byte[] array);