Search in sources :

Example 16 with PagerAdapter

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);
        }
    }
}
Also used : PagerAdapter(android.support.v4.view.PagerAdapter)

Example 17 with PagerAdapter

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();
}
Also used : PagerAdapter(android.support.v4.view.PagerAdapter)

Example 18 with PagerAdapter

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();
}
Also used : PagerAdapter(android.support.v4.view.PagerAdapter)

Example 19 with PagerAdapter

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();
}
Also used : PagerAdapter(android.support.v4.view.PagerAdapter)

Example 20 with PagerAdapter

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);
}
Also used : TabPageIndicator(com.viewpagerindicator.TabPageIndicator) ArtistPagerAdapter(org.musicbrainz.mobile.adapter.pager.ArtistPagerAdapter) ViewPager(android.support.v4.view.ViewPager)

Aggregations

PagerAdapter (android.support.v4.view.PagerAdapter)111 View (android.view.View)47 ViewPager (android.support.v4.view.ViewPager)39 TextView (android.widget.TextView)33 HorizontalScrollView (android.widget.HorizontalScrollView)19 ViewGroup (android.view.ViewGroup)18 LinearLayout (android.widget.LinearLayout)13 Toolbar (android.support.v7.widget.Toolbar)11 ImageView (android.widget.ImageView)11 TabLayout (android.support.design.widget.TabLayout)8 RecyclerView (android.support.v7.widget.RecyclerView)8 ArrayList (java.util.ArrayList)8 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)6 AppBarLayout (android.support.design.widget.AppBarLayout)5 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)5 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)5 ImageButton (android.widget.ImageButton)5 LargeTest (android.support.test.filters.LargeTest)4 MediumTest (android.support.test.filters.MediumTest)4 SmallTest (android.support.test.filters.SmallTest)4