/** This method is from GPSListener, used to notify the ProximityListener. */ public void sentenceReceived(NMEASentence sen) { // Check if this sentence has location info if (sen.getHeader().equals(GGASentence.HEADER)) { Coordinates cur = null; Location loc = null; try { loc = this.getLocation(-1); cur = loc.getQualifiedCoordinates(); } catch (InterruptedException e) { // TODO: This method should bail properly if it fails. System.err.println("Fail 1"); } catch (LocationException e) { // TODO: This method should bail properly if it fails. System.err.println("Fail 2"); } for (int i = 0; i < listeners.size(); i++) { Object[] array = listeners.get(i); ProximityListener pl = (ProximityListener) array[0]; Coordinates to = (Coordinates) array[1]; Float rad = (Float) array[2]; // Now check radius against coordinate and notify listener. if (cur.distance(to) <= rad.floatValue()) { // Remove this ProximityListener because it should be notified only once. // I prefer to do this BEFORE notifying the pl because the user might try // to re-add the pl in proximityEvent(). LocationProvider.removeProximityListener(pl); pl.proximityEvent(to, loc); } } // TODO: Handle LocationListeners here instead of inner? } }