[Search] Fix delay between chars
This commit is contained in:
parent
17f4fd4108
commit
58dc5f01bd
2 changed files with 9 additions and 6 deletions
|
@ -39,7 +39,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class SearchUICore {
|
public class SearchUICore {
|
||||||
|
|
||||||
private static final int TIMEOUT_BETWEEN_CHARS = 400;
|
private static final int TIMEOUT_BETWEEN_CHARS = 700;
|
||||||
|
private static final int TIMEOUT_BEFORE_SEARCH = 50;
|
||||||
private static final Log LOG = PlatformUtil.getLog(SearchUICore.class);
|
private static final Log LOG = PlatformUtil.getLog(SearchUICore.class);
|
||||||
private SearchPhrase phrase;
|
private SearchPhrase phrase;
|
||||||
private SearchResultCollection currentSearchResult;
|
private SearchResultCollection currentSearchResult;
|
||||||
|
@ -353,7 +354,7 @@ public class SearchUICore {
|
||||||
return this.phrase;
|
return this.phrase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SearchResultCollection search(final String text, final ResultMatcher<SearchResult> matcher) {
|
public SearchResultCollection search(final String text, final boolean updateResult, final ResultMatcher<SearchResult> matcher) {
|
||||||
final int request = requestNumber.incrementAndGet();
|
final int request = requestNumber.incrementAndGet();
|
||||||
final SearchPhrase phrase = this.phrase.generateNewPhrase(text, searchSettings);
|
final SearchPhrase phrase = this.phrase.generateNewPhrase(text, searchSettings);
|
||||||
this.phrase = phrase;
|
this.phrase = phrase;
|
||||||
|
@ -369,8 +370,10 @@ public class SearchUICore {
|
||||||
onSearchStart.run();
|
onSearchStart.run();
|
||||||
}
|
}
|
||||||
SearchResultMatcher rm = new SearchResultMatcher(matcher, phrase, request, requestNumber, totalLimit);
|
SearchResultMatcher rm = new SearchResultMatcher(matcher, phrase, request, requestNumber, totalLimit);
|
||||||
if(TIMEOUT_BETWEEN_CHARS > 0) {
|
if (TIMEOUT_BETWEEN_CHARS > 0 && updateResult) {
|
||||||
Thread.sleep(TIMEOUT_BETWEEN_CHARS);
|
Thread.sleep(TIMEOUT_BETWEEN_CHARS);
|
||||||
|
} else if (TIMEOUT_BEFORE_SEARCH > 0) {
|
||||||
|
Thread.sleep(TIMEOUT_BEFORE_SEARCH);
|
||||||
}
|
}
|
||||||
if (rm.isCancelled()) {
|
if (rm.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1072,7 +1072,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
searchEditText.setHint(R.string.type_city_town);
|
searchEditText.setHint(R.string.type_city_town);
|
||||||
startCitySearch();
|
startCitySearch();
|
||||||
updateTabbarVisibility(false);
|
updateTabbarVisibility(false);
|
||||||
runSearch();
|
runCoreSearch("", false, false);
|
||||||
searchEditText.requestFocus();
|
searchEditText.requestFocus();
|
||||||
AndroidUtils.softKeyboardDelayed(searchEditText);
|
AndroidUtils.softKeyboardDelayed(searchEditText);
|
||||||
}
|
}
|
||||||
|
@ -1249,7 +1249,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runCoreSearchInternal(String text, boolean updateResult, boolean searchMore) {
|
private void runCoreSearchInternal(String text, boolean updateResult, boolean searchMore) {
|
||||||
SearchResultCollection c = searchUICore.search(text, new ResultMatcher<SearchResult>() {
|
SearchResultCollection c = searchUICore.search(text, updateResult, new ResultMatcher<SearchResult>() {
|
||||||
SearchResultCollection regionResultCollection = null;
|
SearchResultCollection regionResultCollection = null;
|
||||||
SearchCoreAPI regionResultApi = null;
|
SearchCoreAPI regionResultApi = null;
|
||||||
List<SearchResult> results = new ArrayList<>();
|
List<SearchResult> results = new ArrayList<>();
|
||||||
|
|
Loading…
Reference in a new issue