@Test public void stopShouldDisconnectFromGoogleApiIfConnected_andAlwaysCallOnClientStopIfListenerSet() { LocationClient.LocationClientListener listener = mock(LocationClient.LocationClientListener.class); client.setListener(listener); when(googleApiClient.isConnected()).thenReturn(true); client.stop(); verify(googleApiClient).disconnect(); verify(listener).onClientStop(); reset(listener); doAnswer(new OnDisconnectedAnswer()).when(googleApiClient).disconnect(); client.stop(); verify(listener).onClientStop(); reset(listener); when(googleApiClient.isConnected()).thenReturn(false); client.stop(); verify(listener).onClientStop(); }
public void stop() { stopLocationUpdates(); googleApiClient.unregisterConnectionCallbacks(this); googleApiClient.unregisterConnectionFailedListener(this); if (googleApiClient.isConnected()) { googleApiClient.disconnect(); } if (getListener() != null) { getListener().onClientStop(); } }
GoogleFusedLocationClient extends BaseLocationClient implements ConnectionCallbacks, OnConnectionFailedListener, LocationListener { public void stop() { stopLocationUpdates(); googleApiClient.unregisterConnectionCallbacks(this); googleApiClient.unregisterConnectionFailedListener(this); if (googleApiClient.isConnected()) { googleApiClient.disconnect(); } if (getListener() != null) { getListener().onClientStop(); } } }
GoogleFusedLocationClient extends BaseLocationClient implements ConnectionCallbacks, OnConnectionFailedListener, LocationListener { public void stop() { stopLocationUpdates(); googleApiClient.unregisterConnectionCallbacks(this); googleApiClient.unregisterConnectionFailedListener(this); if (googleApiClient.isConnected()) { googleApiClient.disconnect(); } if (getListener() != null) { getListener().onClientStop(); } } GoogleFusedLocationClient(@NonNull Application application);   GoogleFusedLocationClient(@NonNull GoogleApiClient googleApiClient,
                              @NonNull FusedLocationProviderApi fusedLocationProviderApi,
                              @NonNull LocationManager locationManager); }
GoogleFusedLocationClient extends BaseLocationClient implements ConnectionCallbacks, OnConnectionFailedListener, LocationListener { public void stop() { stopLocationUpdates(); googleApiClient.unregisterConnectionCallbacks(this); googleApiClient.unregisterConnectionFailedListener(this); if (googleApiClient.isConnected()) { googleApiClient.disconnect(); } if (getListener() != null) { getListener().onClientStop(); } } GoogleFusedLocationClient(@NonNull Application application);   GoogleFusedLocationClient(@NonNull GoogleApiClient googleApiClient,
                              @NonNull FusedLocationProviderApi fusedLocationProviderApi,
                              @NonNull LocationManager locationManager); void start(); void stop(); @SuppressLint("MissingPermission") // Permission checks for location services handled in widgets void requestLocationUpdates(@NonNull LocationListener locationListener); void stopLocationUpdates(); @Override @SuppressLint("MissingPermission") // Permission checks for location services handled in widgets Location getLastLocation(); @Override boolean isMonitoringLocation(); @Override boolean canSetUpdateIntervals(); @Override void setUpdateIntervals(long updateInterval, long fastestUpdateInterval); @Override void resetUpdateIntervals(); @Override void onConnected(@Nullable Bundle bundle); @Override void onConnectionSuspended(int cause); @Override void onConnectionFailed(@NonNull ConnectionResult connectionResult); @Override void onLocationChanged(Location location); }
GoogleFusedLocationClient extends BaseLocationClient implements ConnectionCallbacks, OnConnectionFailedListener, LocationListener { public void stop() { stopLocationUpdates(); googleApiClient.unregisterConnectionCallbacks(this); googleApiClient.unregisterConnectionFailedListener(this); if (googleApiClient.isConnected()) { googleApiClient.disconnect(); } if (getListener() != null) { getListener().onClientStop(); } } GoogleFusedLocationClient(@NonNull Application application);   GoogleFusedLocationClient(@NonNull GoogleApiClient googleApiClient,
                              @NonNull FusedLocationProviderApi fusedLocationProviderApi,
                              @NonNull LocationManager locationManager); void start(); void stop(); @SuppressLint("MissingPermission") // Permission checks for location services handled in widgets void requestLocationUpdates(@NonNull LocationListener locationListener); void stopLocationUpdates(); @Override @SuppressLint("MissingPermission") // Permission checks for location services handled in widgets Location getLastLocation(); @Override boolean isMonitoringLocation(); @Override boolean canSetUpdateIntervals(); @Override void setUpdateIntervals(long updateInterval, long fastestUpdateInterval); @Override void resetUpdateIntervals(); @Override void onConnected(@Nullable Bundle bundle); @Override void onConnectionSuspended(int cause); @Override void onConnectionFailed(@NonNull ConnectionResult connectionResult); @Override void onLocationChanged(Location location);  }