From e92195d85f19d7140d218a8a7cdee22ecf3ccf14 Mon Sep 17 00:00:00 2001 From: Bill Schilit Date: Sat, 22 Nov 2014 16:59:14 -0800 Subject: [PATCH] Sort NEAREST above all else --- .../main/java/org/uribeacon/widget/ScanResultAdapter.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/android-uribeacon/uribeacon-library/src/main/java/org/uribeacon/widget/ScanResultAdapter.java b/android-uribeacon/uribeacon-library/src/main/java/org/uribeacon/widget/ScanResultAdapter.java index fe25087..89e6cbe 100644 --- a/android-uribeacon/uribeacon-library/src/main/java/org/uribeacon/widget/ScanResultAdapter.java +++ b/android-uribeacon/uribeacon-library/src/main/java/org/uribeacon/widget/ScanResultAdapter.java @@ -190,6 +190,13 @@ public int compareTo(@NonNull DeviceSighting other) { final String otherAddress = other.scanResult.getDevice().getAddress(); // Sort by the stabilized region of the device, unless // they are the same, in which case sort by distance. + final String nearest = mRegionResolver.getNearestAddress(); + if (address.equals(nearest)) { + return -1; + } + if (otherAddress.equals(nearest)) { + return 1; + } int r1 = mRegionResolver.getRegion(address); int r2 = mRegionResolver.getRegion(otherAddress); if (r1 != r2) {