diff --git a/build.gradle b/build.gradle index 11b596d2..b8f894f3 100644 --- a/build.gradle +++ b/build.gradle @@ -12,9 +12,21 @@ buildscript { mavenCentral() maven { url "https://maven.google.com" } jcenter() + google() } dependencies { - classpath 'com.android.tools.build:gradle:3.0.0-rc2' + classpath 'com.android.tools.build:gradle:3.1.3' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' + } + +} + +allprojects { + repositories { + mavenCentral() + maven { url "https://maven.google.com" } + jcenter() + google() } } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0fec9a5e..7034c45e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sat Oct 14 10:52:55 BST 2017 +#Fri Jun 22 08:51:40 CEST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip diff --git a/library/build.gradle b/library/build.gradle index 1c91c5ae..8d1ba069 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -8,7 +8,7 @@ apply plugin: 'com.android.library' apply plugin: 'maven-publish' apply plugin: 'maven' apply plugin: 'signing' - +apply plugin: 'com.github.dcendents.android-maven' version smartLocationVersion group 'io.nlopez.smartlocation' diff --git a/library/src/main/java/io/nlopez/smartlocation/SmartLocation.java b/library/src/main/java/io/nlopez/smartlocation/SmartLocation.java index fd40c7d4..18d6171c 100644 --- a/library/src/main/java/io/nlopez/smartlocation/SmartLocation.java +++ b/library/src/main/java/io/nlopez/smartlocation/SmartLocation.java @@ -154,7 +154,7 @@ public static class LocationControl { private static final Map MAPPING = new WeakHashMap<>(); - private final SmartLocation smartLocation; + private SmartLocation smartLocation; private LocationParams params; private LocationProvider provider; private boolean oneFix; @@ -212,6 +212,13 @@ public void start(OnLocationUpdatedListener listener) { public void stop() { provider.stop(); } + + public void destroy() { + provider.destroy(); + provider = null; + params = null; + smartLocation = null; + } } public static class GeocodingControl { diff --git a/library/src/main/java/io/nlopez/smartlocation/location/LocationProvider.java b/library/src/main/java/io/nlopez/smartlocation/location/LocationProvider.java index c97d60dc..04494371 100644 --- a/library/src/main/java/io/nlopez/smartlocation/location/LocationProvider.java +++ b/library/src/main/java/io/nlopez/smartlocation/location/LocationProvider.java @@ -19,4 +19,5 @@ public interface LocationProvider { Location getLastLocation(); + void destroy(); } diff --git a/library/src/main/java/io/nlopez/smartlocation/location/providers/LocationBasedOnActivityProvider.java b/library/src/main/java/io/nlopez/smartlocation/location/providers/LocationBasedOnActivityProvider.java index 10124035..a5b82fee 100644 --- a/library/src/main/java/io/nlopez/smartlocation/location/providers/LocationBasedOnActivityProvider.java +++ b/library/src/main/java/io/nlopez/smartlocation/location/providers/LocationBasedOnActivityProvider.java @@ -69,4 +69,9 @@ public void onActivityUpdated(DetectedActivity detectedActivity) { public interface LocationBasedOnActivityListener { public LocationParams locationParamsForActivity(DetectedActivity detectedActivity); } + + @Override + public void destroy() { + locationProvider.destroy(); + } } diff --git a/library/src/main/java/io/nlopez/smartlocation/location/providers/LocationGooglePlayServicesProvider.java b/library/src/main/java/io/nlopez/smartlocation/location/providers/LocationGooglePlayServicesProvider.java index 203d19cf..35fcc43c 100644 --- a/library/src/main/java/io/nlopez/smartlocation/location/providers/LocationGooglePlayServicesProvider.java +++ b/library/src/main/java/io/nlopez/smartlocation/location/providers/LocationGooglePlayServicesProvider.java @@ -204,6 +204,14 @@ public Location getLastLocation() { return null; } + @Override + public void destroy() { + context = null; + listener = null; + googlePlayServicesListener = null; + serviceListener = null; + } + @Override public ServiceConnectionListener getServiceListener() { return serviceListener; diff --git a/library/src/main/java/io/nlopez/smartlocation/location/providers/LocationGooglePlayServicesWithFallbackProvider.java b/library/src/main/java/io/nlopez/smartlocation/location/providers/LocationGooglePlayServicesWithFallbackProvider.java index 111feb65..30a02b3a 100644 --- a/library/src/main/java/io/nlopez/smartlocation/location/providers/LocationGooglePlayServicesWithFallbackProvider.java +++ b/library/src/main/java/io/nlopez/smartlocation/location/providers/LocationGooglePlayServicesWithFallbackProvider.java @@ -60,6 +60,13 @@ public void stop() { shouldStart = false; } + @Override + public void destroy() { + provider.destroy(); + context = null; + listener = null; + } + @Override public Location getLastLocation() { return provider.getLastLocation(); diff --git a/library/src/main/java/io/nlopez/smartlocation/location/providers/LocationManagerProvider.java b/library/src/main/java/io/nlopez/smartlocation/location/providers/LocationManagerProvider.java index 75567a5a..e1cfc547 100644 --- a/library/src/main/java/io/nlopez/smartlocation/location/providers/LocationManagerProvider.java +++ b/library/src/main/java/io/nlopez/smartlocation/location/providers/LocationManagerProvider.java @@ -173,4 +173,9 @@ public void onProviderEnabled(String provider) { public void onProviderDisabled(String provider) { } + + @Override + public void destroy() { + mContext = null; + } } diff --git a/library/src/main/java/io/nlopez/smartlocation/location/providers/MultiFallbackProvider.java b/library/src/main/java/io/nlopez/smartlocation/location/providers/MultiFallbackProvider.java index 8dc88ccf..7ded28fb 100644 --- a/library/src/main/java/io/nlopez/smartlocation/location/providers/MultiFallbackProvider.java +++ b/library/src/main/java/io/nlopez/smartlocation/location/providers/MultiFallbackProvider.java @@ -125,6 +125,14 @@ void fallbackProvider() { } } + @Override + public void destroy() { + context = null; + if (currentProvider != null) { + currentProvider.destroy(); + } + } + /** * Builder class for the {@link MultiFallbackProvider}. */ diff --git a/library/src/test/java/io/nlopez/smartlocation/location/providers/TestServiceProvider.java b/library/src/test/java/io/nlopez/smartlocation/location/providers/TestServiceProvider.java index 38aa4743..ecddcb8d 100644 --- a/library/src/test/java/io/nlopez/smartlocation/location/providers/TestServiceProvider.java +++ b/library/src/test/java/io/nlopez/smartlocation/location/providers/TestServiceProvider.java @@ -79,4 +79,9 @@ public void simulateFailure() { listener.onConnectionFailed(); } } + + @Override + public void destroy() { + + } } diff --git a/library/src/test/java/io/nlopez/smartlocation/util/MockLocationProvider.java b/library/src/test/java/io/nlopez/smartlocation/util/MockLocationProvider.java index fe3c554e..5def0e54 100644 --- a/library/src/test/java/io/nlopez/smartlocation/util/MockLocationProvider.java +++ b/library/src/test/java/io/nlopez/smartlocation/util/MockLocationProvider.java @@ -39,4 +39,9 @@ public Location getLastLocation() { public void fakeEmitLocation(Location location) { listener.onLocationUpdated(location); } + + @Override + public void destroy() { + + } } diff --git a/rxjava/src/test/java/io/nlopez/smartlocation/rx/ObservableFactoryTest.java b/rxjava/src/test/java/io/nlopez/smartlocation/rx/ObservableFactoryTest.java index 1e1f0fb8..c7e9cb22 100644 --- a/rxjava/src/test/java/io/nlopez/smartlocation/rx/ObservableFactoryTest.java +++ b/rxjava/src/test/java/io/nlopez/smartlocation/rx/ObservableFactoryTest.java @@ -120,5 +120,10 @@ public Location getLastLocation() { public void fakeEmit(Location location) { mListener.onLocationUpdated(location); } + + @Override + public void destroy() { + + } } }