@Test public void isBetterThan_shouldReturnFalseIfLocationAIsNull() throws Exception { Location locationA = null; Location locationB = new Location("test"); assertThat(FusionEngine.isBetterThan(locationA, locationB)).isFalse(); }
public static boolean isBetterThan(Location locationA, Location locationB) { if (locationA == null) { return false; } if (locationB == null) { return true; } if (clock.getElapsedTimeInNanos(locationA) > clock.getElapsedTimeInNanos(locationB) + RECENT_UPDATE_THRESHOLD_IN_NANOS) { return true; } if (!locationA.hasAccuracy()) { return false; } if (!locationB.hasAccuracy()) { return true; } return locationA.getAccuracy() < locationB.getAccuracy(); }
FusionEngine extends LocationEngine implements LocationListener { public static boolean isBetterThan(Location locationA, Location locationB) { if (locationA == null) { return false; } if (locationB == null) { return true; } if (clock.getElapsedTimeInNanos(locationA) > clock.getElapsedTimeInNanos(locationB) + RECENT_UPDATE_THRESHOLD_IN_NANOS) { return true; } if (!locationA.hasAccuracy()) { return false; } if (!locationB.hasAccuracy()) { return true; } return locationA.getAccuracy() < locationB.getAccuracy(); } }
FusionEngine extends LocationEngine implements LocationListener { public static boolean isBetterThan(Location locationA, Location locationB) { if (locationA == null) { return false; } if (locationB == null) { return true; } if (clock.getElapsedTimeInNanos(locationA) > clock.getElapsedTimeInNanos(locationB) + RECENT_UPDATE_THRESHOLD_IN_NANOS) { return true; } if (!locationA.hasAccuracy()) { return false; } if (!locationB.hasAccuracy()) { return true; } return locationA.getAccuracy() < locationB.getAccuracy(); } FusionEngine(Context context, Callback callback); }
FusionEngine extends LocationEngine implements LocationListener { public static boolean isBetterThan(Location locationA, Location locationB) { if (locationA == null) { return false; } if (locationB == null) { return true; } if (clock.getElapsedTimeInNanos(locationA) > clock.getElapsedTimeInNanos(locationB) + RECENT_UPDATE_THRESHOLD_IN_NANOS) { return true; } if (!locationA.hasAccuracy()) { return false; } if (!locationB.hasAccuracy()) { return true; } return locationA.getAccuracy() < locationB.getAccuracy(); } FusionEngine(Context context, Callback callback); @Override Location getLastLocation(); @Override boolean isProviderEnabled(String provider); @Override void onLocationChanged(Location location); @Override void onStatusChanged(String provider, int status, Bundle extras); @Override void onProviderEnabled(String provider); @Override void onProviderDisabled(String provider); static boolean isBetterThan(Location locationA, Location locationB); }
FusionEngine extends LocationEngine implements LocationListener { public static boolean isBetterThan(Location locationA, Location locationB) { if (locationA == null) { return false; } if (locationB == null) { return true; } if (clock.getElapsedTimeInNanos(locationA) > clock.getElapsedTimeInNanos(locationB) + RECENT_UPDATE_THRESHOLD_IN_NANOS) { return true; } if (!locationA.hasAccuracy()) { return false; } if (!locationB.hasAccuracy()) { return true; } return locationA.getAccuracy() < locationB.getAccuracy(); } FusionEngine(Context context, Callback callback); @Override Location getLastLocation(); @Override boolean isProviderEnabled(String provider); @Override void onLocationChanged(Location location); @Override void onStatusChanged(String provider, int status, Bundle extras); @Override void onProviderEnabled(String provider); @Override void onProviderDisabled(String provider); static boolean isBetterThan(Location locationA, Location locationB); static final long RECENT_UPDATE_THRESHOLD_IN_MILLIS; static final long RECENT_UPDATE_THRESHOLD_IN_NANOS; }