summaryrefslogtreecommitdiff
path: root/platform/android
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2017-01-11 22:37:37 +0100
committerGitHub <noreply@github.com>2017-01-11 22:37:37 +0100
commit5fff4ed6cbe4a61673a0332e2f89a354dac606e3 (patch)
tree4920e26b877c37dc6614ace057913b1456db4278 /platform/android
parentb65b1e2c48f1c998a6b4a7fbeae36c8ef3fb7068 (diff)
downloadqtlocation-mapboxgl-5fff4ed6cbe4a61673a0332e2f89a354dac606e3.tar.gz
[android] - synchronised mutators for thread safety in Mapbox, added documentation to Mapbox#getInstance (#7677)
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java
index 90f52604df..9d20e968c8 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java
@@ -18,6 +18,16 @@ public final class Mapbox {
private String accessToken;
private Boolean connected;
+ /**
+ * Get an instance of Mapbox.
+ * <p>
+ * This class manages the active access token, application context and connectivity state.
+ * </p>
+ *
+ * @param context Android context which holds or is an application context
+ * @param accessToken Mapbox access token
+ * @return the single instance of Mapbox
+ */
public static synchronized Mapbox getInstance(@NonNull Context context, @NonNull String accessToken) {
if (INSTANCE == null) {
Context appContext = context.getApplicationContext();
@@ -70,7 +80,7 @@ public final class Mapbox {
* @param connected flag to determine the connectivity state, true for connected, false for
* disconnected, null for ConnectivityManager to determine.
*/
- public static void setConnected(Boolean connected) {
+ public static synchronized void setConnected(Boolean connected) {
// Connectivity state overridden by app
INSTANCE.connected = connected;
}
@@ -81,7 +91,7 @@ public final class Mapbox {
*
* @return true if there is an Internet connection, false otherwise
*/
- public static Boolean isConnected() {
+ public static synchronized Boolean isConnected() {
if (INSTANCE.connected != null) {
// Connectivity state overridden by app
return INSTANCE.connected;