summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/net/ConnectivityReceiver.java
diff options
context:
space:
mode:
authorCameron Mace <cameron@mapbox.com>2016-12-16 16:19:15 -0500
committerGitHub <noreply@github.com>2016-12-16 16:19:15 -0500
commit20b958301eb208fe9ed0ae8edfb14b6f3741d8f2 (patch)
tree94ae0ce250cda159be13f9a21cc70c92d4908974 /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/net/ConnectivityReceiver.java
parentf95b4838ea816b9da0c151a953a1f98f97c79a39 (diff)
downloadqtlocation-mapboxgl-20b958301eb208fe9ed0ae8edfb14b6f3741d8f2.tar.gz
Adds checkstyle to CI (#7442)
* adds checkstyle to CI * fixed gradlew path * resolved testapp checkstyle violations * added back mapboxMap variable for test * checkstyle annotations * checkstyle SDK round 1 * maps package checkstyle * rest of SDK checkstyle * checkstyle gesture library * checkstyle test * finished rest of test checkstyle * resolved all checkstyle errors * fixed class name * removed old test file * fixed camera postion test * fixed native crash
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/net/ConnectivityReceiver.java')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/net/ConnectivityReceiver.java129
1 files changed, 65 insertions, 64 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/net/ConnectivityReceiver.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/net/ConnectivityReceiver.java
index 7278cdd673..63d9254306 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/net/ConnectivityReceiver.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/net/ConnectivityReceiver.java
@@ -7,6 +7,7 @@ import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.support.annotation.NonNull;
+
import timber.log.Timber;
import com.mapbox.mapboxsdk.MapboxAccountManager;
@@ -19,77 +20,77 @@ import java.util.concurrent.CopyOnWriteArrayList;
* Not public api.
*/
public class ConnectivityReceiver extends BroadcastReceiver {
- private static ConnectivityReceiver INSTANCE;
-
- /**
- * Get or create the singleton instance
- */
- public static synchronized ConnectivityReceiver instance(Context context) {
- if (INSTANCE == null) {
- //Register new instance
- INSTANCE = new ConnectivityReceiver();
- context.registerReceiver(INSTANCE, new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"));
-
- //Add default listeners
- INSTANCE.addListener(new NativeConnectivityListener());
- }
-
- return INSTANCE;
+ private static ConnectivityReceiver INSTANCE;
+
+ /**
+ * Get or create the singleton instance
+ */
+ public static synchronized ConnectivityReceiver instance(Context context) {
+ if (INSTANCE == null) {
+ //Register new instance
+ INSTANCE = new ConnectivityReceiver();
+ context.registerReceiver(INSTANCE, new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"));
+
+ //Add default listeners
+ INSTANCE.addListener(new NativeConnectivityListener());
}
- private List<ConnectivityListener> listeners = new CopyOnWriteArrayList<>();
+ return INSTANCE;
+ }
- private ConnectivityReceiver() {
- }
+ private List<ConnectivityListener> listeners = new CopyOnWriteArrayList<>();
- /**
- * @see BroadcastReceiver#onReceive(Context, Intent)
- */
- @Override
- public void onReceive(Context context, Intent intent) {
- boolean connected = isConnected(context);
- Timber.v("Connected: " + connected);
-
- //Loop over listeners
- for (ConnectivityListener listener : listeners) {
- listener.onNetworkStateChanged(connected);
- }
- }
+ private ConnectivityReceiver() {
+ }
- /**
- * Add a listener to be notified
- *
- * @param listener the listener to add
- */
- public void addListener(@NonNull ConnectivityListener listener) {
- listeners.add(listener);
- }
+ /**
+ * @see BroadcastReceiver#onReceive(Context, Intent)
+ */
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ boolean connected = isConnected(context);
+ Timber.v("Connected: " + connected);
- /**
- * Remove a listener
- *
- * @param listener the listener to remove
- */
- public void removeListener(@NonNull ConnectivityListener listener) {
- listeners.remove(listener);
+ //Loop over listeners
+ for (ConnectivityListener listener : listeners) {
+ listener.onNetworkStateChanged(connected);
}
-
- /**
- * Get current connectivity state
- *
- * @param context current Context
- * @return true if connected
- */
- public boolean isConnected(Context context) {
- Boolean connected = MapboxAccountManager.getInstance().isConnected();
- if (connected != null) {
- // Connectivity state overridden by app
- return connected;
- }
-
- ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
- return (activeNetwork != null && activeNetwork.isConnected());
+ }
+
+ /**
+ * Add a listener to be notified
+ *
+ * @param listener the listener to add
+ */
+ public void addListener(@NonNull ConnectivityListener listener) {
+ listeners.add(listener);
+ }
+
+ /**
+ * Remove a listener
+ *
+ * @param listener the listener to remove
+ */
+ public void removeListener(@NonNull ConnectivityListener listener) {
+ listeners.remove(listener);
+ }
+
+ /**
+ * Get current connectivity state
+ *
+ * @param context current Context
+ * @return true if connected
+ */
+ public boolean isConnected(Context context) {
+ Boolean connected = MapboxAccountManager.getInstance().isConnected();
+ if (connected != null) {
+ // Connectivity state overridden by app
+ return connected;
}
+ ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
+ return (activeNetwork != null && activeNetwork.isConnected());
+ }
+
}