@Test public void connect_multipleClients_shouldBeConnectedWhenConnectionCallbackInvoked() throws Exception { client.connect(); TestConnectionCallbacks callbacks = new TestConnectionCallbacks(); LostApiClient anotherClient = new LostApiClientImpl(application, callbacks, new LostClientManager(clock, handlerFactory)); callbacks.setLostClient(anotherClient); anotherClient.connect(); assertThat(callbacks.isClientConnectedOnConnect()).isTrue(); }
@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);  }