Delay on performFiltering
smiesnyrobert opened this issue · comments
Hi, how can i make filtering delayed? Now filtering run on every new/removed letter. I want delay this, because I loading data from webservice. Thank you
Hello guys,
Any news on this?
I've found the following after some research: https://futurestud.io/tutorials/android-how-to-delay-changedtextevent-on-androids-edittext
For reference:
private EditText searchText;
private TextView resultText;
private Timer timer;
private TextWatcher searchTextWatcher = new TextWatcher() {
@Override
public void afterTextChanged(Editable arg0) {
// user typed: start the timer
timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
// do your actual work here
}
}, 600); // 600ms delay before the timer executes the „run“ method from TimerTask
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// nothing to do here
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// user is typing: reset already started timer (if existing)
if (timer != null) {
timer.cancel();
}
}
};
Is possible to attach it on a MaterialSearchView object?