Search in sources :

Example 21 with PagerAdapter

use of android.support.v4.view.PagerAdapter in project musicbrainz-android by jdamcd.

the class ReleaseActivity method configurePager.

private void configurePager() {
    pagerAdapter = new ReleasePagerAdapter(getSupportFragmentManager());
    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(pagerAdapter);
    TabPageIndicator indicator = (TabPageIndicator) findViewById(R.id.indicator);
    indicator.setViewPager(pager);
    pager.setOffscreenPageLimit(pagerAdapter.getCount() - 1);
}
Also used : ReleasePagerAdapter(org.musicbrainz.mobile.adapter.pager.ReleasePagerAdapter) TabPageIndicator(com.viewpagerindicator.TabPageIndicator) ViewPager(android.support.v4.view.ViewPager)

Example 22 with PagerAdapter

use of android.support.v4.view.PagerAdapter in project FastDev4Android by jiangqqlmj.

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 23 with PagerAdapter

use of android.support.v4.view.PagerAdapter in project ProductTour by matrixxun.

the class ProductTour3Activity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Window window = getWindow();
    window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    setContentView(R.layout.activity_tutorial);
    skip = Button.class.cast(findViewById(R.id.skip));
    skip.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            endTutorial();
        }
    });
    next = ImageButton.class.cast(findViewById(R.id.next));
    next.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pager.setCurrentItem(pager.getCurrentItem() + 1, true);
        }
    });
    done = Button.class.cast(findViewById(R.id.done));
    done.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            endTutorial();
        }
    });
    pager = (ViewPager) findViewById(R.id.pager);
    pagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
    pager.setAdapter(pagerAdapter);
    pager.setPageTransformer(true, new CrossfadePageTransformer());
    pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            if (position == NUM_PAGES - 2 && positionOffset > 0) {
                if (isOpaque) {
                    pager.setBackgroundColor(Color.TRANSPARENT);
                    isOpaque = false;
                }
            } else {
                if (!isOpaque) {
                    pager.setBackgroundColor(getResources().getColor(R.color.primary_material_light));
                    isOpaque = true;
                }
            }
        }

        @Override
        public void onPageSelected(int position) {
            setIndicator(position);
            if (position == NUM_PAGES - 2) {
                skip.setVisibility(View.GONE);
                next.setVisibility(View.GONE);
                done.setVisibility(View.VISIBLE);
            } else if (position < NUM_PAGES - 2) {
                skip.setVisibility(View.VISIBLE);
                next.setVisibility(View.VISIBLE);
                done.setVisibility(View.GONE);
            } else if (position == NUM_PAGES - 1) {
                endTutorial();
            }
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    buildCircles();
}
Also used : Window(android.view.Window) ImageButton(android.widget.ImageButton) ImageButton(android.widget.ImageButton) Button(android.widget.Button) ImageView(android.widget.ImageView) View(android.view.View) ViewPager(android.support.v4.view.ViewPager)

Example 24 with PagerAdapter

use of android.support.v4.view.PagerAdapter in project ProductTour by matrixxun.

the class ProductTourActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Window window = getWindow();
    window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    setContentView(R.layout.activity_tutorial);
    skip = Button.class.cast(findViewById(R.id.skip));
    skip.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            endTutorial();
        }
    });
    next = ImageButton.class.cast(findViewById(R.id.next));
    next.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pager.setCurrentItem(pager.getCurrentItem() + 1, true);
        }
    });
    done = Button.class.cast(findViewById(R.id.done));
    done.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            endTutorial();
        }
    });
    pager = (ViewPager) findViewById(R.id.pager);
    pagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
    pager.setAdapter(pagerAdapter);
    pager.setPageTransformer(true, new CrossfadePageTransformer());
    pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            if (position == NUM_PAGES - 2 && positionOffset > 0) {
                if (isOpaque) {
                    pager.setBackgroundColor(Color.TRANSPARENT);
                    isOpaque = false;
                }
            } else {
                if (!isOpaque) {
                    pager.setBackgroundColor(getResources().getColor(R.color.primary_material_light));
                    isOpaque = true;
                }
            }
        }

        @Override
        public void onPageSelected(int position) {
            setIndicator(position);
            if (position == NUM_PAGES - 2) {
                skip.setVisibility(View.GONE);
                next.setVisibility(View.GONE);
                done.setVisibility(View.VISIBLE);
            } else if (position < NUM_PAGES - 2) {
                skip.setVisibility(View.VISIBLE);
                next.setVisibility(View.VISIBLE);
                done.setVisibility(View.GONE);
            } else if (position == NUM_PAGES - 1) {
                endTutorial();
            }
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    buildCircles();
}
Also used : Window(android.view.Window) ImageButton(android.widget.ImageButton) ImageButton(android.widget.ImageButton) Button(android.widget.Button) ImageView(android.widget.ImageView) View(android.view.View) ViewPager(android.support.v4.view.ViewPager) SuppressLint(android.annotation.SuppressLint)

Example 25 with PagerAdapter

use of android.support.v4.view.PagerAdapter in project MaterialTabs by neokree.

the class IconTabActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_icons);
    res = this.getResources();
    // init toolbar (old action bar)
    Toolbar toolbar = (Toolbar) this.findViewById(R.id.toolbar);
    toolbar.setTitleTextColor(Color.WHITE);
    this.setSupportActionBar(toolbar);
    tabHost = (MaterialTabHost) this.findViewById(R.id.tabHost);
    pager = (ViewPager) this.findViewById(R.id.pager);
    // init view pager
    pagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
    pager.setAdapter(pagerAdapter);
    pager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            // when user do a swipe the selected tab change
            tabHost.setSelectedNavigationItem(position);
        }
    });
    // insert all tabs from pagerAdapter data
    for (int i = 0; i < pagerAdapter.getCount(); i++) {
        tabHost.addTab(tabHost.newTab().setIcon(getIcon(i)).setTabListener(this));
    }
}
Also used : ViewPager(android.support.v4.view.ViewPager) Toolbar(android.support.v7.widget.Toolbar)

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