Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-08-05 08:59:45 +02:00
commit 342b6ad508
2 changed files with 60 additions and 22 deletions

View file

@ -1,17 +1,5 @@
package net.osmand.search;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import net.osmand.Collator;
import net.osmand.OsmAndCollator;
import net.osmand.PlatformUtil;
@ -20,24 +8,34 @@ import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.data.Amenity;
import net.osmand.data.LatLon;
import net.osmand.osm.MapPoiTypes;
import net.osmand.search.core.CustomSearchPoiFilter;
import net.osmand.search.core.ObjectType;
import net.osmand.search.core.SearchCoreAPI;
import net.osmand.search.core.SearchCoreFactory;
import net.osmand.search.core.SearchCoreFactory.SearchAmenityByTypeAPI;
import net.osmand.search.core.SearchCoreFactory.SearchAmenityTypesAPI;
import net.osmand.search.core.SearchCoreFactory.SearchBuildingAndIntersectionsByStreetAPI;
import net.osmand.search.core.SearchCoreFactory.SearchStreetByCityAPI;
import net.osmand.search.core.CustomSearchPoiFilter;
import net.osmand.search.core.SearchPhrase;
import net.osmand.search.core.SearchPhrase.NameStringMatcher;
import net.osmand.search.core.SearchResult;
import net.osmand.search.core.SearchSettings;
import net.osmand.search.core.SearchWord;
import net.osmand.search.core.SearchPhrase.NameStringMatcher;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
import org.apache.commons.logging.Log;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
public class SearchUICore {
private static final int TIMEOUT_BETWEEN_CHARS = 200;
@ -126,9 +124,8 @@ public class SearchUICore {
filterSearchDuplicateResults(sphrase, rm.getRequestResults());
LOG.info(">> Shallow Search phrase " + phrase + " " + rm.getRequestResults().size());
SearchResultCollection collection = new SearchResultCollection(rm.getRequestResults(),
return new SearchResultCollection(rm.getRequestResults(),
sphrase);
return collection;
}
return quickRes;
}

View file

@ -59,7 +59,6 @@ import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.search.QuickSearchHelper.SearchHistoryAPI;
import net.osmand.search.SearchUICore;
import net.osmand.search.SearchUICore.SearchResultCollection;
import net.osmand.search.SearchUICore.SearchResultMatcher;
import net.osmand.search.core.ObjectType;
import net.osmand.search.core.SearchCoreAPI;
import net.osmand.search.core.SearchCoreFactory.SearchAmenityTypesAPI;
@ -74,7 +73,6 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
public class QuickSearchDialogFragment extends DialogFragment implements OsmAndCompassListener, OsmAndLocationListener {
@ -636,6 +634,27 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
}
public void reloadCategories() {
if (app.isApplicationInitializing()) {
showProgressBar();
app.getAppInitializer().addListener(new AppInitializeListener() {
@Override
public void onProgress(AppInitializer init, AppInitializer.InitEvents event) {
}
@Override
public void onFinish(AppInitializer init) {
reloadCategoriesInternal();
if (!searching) {
hideProgressBar();
}
}
});
} else {
reloadCategoriesInternal();
}
}
private void reloadCategoriesInternal() {
try {
SearchResultCollection res = searchUICore.shallowSearch(SearchAmenityTypesAPI.class,
"", null);
@ -654,6 +673,27 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
}
public void reloadHistory() {
if (app.isApplicationInitializing()) {
showProgressBar();
app.getAppInitializer().addListener(new AppInitializeListener() {
@Override
public void onProgress(AppInitializer init, AppInitializer.InitEvents event) {
}
@Override
public void onFinish(AppInitializer init) {
reloadHistoryInternal();
if (!searching) {
hideProgressBar();
}
}
});
} else {
reloadHistoryInternal();
}
}
private void reloadHistoryInternal() {
try {
SearchResultCollection res = searchUICore.shallowSearch(SearchHistoryAPI.class,
"", null);
@ -687,6 +727,8 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
showProgressBar();
foundPartialLocation = false;
updateToolbarButton();
interruptedSearch = false;
searching = true;
if (app.isApplicationInitializing() && text.length() > 0) {
app.getAppInitializer().addListener(new AppInitializeListener() {
@ -711,8 +753,6 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
}
private SearchResultCollection runCoreSearchInternal(String text) {
interruptedSearch = false;
searching = true;
return searchUICore.search(text, new ResultMatcher<SearchResult>() {
SearchResultCollection regionResultCollection = null;
@ -785,6 +825,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
List<SearchResult> res = new ArrayList<>(getResultCollection().getCurrentSearchResults());
res.addAll(regionResults);
SearchResultCollection resCollection = new SearchResultCollection(res, regionPhrase);
searchUICore.filterSearchDuplicateResults(regionPhrase, resCollection.getCurrentSearchResults());
updateSearchResult(resCollection, true);
} else {
updateSearchResult(regionResultCollection, false);