use of com.itculturalfestival.smartcampus.adapter.BaseFragmentPagerAdapter in project SmartCampus by Vegen.
the class HomeFragment method setupUI.
@Override
protected void setupUI() {
showContentView();
ImmersionBar.setTitleBar(getActivity(), toolbar);
float marginHeight = SystemUtils.getStatusBarHeight(getContext()) + SystemUtils.getActionBarHeight(getContext());
viewTop.getLayoutParams().height = (int) marginHeight;
banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE);
banner.setIndicatorGravity(BannerConfig.CENTER);
banner.setImageLoader(new GlideImageLoader());
banner.setOnBannerListener(position -> {
if (bannerList.isEmpty())
return;
TopFunArticleDetailActivity.start(getContext(), bannerList.get(position).getTitle(), bannerList.get(position).getNextUrl());
});
List<Fragment> fragments = new ArrayList<>();
flashFragment = NewsFragment.getInstance(Constant.NEWS_TYPE_FLASH);
focusFragment = NewsFragment.getInstance(Constant.NEWS_TYPE_FOCUS);
comprehensiveFragment = NewsFragment.getInstance(Constant.NEWS_TYPE_COMPREHENSIVE);
otherFragment = NewsFragment.getInstance(Constant.NEWS_TYPE_OTHER);
fragments.add(flashFragment);
fragments.add(focusFragment);
fragments.add(comprehensiveFragment);
fragments.add(otherFragment);
List<String> strings = new ArrayList<>();
strings.add("快讯");
strings.add("要闻");
strings.add("综合");
strings.add("其他");
fragmentPagerAdapter = new BaseFragmentPagerAdapter(getChildFragmentManager(), fragments, strings);
viewPager.setAdapter(fragmentPagerAdapter);
tabLayout.setupWithViewPager(viewPager);
viewPager.setOffscreenPageLimit(fragments.size());
}
use of com.itculturalfestival.smartcampus.adapter.BaseFragmentPagerAdapter in project SmartCampus by Vegen.
the class MainActivity method setupViewPager.
private void setupViewPager() {
List<Fragment> fragments = new ArrayList<>();
fragments.add(HomeFragment.getInstance());
fragments.add(TeamFragment.getInstance());
fragments.add(CircleFragment.getInstance());
fragments.add(MessageFragment.getInstance());
fragments.add(UserFragment.getInstance());
pageAdapter = new BaseFragmentPagerAdapter(getSupportFragmentManager(), fragments);
viewPager.setAdapter(pageAdapter);
viewPager.setOffscreenPageLimit(fragments.size());
viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
// changeToolbar(position);
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
super.onPageScrolled(position, positionOffset, positionOffsetPixels);
}
});
}
Aggregations