Skip to content

Commit

Permalink
Fix #273 - When searching, always check if last known location is null
Browse files Browse the repository at this point in the history
If it is, use the current region center instead.  Searches are location-based in OBA server-side, so we need to feed the REST API a location.
  • Loading branch information
barbeau committed Jun 24, 2015
1 parent 2cca338 commit 86c4722
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,11 @@ protected boolean isShortcutMode() {

protected final Location getSearchCenter() {
Activity act = getActivity();
Location result = null;
if (act instanceof MyTabActivityBase) {
MyTabActivityBase base = (MyTabActivityBase) act;
result = base.getSearchCenter();
}
if (result == null) {
result = Application.getLastKnownLocation(act, mGoogleApiClient);
Location location = Application.getLastKnownLocation(act, mGoogleApiClient);
if (location == null) {
location = LocationUtil.getDefaultSearchCenter();
}
return result;
return location;
}

private final OnFocusChangeListener mOnQueryTextFocusChangeListener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,11 @@ private void search() {
@Override
public Loader<SearchResponse> onCreateLoader(int id, Bundle args) {
String query = args.getString(QUERY_TEXT);
return new MyLoader(getActivity(), query,
Application.getLastKnownLocation(getActivity(), mGoogleApiClient));
Location location = Application.getLastKnownLocation(getActivity(), mGoogleApiClient);
if (location == null) {
location = LocationUtil.getDefaultSearchCenter();
}
return new MyLoader(getActivity(), query, location);
}

@Override
Expand Down

0 comments on commit 86c4722

Please sign in to comment.