Search in sources :

Example 26 with PagerAdapter

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

Example 27 with PagerAdapter

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

Example 28 with PagerAdapter

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

Example 29 with PagerAdapter

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

Example 30 with PagerAdapter

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

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