@SuppressWarnings("unchecked") void update(Location loc, AirspaceLookupIf lookup) { if (loc == null || lookup == null) return; final float gs = (float) (loc.getSpeed() * 3.6 / 1.852); if (gs < 4) { ++count_standstill; if (last_update == 0) last_update = SystemClock.elapsedRealtime(); if (count_standstill > 20 && SystemClock.elapsedRealtime() - last_update > 1000l * 60 * 10) { last_update = SystemClock.elapsedRealtime(); count_standstill = 0; boolean needswork = false; for (AirspaceArea area : lookup.getAllAirspace()) { if (area.cleared != 0) { area.cleared = 0; needswork = true; } } if (needswork) save(lookup); } } else { last_update = SystemClock.elapsedRealtime(); count_standstill = 0; } }
public void save(AirspaceLookupIf lookup) { loader = new BackgroundSaver(); loader.execute(lookup.getAllAirspace()); }