use of android.support.v4.view.PagerAdapter in project SmartTabLayout by ogaclejapan.
the class SmartTabLayout method populateTabStrip.
private void populateTabStrip() {
final PagerAdapter adapter = viewPager.getAdapter();
for (int i = 0; i < adapter.getCount(); i++) {
final View tabView = (tabProvider == null) ? createDefaultTabView(adapter.getPageTitle(i)) : tabProvider.createTabView(tabStrip, i, adapter);
if (tabView == null) {
throw new IllegalStateException("tabView is null.");
}
if (distributeEvenly) {
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
lp.width = 0;
lp.weight = 1;
}
if (internalTabClickListener != null) {
tabView.setOnClickListener(internalTabClickListener);
}
tabStrip.addView(tabView);
if (i == viewPager.getCurrentItem()) {
tabView.setSelected(true);
}
}
}
use of android.support.v4.view.PagerAdapter in project JamsMusicPlayer by psaravan.
the class VelocityIconPageIndicator method setVelocityViewPager.
@Override
public void setVelocityViewPager(VelocityViewPager view) {
if (mVelocityViewPager == view) {
return;
}
if (mVelocityViewPager != null) {
mVelocityViewPager.setOnPageChangeListener(null);
}
PagerAdapter adapter = view.getAdapter();
if (adapter == null) {
throw new IllegalStateException("VelocityViewPager does not have adapter instance.");
}
mVelocityViewPager = view;
view.setOnPageChangeListener(this);
notifyDataSetChanged();
}
use of android.support.v4.view.PagerAdapter in project JamsMusicPlayer by psaravan.
the class VelocityTabPageIndicator method setVelocityViewPager.
@Override
public void setVelocityViewPager(VelocityViewPager view) {
if (mVelocityViewPager == view) {
return;
}
if (mVelocityViewPager != null) {
mVelocityViewPager.setOnPageChangeListener(null);
}
final PagerAdapter adapter = view.getAdapter();
if (adapter == null) {
throw new IllegalStateException("VelocityViewPager does not have adapter instance.");
}
mVelocityViewPager = view;
view.setOnPageChangeListener(this);
notifyDataSetChanged();
}
use of android.support.v4.view.PagerAdapter in project JamsMusicPlayer by psaravan.
the class TabPageIndicator method notifyDataSetChanged.
public void notifyDataSetChanged() {
mTabLayout.removeAllViews();
PagerAdapter adapter = mViewPager.getAdapter();
IconPagerAdapter iconAdapter = null;
if (adapter instanceof IconPagerAdapter) {
iconAdapter = (IconPagerAdapter) adapter;
}
final int count = adapter.getCount();
for (int i = 0; i < count; i++) {
CharSequence title = adapter.getPageTitle(i);
if (title == null) {
title = EMPTY_TITLE;
}
int iconResId = 0;
if (iconAdapter != null) {
iconResId = iconAdapter.getIconResId(i);
}
addTab(i, title, iconResId);
}
if (mSelectedTabIndex > count) {
mSelectedTabIndex = count - 1;
}
setCurrentItem(mSelectedTabIndex);
requestLayout();
}
use of android.support.v4.view.PagerAdapter in project JamsMusicPlayer by psaravan.
the class TabPageIndicator method setViewPager.
@Override
public void setViewPager(ViewPager view) {
if (mViewPager == view) {
return;
}
if (mViewPager != null) {
mViewPager.setOnPageChangeListener(null);
}
final PagerAdapter adapter = view.getAdapter();
if (adapter == null) {
throw new IllegalStateException("ViewPager does not have adapter instance.");
}
mViewPager = view;
view.setOnPageChangeListener(this);
notifyDataSetChanged();
}
Aggregations