use of android.support.v4.view.PagerAdapter in project LuaViewSDK by alibaba.
the class AutoScrollViewPager method scrollOnce.
/**
* scroll only once
*/
public void scrollOnce() {
PagerAdapter adapter = getAdapter();
int realPosition = getCurrentItem();
int realCount;
if (adapter == null || (realCount = getRealCount()) <= 1) {
return;
}
//调整方向
if (reverseDirection) {
if (direction == RIGHT && realPosition + 1 >= realCount) {
direction = LEFT;
} else if (direction == LEFT && realPosition - 1 < 0) {
direction = RIGHT;
}
}
if (isLooping()) {
setCurrentItem(direction == LEFT ? (realPosition - 1) % getCount() : (realPosition + 1) % getCount(), true);
} else {
int nextItem = (direction == LEFT) ? --realPosition : ++realPosition;
if (nextItem < 0) {
setCurrentItem(realCount - 1, true);
} else if (nextItem == realCount) {
setCurrentItem(0, true);
} else {
setCurrentItem(nextItem, true);
}
}
}
use of android.support.v4.view.PagerAdapter in project LuaViewSDK by alibaba.
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();
}
use of android.support.v4.view.PagerAdapter in project LuaViewSDK by alibaba.
the class LVCustomViewPagerIndicator method setViewPager.
@Override
public void setViewPager(ViewPager view) {
if (mViewPager == view) {
return;
}
if (mViewPager != null) {
mViewPager.setOnPageChangeListener(null);
}
PagerAdapter adapter = view.getAdapter();
if (adapter == null) {
throw new IllegalStateException("ViewPager does not have adapter instance.");
}
mViewPager = view;
view.setOnPageChangeListener(this);
notifyDataSetChanged();
}
use of android.support.v4.view.PagerAdapter in project SmartAndroidSource by jaychou2012.
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 musicbrainz-android by jdamcd.
the class ArtistActivity method configurePager.
private void configurePager() {
pagerAdapter = new ArtistPagerAdapter(getSupportFragmentManager());
ViewPager pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(pagerAdapter);
TabPageIndicator indicator = (TabPageIndicator) findViewById(R.id.indicator);
indicator.setViewPager(pager);
pager.setCurrentItem(1);
pager.setOffscreenPageLimit(pagerAdapter.getCount() - 1);
}
Aggregations