Remove search input textview(also EditTextView) debounce to help reduce unnecessary network bandwidth waste
Switch branches/tags
Nothing to show
Clone or download
Latest commit e96df24 Nov 15, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea feat:add license Nov 15, 2018
app first commit Nov 8, 2018
gradle/wrapper first commit Nov 8, 2018
image first commit Nov 8, 2018
library first commit Nov 8, 2018
.gitignore first commit Nov 8, 2018
LICENSE feat:add license Nov 15, 2018 feat:add license Nov 15, 2018
build.gradle first commit Nov 8, 2018 first commit Nov 8, 2018
gradlew first commit Nov 8, 2018
gradlew.bat first commit Nov 8, 2018
settings.gradle first commit Nov 8, 2018

Sug Debounce

Sometimes, we need to listen for changes in the TextView(also EditText) content, especially for some Android apps that support search, search suggestions is a very important feature that enhances the user experience. In general, Android developers prefer to use TextWatcher to listen to TextView content changes, such as follows

    textView.addTextChangedListener(new TextWatcher() {
      @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {


      @Override public void onTextChanged(CharSequence s, int start, int before, int count) {


      @Override public void afterTextChanged(Editable s) {

        /*do suggestion search*/

However, there is a problem here. If you want to search for "California," you may need at least four network requests such as "c", "a", "l", "i" to get the desired suggestions list. And these asynchronous network requests may eventually show the wrong suggestion list, without any special handling.

User experience! User experience! User experience! The important thing to speak three times!

We should do some debounce to avoid unnecessary network requests and avoid wasting bandwidth.

It's similar to javascript-debounce-function.

Getting Started


Step 1. Add it in your root build.gradle at the end of repositories:

    allprojects {
        repositories {
            maven { url '' }

Step 2. Add the dependency

    dependencies {
	implementation 'com.github.SmartDengg:sug-debounce:1.0.0'


    Debounce.onAfterTextChangedAction(textView, 300,
        new DebounceObserver<TextViewAfterTextChangeEvent>() {
          @Override public void onError(Throwable throwable) {


          @Override public void onSuccess(TextViewAfterTextChangeEvent event) {
            /*do your search*/

You can change the denounce timeout, but we recommend 300 ~ 400 ms.

Debounce VS No-Debounce (video)


Debounce search suggestions


No-Debounce search suggestions

How it works



Found this project useful

❤️ Hope this article can help you. Support by clicking the ⭐️, or share it with people around you. ❤️

About author

Email :

weibo : -小鄧子-


See the LICENSE file for license rights and limitations (MIT).