@Test public void onlyMoreAccurateFixes_ShouldResultInUpdates() { maxAccuracyLocationClient.requestLocationUpdates(5); Location location = createLocation("GPS", 1, 1, 1, 100); fakeLocationClient.receiveFix(location); assertEquals(location, testLocationListener.getLastLocation()); Location moreAccurateLocation = createLocation("GPS", 1, 1, 1, 2); fakeLocationClient.receiveFix(moreAccurateLocation); assertEquals(moreAccurateLocation, testLocationListener.getLastLocation()); Location lessAccurateLocation = createLocation("GPS", 1, 1, 1, 10); fakeLocationClient.receiveFix(lessAccurateLocation); assertEquals(moreAccurateLocation, testLocationListener.getLastLocation()); }
public void requestLocationUpdates(long timeoutSeconds) { new Handler(Looper.getMainLooper()).post(() -> { locationClient.setListener(this); locationClient.start(); }); highestAccuracyReading = null; timerHandler.removeCallbacksAndMessages(null); timerHandler.postDelayed(() -> { locationClient.stop(); locationClient.setListener(null); Timber.i("MaxAccuracyWithinTimeoutLocationClient: stopping location updates"); }, timeoutSeconds * 1000); }
MaxAccuracyWithinTimeoutLocationClient implements LocationClient.LocationClientListener, LocationListener { public void requestLocationUpdates(long timeoutSeconds) { new Handler(Looper.getMainLooper()).post(() -> { locationClient.setListener(this); locationClient.start(); }); highestAccuracyReading = null; timerHandler.removeCallbacksAndMessages(null); timerHandler.postDelayed(() -> { locationClient.stop(); locationClient.setListener(null); Timber.i("MaxAccuracyWithinTimeoutLocationClient: stopping location updates"); }, timeoutSeconds * 1000); } }
MaxAccuracyWithinTimeoutLocationClient implements LocationClient.LocationClientListener, LocationListener { public void requestLocationUpdates(long timeoutSeconds) { new Handler(Looper.getMainLooper()).post(() -> { locationClient.setListener(this); locationClient.start(); }); highestAccuracyReading = null; timerHandler.removeCallbacksAndMessages(null); timerHandler.postDelayed(() -> { locationClient.stop(); locationClient.setListener(null); Timber.i("MaxAccuracyWithinTimeoutLocationClient: stopping location updates"); }, timeoutSeconds * 1000); } MaxAccuracyWithinTimeoutLocationClient(LocationClient locationClient, LocationListener listener); }
MaxAccuracyWithinTimeoutLocationClient implements LocationClient.LocationClientListener, LocationListener { public void requestLocationUpdates(long timeoutSeconds) { new Handler(Looper.getMainLooper()).post(() -> { locationClient.setListener(this); locationClient.start(); }); highestAccuracyReading = null; timerHandler.removeCallbacksAndMessages(null); timerHandler.postDelayed(() -> { locationClient.stop(); locationClient.setListener(null); Timber.i("MaxAccuracyWithinTimeoutLocationClient: stopping location updates"); }, timeoutSeconds * 1000); } MaxAccuracyWithinTimeoutLocationClient(LocationClient locationClient, LocationListener listener); void requestLocationUpdates(long timeoutSeconds); @Override void onClientStart(); @Override void onClientStartFailure(); @Override void onClientStop(); @Override void onLocationChanged(Location location); }
MaxAccuracyWithinTimeoutLocationClient implements LocationClient.LocationClientListener, LocationListener { public void requestLocationUpdates(long timeoutSeconds) { new Handler(Looper.getMainLooper()).post(() -> { locationClient.setListener(this); locationClient.start(); }); highestAccuracyReading = null; timerHandler.removeCallbacksAndMessages(null); timerHandler.postDelayed(() -> { locationClient.stop(); locationClient.setListener(null); Timber.i("MaxAccuracyWithinTimeoutLocationClient: stopping location updates"); }, timeoutSeconds * 1000); } MaxAccuracyWithinTimeoutLocationClient(LocationClient locationClient, LocationListener listener); void requestLocationUpdates(long timeoutSeconds); @Override void onClientStart(); @Override void onClientStartFailure(); @Override void onClientStop(); @Override void onLocationChanged(Location location);  }