Recently I stumbled upon this matter myself when for scrolling and showing Snackback, too many were shown before the first even disappeared. I had to find a way to know if the app should have laid down the Snackbar.
I personally found this solution.
It is true Snackbar itself does not offer any kind of listener for it's state/visibility, but you can still get the View Object out of Snackbar ( getView(); ). From the View Object you have the chance to use a wide variety of methods to add listeners.
To implement it you have to go out of the common "all-in-one-line" Toast/Snackbar usage, because adding listeners returns void .
I personally found OnAttachStateChangeListener to fulfill my needs.
Dropping a snipper with my code in case it might turn useful for you.
Snackbar snack = Snackbar.make(getView(), "My Placeholder Text", Snackbar.LENGTH_LONG);
snack.getView().addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(View v) {
canDisplaySnackbar = false;
}
@Override
public void onViewDetachedFromWindow(View v) {
Handler h = new Handler();
h.postDelayed(new Runnable() {
@Override
public void run() {
canDisplaySnackbar = true;
}
}, 1000);
}
});
snack.show();
Please note that this is just my implementation for my own problem, Handler with a postDelayed Runnable might not even fit your case. It was just to give a general idea of the implementation I suggested using a snippet I already own.