summaryrefslogtreecommitdiff
path: root/altosui/AltosScanUI.java
diff options
context:
space:
mode:
authorRobert Garbee <robert@gag.com>2012-07-18 14:25:27 -0600
committerRobert Garbee <robert@gag.com>2012-07-18 14:25:27 -0600
commite2b472bbb2418fc13be42dbc7c52beb88479c46d (patch)
tree80c758082cad6517d86fb4aa31abc6a6049555eb /altosui/AltosScanUI.java
parent75d6aa6f798606f1a6c5a46542065dda81e63b2a (diff)
parentb242f2756a8d9419a9bdba890b9e6b73560bdc19 (diff)
Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
Diffstat (limited to 'altosui/AltosScanUI.java')
-rw-r--r--altosui/AltosScanUI.java42
1 files changed, 32 insertions, 10 deletions
diff --git a/altosui/AltosScanUI.java b/altosui/AltosScanUI.java
index 44eeda6d..ef6389b6 100644
--- a/altosui/AltosScanUI.java
+++ b/altosui/AltosScanUI.java
@@ -59,29 +59,50 @@ class AltosScanResult {
}
public boolean equals(AltosScanResult other) {
- return (callsign.equals(other.callsign) &&
- serial == other.serial &&
- flight == other.flight &&
+ return (serial == other.serial &&
frequency.frequency == other.frequency.frequency &&
telemetry == other.telemetry);
}
+
+ public boolean up_to_date(AltosScanResult other) {
+ if (flight == 0 && other.flight != 0) {
+ flight = other.flight;
+ return false;
+ }
+ if (callsign.equals("N0CALL") && !other.callsign.equals("N0CALL")) {
+ callsign = other.callsign;
+ return false;
+ }
+ return true;
+ }
}
class AltosScanResults extends LinkedList<AltosScanResult> implements ListModel {
LinkedList<ListDataListener> listeners = new LinkedList<ListDataListener>();
+ void changed(ListDataEvent de) {
+ for (ListDataListener l : listeners)
+ l.contentsChanged(de);
+ }
+
public boolean add(AltosScanResult r) {
- for (AltosScanResult old : this)
- if (old.equals(r))
+ int i = 0;
+ for (AltosScanResult old : this) {
+ if (old.equals(r)) {
+ if (!old.up_to_date(r))
+ changed (new ListDataEvent(this,
+ ListDataEvent.CONTENTS_CHANGED,
+ i, i));
return true;
+ }
+ i++;
+ }
super.add(r);
- ListDataEvent de = new ListDataEvent(this,
- ListDataEvent.INTERVAL_ADDED,
- this.size() - 2, this.size() - 1);
- for (ListDataListener l : listeners)
- l.contentsChanged(de);
+ changed(new ListDataEvent(this,
+ ListDataEvent.INTERVAL_ADDED,
+ this.size() - 2, this.size() - 1));
return true;
}
@@ -205,6 +226,7 @@ public class AltosScanUI
void set_frequency() throws InterruptedException, TimeoutException {
reader.set_frequency(frequencies[frequency_index].frequency);
+ reader.reset();
}
void next() throws InterruptedException, TimeoutException {