Skip to content

skill20/ComboListener

 
 

Repository files navigation

ComboListener

Observe click combo on any view on Android.

##ScreenShot combo.gif

Usages

1.Include the library with Gradle or Maven.

Gradle

dependencies {
   compile 'com.gjiazhe:combolistener:1.0.2'
}

Maven

<dependency>
  <groupId>com.gjiazhe</groupId>
  <artifactId>combolistener</artifactId>
  <version>1.0.2</version>
  <type>pom</type>
</dependency>

2.In your code, use ComboListenerBuilder to set the options and the listener.

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        final Toast toast = Toast.makeText(this, "", Toast.LENGTH_SHORT);
        Button btnCombo = (Button) findViewById(R.id.btn_combo);

        new ComboListenerBuilder()
                .setMaxInterval(500)//set the Max Interval between two clicks, default is 300ms
                .observeOn(btnCombo)//set the view to be observed
                .setOnComboListener(new ComboListenerBuilder.OnComboListener() {
                    @Override
                    public void onCombo(View view, int comboCount) {
                        toast.setText(comboCount+"");
                        toast.show();
                    }
                })
                .startListen();
    }
}

About

Observe click combo on any view for Android

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%