MrEngineer13 / SnackBar

toast-like alert pattern for Android inspired by the Google Material Design Spec

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Callback Once Snackbar Disappears

arayray opened this issue · comments

I'm not sure if this exists currently or not but a good feature would be a callback so when the dialog disappears you can run a function. Prefect for any undo button, simply don't do anything until the callback is called.

There's already a built in method to do this. Just set a OnVisibiltyChangeListener like so:

.withVisibilityChangeListener(new SnackBar.OnVisibilityChangeListener() {
        @Override
        public void onShow(int stackSize) {
            Log.i("SNACKBAR", "onShow Snacks left to show: "+stackSize);
        }

        @Override
        public void onHide(int stackSize) {
            Log.i("SNACKBAR", "onHide Snacks left to show: "+stackSize);
        }
})