Java Code Examples for com.heinrichreimersoftware.materialintro.util.AnimUtils#applyShakeAnimation()

The following examples show how to use com.heinrichreimersoftware.materialintro.util.AnimUtils#applyShakeAnimation() . 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: IntroActivity.java    From Puff-Android with MIT License 6 votes vote down vote up
public void nextSlide() {
    int currentItem = pager.getCurrentItem();
    if (currentItem == pager.getAdapter().getCount() - 1) {
        position += 1;
        finishIfNeeded();
        return;
    }
    if (canGoForward(currentItem, true)) {
        if (this.slideListener != null)
            slideListener.willLeaveSlide(currentItem);
        pager.setCurrentItem(++currentItem, true);
    }
    else {
        AnimUtils.applyShakeAnimation(this, buttonNext);

    }
}
 
Example 2
Source File: IntroActivity.java    From Puff-Android with MIT License 5 votes vote down vote up
public void previousSlide() {
    int currentItem = pager.getCurrentItem();

    if (canGoBackward(currentItem, true)) {
        if (this.slideListener != null)
            slideListener.willLeaveSlide(currentItem);
        pager.setCurrentItem(--currentItem, true);
    }
    else {
        AnimUtils.applyShakeAnimation(this, buttonSkip);

    }
}
 
Example 3
Source File: IntroActivity.java    From Prodigal with Apache License 2.0 5 votes vote down vote up
public void nextSlide() {
    int currentItem = pager.getCurrentItem();
    if (currentItem > adapter.getCount() - 1) finishIfNeeded();

    if (canGoForward(currentItem, true)) {
        smoothScrollPagerTo(++currentItem);
    }
    else {
        AnimUtils.applyShakeAnimation(this, buttonNext);
    }
}
 
Example 4
Source File: IntroActivity.java    From Prodigal with Apache License 2.0 5 votes vote down vote up
public void previousSlide() {
    int currentItem = pager.getCurrentItem();
    if (currentItem <= 0) return;

    if (canGoBackward(currentItem, true)) {
        smoothScrollPagerTo(--currentItem);
    }
    else {
        AnimUtils.applyShakeAnimation(this, buttonBack);

    }
}
 
Example 5
Source File: IntroActivity.java    From material-intro with MIT License 4 votes vote down vote up
@Override
public boolean goToSlide(int position) {
    int lastPosition = miPager.getCurrentItem();

    if (lastPosition >= adapter.getCount()) {
        finishIfNeeded();
    }

    int newPosition = lastPosition;

    position = Math.max(0, Math.min(position, getCount()));

    if (position > lastPosition) {
        // Go forward
        while (newPosition < position && canGoForward(newPosition, true)) {
            newPosition++;
        }
    } else if (position < lastPosition) {
        // Go backward
        while (newPosition > position && canGoBackward(newPosition, true)) {
            newPosition--;
        }
    } else {
        // Noting to do here
        return true;
    }

    boolean blocked = false;
    if (newPosition != position) {
        // Could not go the complete way to the given position.
        blocked = true;

        if (position > lastPosition) {
            AnimUtils.applyShakeAnimation(this, miButtonNext);
        } else if (position < lastPosition) {
            AnimUtils.applyShakeAnimation(this, miButtonBack);
        }
    }

    // Scroll to new position
    smoothScrollPagerTo(newPosition);

    return !blocked;
}