use of com.qslll.library.fragments.ExpandingFragment in project ExpandingPager by qs-lll.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
setupWindowAnimations();
TravelViewPagerAdapter adapter = new TravelViewPagerAdapter(getSupportFragmentManager());
adapter.addAll(generateTravelList());
viewPager.setAdapter(adapter);
ExpandingPagerFactory.setupViewPager(viewPager);
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
ExpandingFragment expandingFragment = ExpandingPagerFactory.getCurrentFragment(viewPager);
if (expandingFragment != null && expandingFragment.isOpenend()) {
expandingFragment.close();
}
}
@Override
public void onPageSelected(int position) {
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
}
use of com.qslll.library.fragments.ExpandingFragment in project ExpandingPager by qs-lll.
the class ExpandingPagerFactory method getCurrentFragment.
public static ExpandingFragment getCurrentFragment(ViewPager viewPager) {
if (viewPager.getAdapter() instanceof ExpandingViewPagerAdapter) {
ExpandingViewPagerAdapter adapter = (ExpandingViewPagerAdapter) viewPager.getAdapter();
Fragment fragment = adapter.getCurrentFragment();
if (fragment instanceof ExpandingFragment) {
return (ExpandingFragment) fragment;
}
}
return null;
}
Aggregations