diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/Source.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/Source.java | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/Source.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/Source.java index d9aacdc80d..58ffa12e35 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/Source.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/Source.java @@ -2,15 +2,38 @@ package com.mapbox.mapboxsdk.style.sources; import java.util.HashMap; -public abstract class Source extends HashMap<String, Object> { - private final String id; +/** + * Base Peer class for sources. see source.hpp for the other half of the peer. + */ +public abstract class Source { + private long nativePtr; + private boolean invalidated; - protected Source(String id, String type) { - this.put("type", type); - this.id = id; + public Source(long nativePtr) { + this.nativePtr = nativePtr; + } + + public Source() { } public String getId() { - return id; + checkValidity(); + return nativeGetId(); + } + + public long getNativePtr() { + return nativePtr; + } + + protected native String nativeGetId(); + + protected void checkValidity() { + if (invalidated) { + throw new RuntimeException("Layer has been invalidated. Request a new reference after adding"); + } + } + + public final void invalidate() { + this.invalidated = true; } } |