Created
July 24, 2015 13:02
-
-
Save benjaminVadon/6925df0adf310acdc9ba to your computer and use it in GitHub Desktop.
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
currentListener = new AppBarLayout.OnOffsetChangedListener() { | |
@Override | |
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { | |
Fragment fragment = ((RegisteredFragmentPagerAdapter) viewPager.getAdapter()).getRegisteredFragment(tab.getPosition()); | |
if (fragment instanceof SwipeRefreshLayoutController) { | |
((SwipeRefreshLayoutController) fragment).getSwipeRefreshLayout().setEnabled(verticalOffset == 0); | |
} | |
if (Math.abs(verticalOffset) == appBarLayout.getTotalScrollRange()) { | |
ViewCompat.setElevation(tabLayout, activity.getResources().getDimension(R.dimen.appbar_elevation)); | |
} else { | |
ViewCompat.setElevation(tabLayout, 0.0F); | |
} | |
} | |
}; | |
appBarLayout.addOnOffsetChangedListener(currentListener); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment