package com.mapbox.mapboxsdk.style.sources; import android.support.annotation.Keep; import android.support.annotation.NonNull; import com.mapbox.mapboxsdk.LibraryLoader; 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 { @Keep private long nativePtr; protected boolean detached; static { LibraryLoader.load(); } /** * Internal use * * @param nativePtr - pointer to native peer */ @Keep protected 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"); } /** * Retrieve the source id * * @return the source id */ @NonNull public String getId() { checkThread(); return nativeGetId(); } /** * Retrieve the source attribution. *

* Will return an empty String if no attribution is available. *

* * @return the string representation of the attribution in html format */ @NonNull public String getAttribution() { checkThread(); return nativeGetAttribution(); } /** * Internal use * * @return the native peer pointer */ public long getNativePtr() { return nativePtr; } @NonNull @Keep protected native String nativeGetId(); @NonNull @Keep protected native String nativeGetAttribution(); public void setDetached() { detached = true; } }