Fix building history. Fix search after map download.

This commit is contained in:
Alexey Kulish 2016-08-03 12:43:05 +03:00
parent a6c0dc2b08
commit 4409a258d8
2 changed files with 20 additions and 9 deletions

View file

@ -8,6 +8,7 @@ import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.helpers.SearchHistoryHelper;
import net.osmand.plus.resources.RegionAddressRepository;
import net.osmand.plus.resources.ResourceManager.ResourceListener;
import net.osmand.search.SearchUICore;
import net.osmand.search.SearchUICore.SearchResultCollection;
import net.osmand.search.core.ObjectType;
@ -19,7 +20,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.List;
public class QuickSearchHelper {
public class QuickSearchHelper implements ResourceListener {
public static final int SEARCH_FAVORITE_API_PRIORITY = 2;
public static final int SEARCH_FAVORITE_API_CATEGORY_PRIORITY = 7;
@ -31,13 +32,19 @@ public class QuickSearchHelper {
private OsmandApplication app;
private SearchUICore core;
private SearchResultCollection resultCollection;
private boolean mapsIndexed;
public QuickSearchHelper(OsmandApplication app) {
this.app = app;
core = new SearchUICore(app.getPoiTypes(), app.getSettings().MAP_PREFERRED_LOCALE.get());
app.getResourceManager().addResourceListener(this);
}
public SearchUICore getCore() {
if (mapsIndexed) {
mapsIndexed = false;
setRepositoriesForSearchUICore(app);
}
return core;
}
@ -50,6 +57,7 @@ public class QuickSearchHelper {
}
public void initSearchUICore() {
mapsIndexed = false;
setRepositoriesForSearchUICore(app);
core.init();
// Register favorites search api
@ -213,4 +221,9 @@ public class QuickSearchHelper {
return SEARCH_HISTORY_API_PRIORITY;
}
}
@Override
public void onMapsIndexed() {
mapsIndexed = true;
}
}

View file

@ -158,7 +158,6 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
String lang = searchResult.requiredSearchPhrase.getSettings().getLang();
PointDescription pointDescription = null;
Object object = searchResult.object;
String typeName = null;
switch (searchResult.objectType) {
case POI:
String poiSimpleFormat = OsmAndFormatter.getPoiStringWithoutType((Amenity) object, lang);
@ -192,25 +191,24 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
pointDescription = fav.getPointDescription();
break;
case HOUSE:
String name = searchResult.localeName;
String nm = searchResult.localeName;
if (searchResult.relatedObject instanceof City) {
typeName = ((City) searchResult.relatedObject).getName(searchResult.requiredSearchPhrase.getSettings().getLang(), true);
nm = ((City) searchResult.relatedObject).getName(searchResult.requiredSearchPhrase.getSettings().getLang(), true) + " " + nm;
} else if (searchResult.relatedObject instanceof Street) {
String s = ((Street) searchResult.relatedObject).getName(searchResult.requiredSearchPhrase.getSettings().getLang(), true);
String c = ((Street) searchResult.relatedObject).getCity().getName(searchResult.requiredSearchPhrase.getSettings().getLang(), true);
name = s + " " + name;
typeName = c;
nm = s + " " + nm + ", " + c;
} else if (searchResult.localeRelatedObjectName != null) {
typeName = searchResult.localeRelatedObjectName;
nm = searchResult.localeRelatedObjectName + " " + nm;
}
pointDescription = new PointDescription(PointDescription.POINT_TYPE_ADDRESS, typeName, name);
pointDescription = new PointDescription(PointDescription.POINT_TYPE_ADDRESS, nm);
break;
case LOCATION:
LatLon latLon = (LatLon) object;
pointDescription = new PointDescription(latLon.getLatitude(), latLon.getLongitude());
break;
case STREET_INTERSECTION:
typeName = QuickSearchListItem.getTypeName(app, searchResult);
String typeName = QuickSearchListItem.getTypeName(app, searchResult);
if (Algorithms.isEmpty(typeName)) {
typeName = null;
}