|
|
Listener for clicking each button or animation-states.
|
|
|
|
|
|
###Listener in Each Builder
|
|
|
You can add a simple listener for each boom-button by adding to each builder of them.
|
|
|
```
|
|
|
for (int i = 0; i < bmb.getPiecePlaceEnum().pieceNumber(); i++) {
|
|
|
SimpleCircleButton.Builder builder = new SimpleCircleButton.Builder()
|
|
|
.listener(new OnBMClickListener() {
|
|
|
@Override
|
|
|
public void onBoomButtonClick(int index) {
|
|
|
// When the boom-button corresponding this builder is clicked.
|
|
|
Toast.makeText(SimpleCircleButtonActivity.this, "Clicked " + index, Toast.LENGTH_SHORT).show();
|
|
|
}
|
|
|
});
|
|
|
bmb.addBuilder(builder);
|
|
|
}
|
|
|
```
|
|
|
|
|
|
###Listener for BMB
|
|
|
If you want to manager all the click events in a method, you can use `OnBoomListener` / `OnBoomListenerAdapter`:
|
|
|
```
|
|
|
// Use OnBoomListener to listen all methods
|
|
|
bmb.setOnBoomListener(new OnBoomListener() {
|
|
|
@Override
|
|
|
public void onClicked(int index, BoomButton boomButton) {
|
|
|
// If you have implement listeners for boom-buttons in builders,
|
|
|
// then you shouldn't add any listener here for duplicate callbacks.
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onBackgroundClick() {
|
|
|
textViewForAnimation.setText("Click background!!!");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onBoomWillHide() {
|
|
|
textViewForAnimation.setText("Will RE-BOOM!!!");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onBoomDidHide() {
|
|
|
textViewForAnimation.setText("Did RE-BOOM!!!");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onBoomWillShow() {
|
|
|
textViewForAnimation.setText("Will BOOM!!!");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onBoomDidShow() {
|
|
|
textViewForAnimation.setText("Did BOOM!!!");
|
|
|
}
|
|
|
});
|
|
|
```
|
|
|
Or in `OnBoomListenerAdapter`(Optional listener):
|
|
|
```
|
|
|
// Use OnBoomListenerAdapter to listen part of methods
|
|
|
bmb.setOnBoomListener(new OnBoomListenerAdapter() {
|
|
|
@Override
|
|
|
public void onBoomWillShow() {
|
|
|
super.onBoomWillShow();
|
|
|
// logic here
|
|
|
}
|
|
|
});
|
|
|
``` |
|
|
\ No newline at end of file |