altoslib/altosuilib: Fix equals methods, add hashCode
[fw/altos] / altosuilib / AltosScanUI.java
index 1b30f99d64a092532e7eb9de702d17d0461b12fa..fccfbaee284703d4b7e6d727c5e55f3c052758c8 100644 (file)
@@ -15,7 +15,7 @@
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  */
 
-package org.altusmetrum.altosuilib_3;
+package org.altusmetrum.altosuilib_7;
 
 import java.awt.*;
 import java.awt.event.*;
@@ -25,7 +25,7 @@ import java.io.*;
 import java.util.*;
 import java.text.*;
 import java.util.concurrent.*;
-import org.altusmetrum.altoslib_5.*;
+import org.altusmetrum.altoslib_7.*;
 
 class AltosScanResult {
        String          callsign;
@@ -62,9 +62,18 @@ class AltosScanResult {
                rate = in_rate;
        }
 
-       public boolean equals(AltosScanResult other) {
+       public int hashCode() {
+               return serial ^ frequency.hashCode() ^ telemetry ^ rate;
+       }
+
+       public boolean equals(Object o) {
+               if (o == null)
+                       return false;
+               if (!(o instanceof AltosScanResult))
+                       return false;
+               AltosScanResult other = (AltosScanResult) o;
                return (serial == other.serial &&
-                       frequency.frequency == other.frequency.frequency &&
+                       frequency.equals(other.frequency) &&
                        telemetry == other.telemetry &&
                        rate == other.rate);
        }
@@ -254,9 +263,6 @@ public class AltosScanUI
        void next() throws InterruptedException, TimeoutException {
                reader.set_monitor(false);
 
-               /* Let any pending input from the last configuration drain out */
-               Thread.sleep(100);
-
                if (select_rate) {
                        boolean wrapped = false;
                        do {
@@ -447,6 +453,7 @@ public class AltosScanUI
        }
 
        public AltosScanUI(AltosUIFrame in_owner, boolean in_select_telemetry) {
+               super(in_owner, "Scan Telemetry", false);
 
                owner = in_owner;
                select_telemetry = in_select_telemetry;