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 | 15 |
1 files changed, 14 insertions, 1 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 22b2244537..6a0939569a 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 @@ -1,9 +1,12 @@ package com.mapbox.mapboxsdk.style.sources; +import com.mapbox.mapboxsdk.utils.ThreadUtils; + /** * Base Peer class for sources. see source.hpp for the other half of the peer. */ public abstract class Source { + private long nativePtr; /** @@ -12,10 +15,19 @@ public abstract class Source { * @param nativePtr - pointer to native peer */ public Source(long nativePtr) { + checkThread(); this.nativePtr = nativePtr; } public Source() { + checkThread(); + } + + /** + * Validates if source interaction is happening on the UI thread + */ + protected void checkThread() { + ThreadUtils.checkThread("Source"); } /** @@ -24,6 +36,7 @@ public abstract class Source { * @return the source id */ public String getId() { + checkThread(); return nativeGetId(); } @@ -36,6 +49,7 @@ public abstract class Source { * @return the string representation of the attribution in html format */ public String getAttribution() { + checkThread(); return nativeGetAttribution(); } @@ -51,5 +65,4 @@ public abstract class Source { protected native String nativeGetId(); protected native String nativeGetAttribution(); - } |