Search in sources :

Example 1 with TabPageIndicator

use of in.srain.cube.views.pager.TabPageIndicator in project android-Ultra-Pull-To-Refresh by liaohuqiu.

the class ViewPagerActivity method initCateViews.

private void initCateViews() {
    int startIndex = 0;
    mCatTabPageIndicator = (TabPageIndicator) findViewById(R.id.view_pager_tab_indicator);
    mFragmentViewPager = (ViewPager) this.findViewById(R.id.view_pager_view_pager);
    ArrayList<ViewPagerFragment> list = new ArrayList<ViewPagerFragment>();
    for (int i = 1; i <= 8; i++) {
        list.add(ViewPagerFragment.create(i));
    }
    mPagerAdapter = new FragmentViewPagerAdapter(getSupportFragmentManager(), list);
    mFragmentViewPager.setAdapter(mPagerAdapter);
    mCatTabPageIndicator.setViewHolderCreator(new TabPageIndicator.ViewHolderCreator() {

        @Override
        public TabPageIndicator.ViewHolderBase createViewHolder() {
            return new HomeCatItemViewHolder();
        }
    });
    mCatTabPageIndicator.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int i) {
            switchTo(i);
        }
    });
    mCatTabPageIndicator.setViewPager(mFragmentViewPager);
    mPtrFrame = (PtrClassicFrameLayout) findViewById(R.id.view_pager_ptr_frame);
    mPtrFrame.disableWhenHorizontalMove(true);
    mPtrFrame.setPtrHandler(new PtrHandler() {

        @Override
        public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
            return mPagerAdapter.checkCanDoRefresh();
        }

        @Override
        public void onRefreshBegin(PtrFrameLayout frame) {
            mPagerAdapter.updateData();
        }
    });
    mFragmentViewPager.setCurrentItem(startIndex);
}
Also used : TabPageIndicator(in.srain.cube.views.pager.TabPageIndicator) PtrHandler(in.srain.cube.views.ptr.PtrHandler) PtrFrameLayout(in.srain.cube.views.ptr.PtrFrameLayout) ArrayList(java.util.ArrayList) ViewPager(android.support.v4.view.ViewPager) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

ViewPager (android.support.v4.view.ViewPager)1 View (android.view.View)1 AbsListView (android.widget.AbsListView)1 TextView (android.widget.TextView)1 TabPageIndicator (in.srain.cube.views.pager.TabPageIndicator)1 PtrFrameLayout (in.srain.cube.views.ptr.PtrFrameLayout)1 PtrHandler (in.srain.cube.views.ptr.PtrHandler)1 ArrayList (java.util.ArrayList)1