I'd keep a long named lastPress as a field on my TextWatcher. When you press a key, set lastPress = System.currentTimeMillis()
. Then just wrap your entire onTextChanged in a if with condition if(System.currentTimeMillis() - lastPress>500)
and set lastPress again in that if.
new TextWatcher(){
long lastPress = 0l;
@Override
public void onTextChanged(CharSequence s,
int start, int before, int count){
if(System.currentTimeMillis() - lastpress > 500){
lastPress= System.currentTimeMillis();
GetAutocompletion ac = new GetAutocompletion();
ac.execute(zipBox.getText().toString());
}
}
// Other methods to implement
}