Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
b13c8089be
1 changed files with 56 additions and 48 deletions
|
@ -763,43 +763,76 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean publish(SearchResult object) {
|
public boolean publish(SearchResult object) {
|
||||||
|
|
||||||
if (paused) {
|
if (paused) {
|
||||||
if (results.size() > 0) {
|
if (results.size() > 0) {
|
||||||
getResultCollection().addSearchResults(results, true, true);
|
getResultCollection().addSearchResults(results, true, true);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (object.objectType) {
|
switch (object.objectType) {
|
||||||
case SEARCH_API_FINISHED:
|
case SEARCH_API_FINISHED:
|
||||||
final SearchCoreAPI searchApi = (SearchCoreAPI) object.object;
|
final SearchCoreAPI searchApi = (SearchCoreAPI) object.object;
|
||||||
|
|
||||||
final List<SearchResult> apiResults;
|
final List<SearchResult> apiResults;
|
||||||
final SearchPhrase phrase = object.requiredSearchPhrase;
|
final SearchPhrase phrase = object.requiredSearchPhrase;
|
||||||
final SearchCoreAPI regionApi = regionResultApi;
|
final SearchCoreAPI regionApi = regionResultApi;
|
||||||
final SearchResultCollection regionCollection = regionResultCollection;
|
final SearchResultCollection regionCollection = regionResultCollection;
|
||||||
|
|
||||||
final boolean hasRegionCollection = (searchApi == regionApi && regionCollection != null);
|
final boolean hasRegionCollection = (searchApi == regionApi && regionCollection != null);
|
||||||
if (hasRegionCollection) {
|
if (hasRegionCollection) {
|
||||||
apiResults = regionCollection.getCurrentSearchResults();
|
apiResults = regionCollection.getCurrentSearchResults();
|
||||||
} else {
|
} else {
|
||||||
apiResults = results;
|
apiResults = results;
|
||||||
}
|
}
|
||||||
|
|
||||||
regionResultApi = null;
|
regionResultApi = null;
|
||||||
regionResultCollection = null;
|
regionResultCollection = null;
|
||||||
results = new ArrayList<>();
|
results = new ArrayList<>();
|
||||||
|
showApiResults(apiResults, phrase, hasRegionCollection);
|
||||||
|
break;
|
||||||
|
case SEARCH_API_REGION_FINISHED:
|
||||||
|
regionResultApi = (SearchCoreAPI) object.object;
|
||||||
|
final SearchPhrase regionPhrase = object.requiredSearchPhrase;
|
||||||
|
regionResultCollection = new SearchResultCollection(regionPhrase);
|
||||||
|
regionResultCollection.addSearchResults(results, true, true);
|
||||||
|
showRegionResults(regionPhrase, regionResultCollection);
|
||||||
|
break;
|
||||||
|
case PARTIAL_LOCATION:
|
||||||
|
showLocationToolbar();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
results.add(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return paused;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showLocationToolbar() {
|
||||||
|
app.runInUIThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
foundPartialLocation = true;
|
||||||
|
updateToolbarButton();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showApiResults(final List<SearchResult> apiResults, final SearchPhrase phrase,
|
||||||
|
final boolean hasRegionCollection) {
|
||||||
app.runInUIThread(new Runnable() {
|
app.runInUIThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!paused) {
|
if (!paused) {
|
||||||
boolean appended = false;
|
boolean appended = false;
|
||||||
if (getResultCollection() == null || getResultCollection().getPhrase() != phrase) {
|
if (getResultCollection() == null || getResultCollection().getPhrase() != phrase) {
|
||||||
SearchResultCollection resCollection =
|
SearchResultCollection resCollection = new SearchResultCollection(phrase);
|
||||||
new SearchResultCollection(phrase);
|
resCollection.addSearchResults(apiResults, true, true);
|
||||||
resCollection.addSearchResults(results, true, true);
|
|
||||||
setResultCollection(resCollection);
|
setResultCollection(resCollection);
|
||||||
} else {
|
} else {
|
||||||
getResultCollection().addSearchResults(apiResults, false, true );
|
getResultCollection().addSearchResults(apiResults, false, true );
|
||||||
|
@ -811,12 +844,9 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
}
|
||||||
case SEARCH_API_REGION_FINISHED:
|
|
||||||
regionResultApi = (SearchCoreAPI) object.object;
|
private void showRegionResults(final SearchPhrase regionPhrase, final SearchResultCollection regionResultCollection) {
|
||||||
final SearchPhrase regionPhrase = object.requiredSearchPhrase;
|
|
||||||
regionResultCollection = new SearchResultCollection(regionPhrase);
|
|
||||||
regionResultCollection.addSearchResults(results, true, true);
|
|
||||||
app.runInUIThread(new Runnable() {
|
app.runInUIThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -832,28 +862,6 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
|
||||||
case PARTIAL_LOCATION:
|
|
||||||
app.runInUIThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
foundPartialLocation = true;
|
|
||||||
updateToolbarButton();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
results.add(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return paused;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void completeQueryWithObject(SearchResult sr) {
|
public void completeQueryWithObject(SearchResult sr) {
|
||||||
|
|
Loading…
Reference in a new issue