use of io.github.ryanhoo.music.ui.music.MusicPlayerFragment in project StylishMusicPlayer by ryanhoo.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
// Main Controls' Titles
mTitles = getResources().getStringArray(R.array.mp_main_titles);
// Fragments
BaseFragment[] fragments = new BaseFragment[mTitles.length];
fragments[0] = new PlayListFragment();
fragments[1] = new MusicPlayerFragment();
fragments[2] = new LocalFilesFragment();
fragments[3] = new SettingsFragment();
// Inflate ViewPager
MainPagerAdapter adapter = new MainPagerAdapter(getSupportFragmentManager(), mTitles, fragments);
viewPager.setAdapter(adapter);
viewPager.setOffscreenPageLimit(adapter.getCount() - 1);
viewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.mp_margin_large));
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
// Empty
}
@Override
public void onPageScrollStateChanged(int state) {
// Empty
}
@Override
public void onPageSelected(int position) {
radioButtons.get(position).setChecked(true);
}
});
radioButtons.get(DEFAULT_PAGE_INDEX).setChecked(true);
}
Aggregations