Java Code Examples for android.support.v4.view.ViewPager#removeOnPageChangeListener()

The following examples show how to use android.support.v4.view.ViewPager#removeOnPageChangeListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StepperIndicator.java    From stepper-indicator with MIT License 6 votes vote down vote up
/**
 * Set the {@link ViewPager} associated with this widget indicator.
 *
 * @param pager     {@link ViewPager} to attach
 * @param stepCount The real page count to display (use this if you are using looped viewpager to indicate the real
 *                  number
 *                  of pages)
 */
public void setViewPager(ViewPager pager, int stepCount) {
    if (this.pager == pager) {
        return;
    }
    if (this.pager != null) {
        pager.removeOnPageChangeListener(this);
    }
    if (pager.getAdapter() == null) {
        throw new IllegalStateException("ViewPager does not have adapter instance.");
    }

    this.pager = pager;
    this.stepCount = stepCount;
    currentStep = 0;
    pager.addOnPageChangeListener(this);

    if (showLabels && labels == null) {
        setLabelsUsingPageTitles();
    }

    requestLayout();
    invalidate();
}
 
Example 2
Source File: CirclePageIndicator.java    From JianshuApp with GNU General Public License v3.0 6 votes vote down vote up
public void setViewPager(ViewPager vp) {
    if (isValid(vp)) {
        this.vp = vp;
        this.count = vp.getAdapter().getCount();
        vp.removeOnPageChangeListener(this);
        vp.addOnPageChangeListener(this);

        unselectDrawables.clear();
        unselectRects.clear();
        for (int i = 0; i < count; i++) {
            unselectDrawables.add(new GradientDrawable());
            unselectRects.add(new Rect());
        }

        invalidate();
    }
}
 
Example 3
Source File: CirclePageIndicator.java    From JianshuApp with GNU General Public License v3.0 6 votes vote down vote up
public void setViewPager(ViewPager vp, int realCount) {
    if (isValid(vp)) {
        this.vp = vp;
        this.count = realCount;
        vp.removeOnPageChangeListener(this);
        vp.addOnPageChangeListener(this);

        unselectDrawables.clear();
        unselectRects.clear();
        for (int i = 0; i < count; i++) {
            unselectDrawables.add(new GradientDrawable());
            unselectRects.add(new Rect());
        }

        invalidate();
    }
}
 
Example 4
Source File: RoundCornerIndicaor.java    From FlycoPageIndicator with MIT License 6 votes vote down vote up
@Override
public void setViewPager(ViewPager vp) {
    if (isValid(vp)) {
        this.vp = vp;
        this.count = vp.getAdapter().getCount();
        vp.removeOnPageChangeListener(this);
        vp.addOnPageChangeListener(this);

        unselectDrawables.clear();
        unselectRects.clear();
        for (int i = 0; i < count; i++) {
            unselectDrawables.add(new GradientDrawable());
            unselectRects.add(new Rect());
        }

        invalidate();
    }
}
 
Example 5
Source File: RoundCornerIndicaor.java    From FlycoPageIndicator with MIT License 6 votes vote down vote up
@Override
public void setViewPager(ViewPager vp, int realCount) {
    if (isValid(vp)) {
        this.vp = vp;
        this.count = realCount;
        vp.removeOnPageChangeListener(this);
        vp.addOnPageChangeListener(this);

        unselectDrawables.clear();
        unselectRects.clear();
        for (int i = 0; i < count; i++) {
            unselectDrawables.add(new GradientDrawable());
            unselectRects.add(new Rect());
        }

        invalidate();
    }
}
 
Example 6
Source File: DachshundTabLayout.java    From Dachshund-Tab-Layout with MIT License 5 votes vote down vote up
@Override
public void setupWithViewPager(@Nullable final ViewPager viewPager, boolean autoRefresh) {
    super.setupWithViewPager(viewPager, autoRefresh);

    //TODO
    if (viewPager != null) {
        viewPager.removeOnPageChangeListener(this);
        viewPager.addOnPageChangeListener(this);
    }
}
 
Example 7
Source File: StepperNavigationActions.java    From android-material-stepper with Apache License 2.0 5 votes vote down vote up
@Override
public final void perform(UiController uiController, View view) {
    final StepperLayout stepperLayout = (StepperLayout) view;
    final ViewPager viewPager = (ViewPager) stepperLayout.findViewById(com.stepstone.stepper.R.id.ms_stepPager);
    // Add a custom tracker listener
    final CustomViewPagerListener customListener = new CustomViewPagerListener();
    viewPager.addOnPageChangeListener(customListener);

    // Note that we're running the following block in a try-finally construct. This
    // is needed since some of the actions are going to throw (expected) exceptions. If that
    // happens, we still need to clean up after ourselves to leave the system (Espresso) in a good
    // state.
    try {
        // Register our listener as idling resource so that Espresso waits until the
        // wrapped action results in the view pager getting to the STATE_IDLE state
        Espresso.registerIdlingResources(customListener);

        uiController.loopMainThreadUntilIdle();

        performAction(stepperLayout);

        uiController.loopMainThreadUntilIdle();

        customListener.mNeedsIdle = true;
        uiController.loopMainThreadUntilIdle();
        customListener.mNeedsIdle = false;
    } finally {
        // Unregister our idling resource
        Espresso.unregisterIdlingResources(customListener);
        // And remove our tracker listener from ViewPager
        viewPager.removeOnPageChangeListener(customListener);
    }
}
 
Example 8
Source File: FlycoPageIndicaor.java    From FlycoPageIndicator with MIT License 5 votes vote down vote up
@Override
public void setViewPager(ViewPager vp) {
    this.vp = vp;
    if (isValid()) {
        this.count = vp.getAdapter().getCount();
        vp.removeOnPageChangeListener(this);
        vp.addOnPageChangeListener(this);

        createIndicators();
    }
}
 
Example 9
Source File: FlycoPageIndicaor.java    From FlycoPageIndicator with MIT License 5 votes vote down vote up
@Override
public void setViewPager(ViewPager vp, int realCount) {
    this.vp = vp;
    if (isValid()) {
        this.count = realCount;
        vp.removeOnPageChangeListener(this);
        vp.addOnPageChangeListener(this);

        createIndicators();
    }
}
 
Example 10
Source File: Spritz.java    From spritz with Apache License 2.0 4 votes vote down vote up
public void detachFrom(ViewPager viewPager) {
    viewPager.removeOnPageChangeListener(spritzOnPageChangeListener);
}
 
Example 11
Source File: ViewPagerIndicator.java    From bannerview with Apache License 2.0 4 votes vote down vote up
public void setupWithViewPager(ViewPager pager) {
    mItemCount = pager.getAdapter().getCount();
    pager.removeOnPageChangeListener(onPageChangeListener);
    pager.addOnPageChangeListener(onPageChangeListener);
    requestLayout();
}
 
Example 12
Source File: PagerIndicator.java    From oneHookLibraryAndroid with Apache License 2.0 4 votes vote down vote up
public void removeViewPager(final ViewPager viewPager) {
    if (viewPager != null) {
        viewPager.removeOnPageChangeListener(this);
    }
}