com.heinrichreimersoftware.materialintro.util.AnimUtils Java Examples

The following examples show how to use com.heinrichreimersoftware.materialintro.util.AnimUtils. 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: InkPageIndicator.java    From material-intro with MIT License 5 votes vote down vote up
public InkPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final int density = (int) context.getResources().getDisplayMetrics().density;

    // Load attributes
    final TypedArray a = getContext().obtainStyledAttributes(
            attrs, R.styleable.InkPageIndicator, defStyle, 0);

    dotDiameter = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotDiameter,
            DEFAULT_DOT_SIZE * density);
    dotRadius = dotDiameter / 2;
    halfDotRadius = dotRadius / 2;
    gap = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotGap,
            DEFAULT_GAP * density);
    animDuration = (long) a.getInteger(R.styleable.InkPageIndicator_animationDuration,
            DEFAULT_ANIM_DURATION);
    animHalfDuration = animDuration / 2;
    unselectedColour = a.getColor(R.styleable.InkPageIndicator_pageIndicatorColor,
            DEFAULT_UNSELECTED_COLOUR);
    selectedColour = a.getColor(R.styleable.InkPageIndicator_currentPageIndicatorColor,
            DEFAULT_SELECTED_COLOUR);

    a.recycle();

    unselectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    unselectedPaint.setColor(unselectedColour);
    selectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    selectedPaint.setColor(selectedColour);
    interpolator = AnimUtils.getFastOutSlowInInterpolator(context);

    // create paths & rect now – reuse & rewind later
    combinedUnselectedPath = new Path();
    unselectedDotPath = new Path();
    unselectedDotLeftPath = new Path();
    unselectedDotRightPath = new Path();
    rectF = new RectF();

    addOnAttachStateChangeListener(this);
}
 
Example #3
Source File: InkPageIndicator.java    From Puff-Android with MIT License 5 votes vote down vote up
public InkPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final int density = (int) context.getResources().getDisplayMetrics().density;

    // Load attributes
    final TypedArray a = getContext().obtainStyledAttributes(
            attrs, R.styleable.InkPageIndicator, defStyle, 0);

    dotDiameter = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotDiameter,
            DEFAULT_DOT_SIZE * density);
    dotRadius = dotDiameter / 2;
    halfDotRadius = dotRadius / 2;
    gap = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotGap,
            DEFAULT_GAP * density);
    animDuration = (long) a.getInteger(R.styleable.InkPageIndicator_animationDuration,
            DEFAULT_ANIM_DURATION);
    animHalfDuration = animDuration / 2;
    int unselectedColor = a.getColor(R.styleable.InkPageIndicator_pageIndicatorColor,
            DEFAULT_UNSELECTED_COLOUR);
    int selectedColor = a.getColor(R.styleable.InkPageIndicator_currentPageIndicatorColor,
            DEFAULT_SELECTED_COLOUR);

    a.recycle();

    unselectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    unselectedPaint.setColor(unselectedColor);
    selectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    selectedPaint.setColor(selectedColor);
    interpolator = AnimUtils.getFastOutSlowInInterpolator(context);

    // create paths & rect now – reuse & rewind later
    combinedUnselectedPath = new Path();
    unselectedDotPath = new Path();
    unselectedDotLeftPath = new Path();
    unselectedDotRightPath = new Path();
    rectF = new RectF();

    addOnAttachStateChangeListener(this);
}
 
Example #4
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 #5
Source File: InkPageIndicator.java    From Prodigal with Apache License 2.0 5 votes vote down vote up
public InkPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final int density = (int) context.getResources().getDisplayMetrics().density;

    // Load attributes
    final TypedArray a = getContext().obtainStyledAttributes(
            attrs, R.styleable.InkPageIndicator, defStyle, 0);

    dotDiameter = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotDiameter,
            DEFAULT_DOT_SIZE * density);
    dotRadius = dotDiameter / 2;
    halfDotRadius = dotRadius / 2;
    gap = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotGap,
            DEFAULT_GAP * density);
    animDuration = (long) a.getInteger(R.styleable.InkPageIndicator_animationDuration,
            DEFAULT_ANIM_DURATION);
    animHalfDuration = animDuration / 2;
    unselectedColour = a.getColor(R.styleable.InkPageIndicator_pageIndicatorColor,
            DEFAULT_UNSELECTED_COLOUR);
    selectedColour = a.getColor(R.styleable.InkPageIndicator_currentPageIndicatorColor,
            DEFAULT_SELECTED_COLOUR);

    a.recycle();

    unselectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    unselectedPaint.setColor(unselectedColour);
    selectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    selectedPaint.setColor(selectedColour);
    interpolator = AnimUtils.getFastOutSlowInInterpolator(context);

    // create paths & rect now – reuse & rewind later
    combinedUnselectedPath = new Path();
    unselectedDotPath = new Path();
    unselectedDotLeftPath = new Path();
    unselectedDotRightPath = new Path();
    rectF = new RectF();

    addOnAttachStateChangeListener(this);
}
 
Example #6
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 #7
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 #8
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;
}