Created
July 16, 2019 09:05
-
-
Save iamdeveloper-lopez/0ff0deed6902082e10b8c82ca1d187da to your computer and use it in GitHub Desktop.
Callback for AppBarLayout state
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class SimpleCollapsingToolbarCallback implements AppBarLayout.OnOffsetChangedListener { | |
public enum State { | |
EXPANDED, | |
COLLAPSED | |
} | |
public abstract void onCollapsingToolbar(State state); | |
@Override | |
public void onOffsetChanged(AppBarLayout appBarLayout, int i) { | |
if (Math.abs(i) - appBarLayout.getTotalScrollRange() == 0) { | |
onCollapsingToolbar(State.COLLAPSED); | |
Log.d("STATE", "COLLAPSED"); | |
} else { | |
onCollapsingToolbar(State.EXPANDED); | |
Log.d("STATE", "EXPANDED"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment