Determine AppBarLayout previous state

Viewed 42

How can i get the previous state of an AppBarLayout? Because when the current state becomes IDLE the behavior will be different if it comes from COLLAPSED state or EXPANDED one.

For now i am able to know the current state thanks to AppBarStateChangeListener :

   appBar.addOnOffsetChangedListener(new AppBarStateChangeListener() {
        @Override
        public void onStateChanged(AppBarLayout appBarLayout, State state) {
            switch (state) {
                case COLLAPSED:
                    //do stuff when COLLAPSED
                    break;
                case EXPANDED:
                    //do stuff when EXPANDED
                    break;
                case IDLE:
                    //do stuff when IDLE
                    break;
            }
        }
    });

If you have a trick to do that, you will really help me.

Thanks

0 Answers
Related