Small refactoring

This commit is contained in:
Victor Shcherb 2016-08-05 15:29:40 +03:00
parent b13c8089be
commit d02a770785

View file

@ -764,8 +764,13 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
@Override @Override
public boolean publish(SearchResult object) { public boolean publish(SearchResult object) {
if (paused) { if (paused) {
if(regionResultCollection != null && regionResultCollection.getCurrentSearchResults().size() > 0) {
getResultCollection().addSearchResults(regionResultCollection.getCurrentSearchResults(), true, true);
regionResultCollection = null;
}
if (results.size() > 0) { if (results.size() > 0) {
getResultCollection().addSearchResults(results, true, true); getResultCollection().addSearchResults(results, true, true);
results.clear();
} }
return false; return false;
} }
@ -784,14 +789,17 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
} }
regionResultApi = null; regionResultApi = null;
regionResultCollection = null; regionResultCollection = null;
results = new ArrayList<>(); results.clear();
showApiResults(apiResults, phrase, hasRegionCollection); showApiResults(apiResults, phrase, hasRegionCollection);
break; break;
case SEARCH_API_REGION_FINISHED: case SEARCH_API_REGION_FINISHED:
regionResultApi = (SearchCoreAPI) object.object; regionResultApi = (SearchCoreAPI) object.object;
final SearchPhrase regionPhrase = object.requiredSearchPhrase; final SearchPhrase regionPhrase = object.requiredSearchPhrase;
regionResultCollection = new SearchResultCollection(regionPhrase); if(regionResultCollection == null) {
regionResultCollection = new SearchResultCollection(regionPhrase);
}
regionResultCollection.addSearchResults(results, true, true); regionResultCollection.addSearchResults(results, true, true);
results.clear();
showRegionResults(regionPhrase, regionResultCollection); showRegionResults(regionPhrase, regionResultCollection);
break; break;
case PARTIAL_LOCATION: case PARTIAL_LOCATION: