Request focus for searchEt in onResume; remove parameter "cancelled" from callback because method onPostExecute won't be invoked if the task was cancelled
This commit is contained in:
parent
a55b6d085e
commit
ed6b4d25bb
2 changed files with 6 additions and 7 deletions
|
@ -55,7 +55,7 @@ public class WikivoyageSearchCore {
|
|||
|
||||
void onSearchStarted();
|
||||
|
||||
void onSearchFinished(@Nullable List<SearchResult> results, boolean lastTask, boolean cancelled);
|
||||
void onSearchFinished(@Nullable List<SearchResult> results, boolean lastTask);
|
||||
}
|
||||
|
||||
private class SearchAsyncTask extends AsyncTask<Void, Void, List<SearchResult>> {
|
||||
|
@ -94,9 +94,8 @@ public class WikivoyageSearchCore {
|
|||
@Override
|
||||
protected void onPostExecute(List<SearchResult> results) {
|
||||
super.onPostExecute(results);
|
||||
boolean cancelled = isCancelled();
|
||||
for (SearchListener listener : listeners) {
|
||||
listener.onSearchFinished(results, workQueue.isEmpty(), cancelled);
|
||||
listener.onSearchFinished(results, workQueue.isEmpty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ public class WikivoyageSearchDialogFragment extends BaseOsmAndDialogFragment imp
|
|||
String newQuery = s.toString();
|
||||
if (newQuery.isEmpty()) {
|
||||
searchCore.cancelSearch();
|
||||
switchProgressBarVisibility(false);
|
||||
adapter.setItems(null);
|
||||
} else if (!searchQuery.equalsIgnoreCase(newQuery)) {
|
||||
searchQuery = newQuery;
|
||||
|
@ -118,6 +119,7 @@ public class WikivoyageSearchDialogFragment extends BaseOsmAndDialogFragment imp
|
|||
if (searchCore != null) {
|
||||
searchCore.registerListener(this);
|
||||
}
|
||||
searchEt.requestFocus();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -135,10 +137,8 @@ public class WikivoyageSearchDialogFragment extends BaseOsmAndDialogFragment imp
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onSearchFinished(@Nullable List<SearchResult> results, boolean lastTask, boolean cancelled) {
|
||||
if (!cancelled) {
|
||||
adapter.setItems(results);
|
||||
}
|
||||
public void onSearchFinished(@Nullable List<SearchResult> results, boolean lastTask) {
|
||||
adapter.setItems(results);
|
||||
if (lastTask) {
|
||||
switchProgressBarVisibility(false);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue