-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ENH/FIX] Search clean-up #717
Conversation
@@ -163,7 +163,7 @@ private void setupMap(final LatLng center, final Bundle savedInstanceState, fina | |||
private void setupQuery( final QueryArgs queryArgs ) { | |||
|
|||
final LatLngBounds bounds = queryArgs.getLocationBounds(); | |||
String sql = "SELECT bssid,lastlat,lastlon FROM " + DatabaseHelper.NETWORK_TABLE + " WHERE 1=1 "; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this whole method should move to DatabaseHelper, not just the query string?
this.bssid = ( bssid == null ) ? "" : bssid.toLowerCase(Locale.US); | ||
this.ssid = ( ssid == null ) ? "" : ssid; | ||
this.frequency = frequency; | ||
this.capabilities = ( capabilities == null ) ? "" : capabilities; | ||
this.level = level; | ||
this.type = type; | ||
if (null != lastTime && lastTime > 0L) { | ||
this.lastTime = lastTime; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HACK: Since the scheme is not-null, empty is resulting in zeros - I'd rather leave last null.
private static final SimpleDateFormat timeFormatter = new SimpleDateFormat(timePattern, l); | ||
private static final SimpleDateFormat dateTimeFormatter = new SimpleDateFormat(dateTimePattern, l); | ||
private static final SimpleDateFormat timeFormatter24 = new SimpleDateFormat(timePattern24, l); | ||
private static final SimpleDateFormat dateTimeFormatter24 = new SimpleDateFormat(dateTimePattern24, l); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we were building these dynamically each time before, which seems silly. OTOH, now we're stuck building two instances we'll never use (over the entire app) because static initialization doesn't have access to Context we need to discriminate between 24 and 12 hour time preference.
public static String getTime(@NonNull final Network network, @NonNull final Context context) { | ||
final Long last = network.getLastTime(); | ||
if (null == last) { | ||
if (DateFormat.is24HourFormat(context)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they made a utility method for us
} else { | ||
return timeFormatter.format(new Date(network.getConstructionTime())); | ||
} | ||
// SOMEDAY (SDK26+: return Instant.ofEpochSecond(network.getConstructionTime()).atZone(ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern(timePattern)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would be great, but it's Android SDK 26+ so we'll use it when we get forced another two versions forward.
format = new SimpleDateFormat("H:mm:ss", Locale.getDefault()); | ||
public static String getTime(@NonNull final Network network, @NonNull final Context context) { | ||
final Long last = network.getLastTime(); | ||
if (null == last) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if lasttime is null then use construction time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has a practical problem - if lasttime
is null (genuinely surprised at how common this is proving), then you get construction time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all seems reasonable to this caveman programmer
@@ -144,6 +144,8 @@ public final class DatabaseHelper extends Thread { | |||
private static final String LOCATED_NETS_QUERY_STEM = " FROM " + DatabaseHelper.NETWORK_TABLE | |||
+ " WHERE bestlat != 0.0 AND bestlon != 0.0 AND instr(bssid, '_') <= 0"; | |||
|
|||
public static final String SEARCH_NETWORKS = "SELECT bssid,lastlat,lastlon FROM " + NETWORK_TABLE + " WHERE 1=1 "; | |||
//TODO: should search use best[lat|lon] instead of last? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe any time we only show a single location it should be the 'best' one. It's newer, back in the day we didn't have best.
Here's a draft of that I've been working on. Notes in-line.