@Test public void connect_shouldAddConnectionCallbacks() throws Exception { new LostApiClientImpl(application, new LostApiClient.ConnectionCallbacks() { @Override public void onConnected() { new LostApiClientImpl(application, new TestConnectionCallbacks(), new LostClientManager(clock, handlerFactory)).connect(); } @Override public void onConnectionSuspended() { } }, new LostClientManager(clock, handlerFactory)).connect(); FusedLocationProviderApiImpl api = (FusedLocationProviderApiImpl) LocationServices.FusedLocationApi; assertThat(api.getServiceConnectionManager().getConnectionCallbacks()).hasSize(2); }
@Override public void connect() { clientManager.addClient(this); GeofencingApiImpl geofencingApi = getGeofencingImpl(); if (!geofencingApi.isConnected()) { geofencingApi.connect(context); } SettingsApiImpl settingsApi = getSettingsApiImpl(); if (!settingsApi.isConnected()) { settingsApi.connect(context); } FusedLocationProviderApiImpl fusedApi = getFusedLocationProviderApiImpl(); if (fusedApi.isConnected()) { if (connectionCallbacks != null) { connectionCallbacks.onConnected(); fusedApi.addConnectionCallbacks(connectionCallbacks); } } else if (fusedApi.isConnecting()) { if (connectionCallbacks != null) { fusedApi.addConnectionCallbacks(connectionCallbacks); } } else { fusedApi.connect(context, connectionCallbacks); } }
LostApiClientImpl implements LostApiClient { @Override public void connect() { clientManager.addClient(this); GeofencingApiImpl geofencingApi = getGeofencingImpl(); if (!geofencingApi.isConnected()) { geofencingApi.connect(context); } SettingsApiImpl settingsApi = getSettingsApiImpl(); if (!settingsApi.isConnected()) { settingsApi.connect(context); } FusedLocationProviderApiImpl fusedApi = getFusedLocationProviderApiImpl(); if (fusedApi.isConnected()) { if (connectionCallbacks != null) { connectionCallbacks.onConnected(); fusedApi.addConnectionCallbacks(connectionCallbacks); } } else if (fusedApi.isConnecting()) { if (connectionCallbacks != null) { fusedApi.addConnectionCallbacks(connectionCallbacks); } } else { fusedApi.connect(context, connectionCallbacks); } } }
LostApiClientImpl implements LostApiClient { @Override public void connect() { clientManager.addClient(this); GeofencingApiImpl geofencingApi = getGeofencingImpl(); if (!geofencingApi.isConnected()) { geofencingApi.connect(context); } SettingsApiImpl settingsApi = getSettingsApiImpl(); if (!settingsApi.isConnected()) { settingsApi.connect(context); } FusedLocationProviderApiImpl fusedApi = getFusedLocationProviderApiImpl(); if (fusedApi.isConnected()) { if (connectionCallbacks != null) { connectionCallbacks.onConnected(); fusedApi.addConnectionCallbacks(connectionCallbacks); } } else if (fusedApi.isConnecting()) { if (connectionCallbacks != null) { fusedApi.addConnectionCallbacks(connectionCallbacks); } } else { fusedApi.connect(context, connectionCallbacks); } } LostApiClientImpl(Context context, ConnectionCallbacks callbacks,
      ClientManager clientManager); }
LostApiClientImpl implements LostApiClient { @Override public void connect() { clientManager.addClient(this); GeofencingApiImpl geofencingApi = getGeofencingImpl(); if (!geofencingApi.isConnected()) { geofencingApi.connect(context); } SettingsApiImpl settingsApi = getSettingsApiImpl(); if (!settingsApi.isConnected()) { settingsApi.connect(context); } FusedLocationProviderApiImpl fusedApi = getFusedLocationProviderApiImpl(); if (fusedApi.isConnected()) { if (connectionCallbacks != null) { connectionCallbacks.onConnected(); fusedApi.addConnectionCallbacks(connectionCallbacks); } } else if (fusedApi.isConnecting()) { if (connectionCallbacks != null) { fusedApi.addConnectionCallbacks(connectionCallbacks); } } else { fusedApi.connect(context, connectionCallbacks); } } LostApiClientImpl(Context context, ConnectionCallbacks callbacks,
      ClientManager clientManager); @Override void connect(); @Override void disconnect(); @Override boolean isConnected(); @Override void registerConnectionCallbacks(ConnectionCallbacks callbacks); @Override void unregisterConnectionCallbacks(ConnectionCallbacks callbacks); }
LostApiClientImpl implements LostApiClient { @Override public void connect() { clientManager.addClient(this); GeofencingApiImpl geofencingApi = getGeofencingImpl(); if (!geofencingApi.isConnected()) { geofencingApi.connect(context); } SettingsApiImpl settingsApi = getSettingsApiImpl(); if (!settingsApi.isConnected()) { settingsApi.connect(context); } FusedLocationProviderApiImpl fusedApi = getFusedLocationProviderApiImpl(); if (fusedApi.isConnected()) { if (connectionCallbacks != null) { connectionCallbacks.onConnected(); fusedApi.addConnectionCallbacks(connectionCallbacks); } } else if (fusedApi.isConnecting()) { if (connectionCallbacks != null) { fusedApi.addConnectionCallbacks(connectionCallbacks); } } else { fusedApi.connect(context, connectionCallbacks); } } LostApiClientImpl(Context context, ConnectionCallbacks callbacks,
      ClientManager clientManager); @Override void connect(); @Override void disconnect(); @Override boolean isConnected(); @Override void registerConnectionCallbacks(ConnectionCallbacks callbacks); @Override void unregisterConnectionCallbacks(ConnectionCallbacks callbacks);  }