@Test public void stopLocationUpdatesShouldCallLocationManagerRemoveUpdates() { LocationListener locationListener = Mockito.mock(LocationListener.class); LocationManager locationManager = Mockito.spy((LocationManager) ReflectionHelpers.getField(androidGpsLocationClient, "locationManager")); ReflectionHelpers.setField(androidGpsLocationClient, "locationManager", locationManager); androidGpsLocationClient.addLocationListener(locationListener); Assert.assertEquals(1, androidGpsLocationClient.getLocationListeners().size()); androidGpsLocationClient.stopLocationUpdates(); Mockito.verify(locationManager, Mockito.times(2)).removeUpdates(Mockito.any(LocationListener.class)); }
@Override public void stopLocationUpdates() { if (isMonitoringLocation()) { lastLocation = null; locationManager.removeUpdates(androidGpsLocationListener); for (LocationListener locationListener : getLocationListeners()) { locationManager.removeUpdates(locationListener); } clearLocationListeners(); } unregisterForGpsStoppedEvent(); }
AndroidGpsLocationClient extends BaseLocationClient { @Override public void stopLocationUpdates() { if (isMonitoringLocation()) { lastLocation = null; locationManager.removeUpdates(androidGpsLocationListener); for (LocationListener locationListener : getLocationListeners()) { locationManager.removeUpdates(locationListener); } clearLocationListeners(); } unregisterForGpsStoppedEvent(); } }
AndroidGpsLocationClient extends BaseLocationClient { @Override public void stopLocationUpdates() { if (isMonitoringLocation()) { lastLocation = null; locationManager.removeUpdates(androidGpsLocationListener); for (LocationListener locationListener : getLocationListeners()) { locationManager.removeUpdates(locationListener); } clearLocationListeners(); } unregisterForGpsStoppedEvent(); } AndroidGpsLocationClient(@NonNull Context context); }
AndroidGpsLocationClient extends BaseLocationClient { @Override public void stopLocationUpdates() { if (isMonitoringLocation()) { lastLocation = null; locationManager.removeUpdates(androidGpsLocationListener); for (LocationListener locationListener : getLocationListeners()) { locationManager.removeUpdates(locationListener); } clearLocationListeners(); } unregisterForGpsStoppedEvent(); } AndroidGpsLocationClient(@NonNull Context context); @Override void stopLocationUpdates(); @SuppressLint("MissingPermission") @Nullable @Override Location getLastLocation(); @Override void requestLocationUpdates(@NonNull LocationListener locationListener); @Override void setUpdateIntervals(long updateInterval, long fastestUpdateInterval); @NonNull @Override String getProvider(); @Override void close(); }
AndroidGpsLocationClient extends BaseLocationClient { @Override public void stopLocationUpdates() { if (isMonitoringLocation()) { lastLocation = null; locationManager.removeUpdates(androidGpsLocationListener); for (LocationListener locationListener : getLocationListeners()) { locationManager.removeUpdates(locationListener); } clearLocationListeners(); } unregisterForGpsStoppedEvent(); } AndroidGpsLocationClient(@NonNull Context context); @Override void stopLocationUpdates(); @SuppressLint("MissingPermission") @Nullable @Override Location getLastLocation(); @Override void requestLocationUpdates(@NonNull LocationListener locationListener); @Override void setUpdateIntervals(long updateInterval, long fastestUpdateInterval); @NonNull @Override String getProvider(); @Override void close();  }