mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-24 22:06:15 +03:00
Merge pull request #2348 from cooperra/patch-1
Fix debouncing not working on first search character; add extra delay instead
This commit is contained in:
commit
d6afa9f30a
1 changed files with 4 additions and 2 deletions
|
@ -48,6 +48,8 @@ public abstract class SearchableBaseNoteFragment extends BaseNoteFragment {
|
||||||
private SearchView searchView;
|
private SearchView searchView;
|
||||||
private String searchQuery = null;
|
private String searchQuery = null;
|
||||||
private static final int delay = 50; // If the search string does not change after $delay ms, then the search task starts.
|
private static final int delay = 50; // If the search string does not change after $delay ms, then the search task starts.
|
||||||
|
private static final int shortStringDelay = 200; // A longer delay for short search strings.
|
||||||
|
private static final int shortStringSize = 3; // The maximum length of a short search string.
|
||||||
private boolean directEditRemotelyAvailable = false; // avoid using this directly, instead use: isDirectEditEnabled()
|
private boolean directEditRemotelyAvailable = false; // avoid using this directly, instead use: isDirectEditEnabled()
|
||||||
|
|
||||||
@ColorInt
|
@ColorInt
|
||||||
|
@ -228,8 +230,8 @@ public abstract class SearchableBaseNoteFragment extends BaseNoteFragment {
|
||||||
handler.removeCallbacksAndMessages(null);
|
handler.removeCallbacksAndMessages(null);
|
||||||
}
|
}
|
||||||
delayQueryTask = new DelayQueryRunnable(newText);
|
delayQueryTask = new DelayQueryRunnable(newText);
|
||||||
// If there is only one char in the search pattern, we should start the search immediately.
|
// If there are few chars in the search pattern, we should start the search later.
|
||||||
handler.postDelayed(delayQueryTask, newText.length() > 1 ? delay : 0);
|
handler.postDelayed(delayQueryTask, newText.length() > shortStringSize ? delay : shortStringDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
class DelayQueryRunnable implements Runnable {
|
class DelayQueryRunnable implements Runnable {
|
||||||
|
|
Loading…
Reference in a new issue