From d4e4294a7434bf1fa15064c3305cca4cefaaace4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Charmas?= Date: Fri, 29 Sep 2017 16:57:41 +0200 Subject: [PATCH] Fixed weak reference access inside location listener --- .../observables/location/LocationUpdatesObservable.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/android-reactive-location/src/main/java/pl/charmas/android/reactivelocation/observables/location/LocationUpdatesObservable.java b/android-reactive-location/src/main/java/pl/charmas/android/reactivelocation/observables/location/LocationUpdatesObservable.java index 77b69503..062faee6 100644 --- a/android-reactive-location/src/main/java/pl/charmas/android/reactivelocation/observables/location/LocationUpdatesObservable.java +++ b/android-reactive-location/src/main/java/pl/charmas/android/reactivelocation/observables/location/LocationUpdatesObservable.java @@ -55,10 +55,10 @@ private static class LocationUpdatesLocationListener implements LocationListener @Override public void onLocationChanged(Location location) { - if (weakRef.get() == null) { - return; + final Observer observer = weakRef.get(); + if (observer != null) { + observer.onNext(location); } - weakRef.get().onNext(location); } } }