[android] Reuse Java Source objects by holding on to a strong reference in the C++ peer.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user