Java Code Examples for androidx.core.view.ViewCompat#postInvalidateOnAnimation()

The following examples show how to use androidx.core.view.ViewCompat#postInvalidateOnAnimation() . 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: SliderPager.java    From Android-Image-Slider with Apache License 2.0 6 votes vote down vote up
@Override
public void computeScroll() {
    mIsScrollStarted = true;
    if (!mScroller.isFinished() && mScroller.computeScrollOffset()) {
        int oldX = getScrollX();
        int oldY = getScrollY();
        int x = mScroller.getCurrX();
        int y = mScroller.getCurrY();

        if (oldX != x || oldY != y) {
            scrollTo(x, y);
            if (!pageScrolled(x)) {
                mScroller.abortAnimation();
                scrollTo(0, y);
            }
        }

        // Keep on drawing until the animation has finished.
        ViewCompat.postInvalidateOnAnimation(this);
        return;
    }

    // Done with scroll, clean up state.
    completeScroll(true);
}
 
Example 2
Source File: DuoDrawerLayout.java    From duo-navigation-drawer with Apache License 2.0 6 votes vote down vote up
/**
 * Open the drawer animated.
 */
public void openDrawer() {
    int drawerWidth = (int) (getWidth() * mMarginFactor);
    if (drawerWidth == 0) {
        getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                DuoDrawerLayout.this.getViewTreeObserver().removeOnPreDrawListener(this);
                if (mViewDragHelper.smoothSlideViewTo(mContentView, ((int) (getWidth() * mMarginFactor)), mContentView.getTop())) {
                    ViewCompat.postInvalidateOnAnimation(DuoDrawerLayout.this);
                }
                return false;
            }
        });
    } else {
        if (mViewDragHelper.smoothSlideViewTo(mContentView, drawerWidth, mContentView.getTop())) {
            ViewCompat.postInvalidateOnAnimation(DuoDrawerLayout.this);
        }
    }
}
 
Example 3
Source File: TabLayout.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
void setIndicatorPosition(int left, int right) {
  if (left != indicatorLeft || right != indicatorRight) {
    // If the indicator's left/right has changed, invalidate
    indicatorLeft = left;
    indicatorRight = right;
    ViewCompat.postInvalidateOnAnimation(this);
  }
}
 
Example 4
Source File: SwipeLayout.java    From UltimateRecyclerView with Apache License 2.0 5 votes vote down vote up
@Override
public void computeScroll() {
    super.computeScroll();
    if (mDragHelper.continueSettling(true)) {
        ViewCompat.postInvalidateOnAnimation(this);
    }
}
 
Example 5
Source File: ParallaxScrimageView.java    From ShrinkingImageLayout with Apache License 2.0 5 votes vote down vote up
public void setOffset(float offset) {
    offset = Math.max(minOffset, offset);
    if (offset != getTranslationY()) {
        setTranslationY(offset);
        imageOffset = (int) (offset * parallaxFactor);
        setScrimAlpha(Math.min((-offset / getMinimumHeight()) * maxScrimAlpha, maxScrimAlpha));
        ViewCompat.postInvalidateOnAnimation(this);
    }
    setPinned(offset == minOffset);
}
 
Example 6
Source File: SlidingUpPanelLayout.java    From AndroidSlidingUpPanel with Apache License 2.0 5 votes vote down vote up
@Override
public void computeScroll() {
    if (mDragHelper != null && mDragHelper.continueSettling(true)) {
        if (!isEnabled()) {
            mDragHelper.abort();
            return;
        }

        ViewCompat.postInvalidateOnAnimation(this);
    }
}
 
Example 7
Source File: RangeSlider.java    From rn-range-slider with MIT License 5 votes vote down vote up
public void setMinValue(long minValue) {
    if (minValue <= maxValue) {
        this.minValue = minValue;
        fitToMinMax();
    }
    ViewCompat.postInvalidateOnAnimation(this);
}
 
Example 8
Source File: SwipeBackLayout.java    From pandora with Apache License 2.0 5 votes vote down vote up
@Override
public void computeScroll() {
    mScrimOpacity = 1 - mScrollPercent;
    if (mScrimOpacity >= 0) {
        if (mHelper.continueSettling(true)) {
            ViewCompat.postInvalidateOnAnimation(this);
        }
    }
}
 
Example 9
Source File: InkPageIndicator.java    From GeometricWeather with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void setJoiningFraction(int leftDot, float fraction) {
    if (leftDot < joiningFractions.length) {

        if (leftDot == 1) {
            //Log.d("PageIndicator", "dot 1 fraction:\t" + fraction);
        }

        joiningFractions[leftDot] = fraction;
        ViewCompat.postInvalidateOnAnimation(this);
    }
}
 
Example 10
Source File: TabLayout.java    From a with GNU General Public License v3.0 5 votes vote down vote up
void setIndicatorPosition(int left, int right) {
    if (left != mIndicatorLeft || right != mIndicatorRight) {
        // If the indicator's left/right has changed, invalidate
        mIndicatorLeft = left;
        mIndicatorRight = right;
        ViewCompat.postInvalidateOnAnimation(this);
    }
}
 
Example 11
Source File: SlideInContactsLayout.java    From toktok-android with GNU General Public License v3.0 5 votes vote down vote up
private void smoothSlideTo(Float slideOffset) {
    int topBound = getPaddingTop();
    int y = (int) (topBound + slideOffset * mDragRange);
    if (mDragHelper.smoothSlideViewTo(mCoordinator, mCoordinator.getLeft(), y)) {
        ViewCompat.postInvalidateOnAnimation(this);
    }
}
 
Example 12
Source File: SlidingUpPanelLayout.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
@Override
public void computeScroll() {
    if (mDragHelper != null && mDragHelper.continueSettling(true)) {
        if (!isEnabled()) {
            mDragHelper.abort();
            return;
        }

        ViewCompat.postInvalidateOnAnimation(this);
    }
}
 
Example 13
Source File: CollapsingTextHelper.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
private void setExpandedTextBlend(float blend) {
  expandedTextBlend = blend;
  ViewCompat.postInvalidateOnAnimation(view);
}
 
Example 14
Source File: RangeSlider.java    From rn-range-slider with MIT License 4 votes vote down vote up
public void setLineWidth(float lineWidth) {
    lineWidth = dpToPx(lineWidth);
    selectionPaint.setStrokeWidth(lineWidth);
    blankPaint.setStrokeWidth(lineWidth);
    ViewCompat.postInvalidateOnAnimation(this);
}
 
Example 15
Source File: RangeSlider.java    From rn-range-slider with MIT License 4 votes vote down vote up
public void setLabelPadding(float labelPadding) {
    this.labelPadding = dpToPx(labelPadding);
    ViewCompat.postInvalidateOnAnimation(this);
}
 
Example 16
Source File: TabLayout.java    From material-components-android with Apache License 2.0 4 votes vote down vote up
void setSelectedIndicatorHeight(int height) {
  if (selectedIndicatorHeight != height) {
    selectedIndicatorHeight = height;
    ViewCompat.postInvalidateOnAnimation(this);
  }
}
 
Example 17
Source File: AnimatedSvgView.java    From AnimatedSvgView with Apache License 2.0 4 votes vote down vote up
/**
 * Reset the animation
 */
public void reset() {
  mStartTime = 0;
  changeState(STATE_NOT_STARTED);
  ViewCompat.postInvalidateOnAnimation(this);
}
 
Example 18
Source File: SwipeProgressBar.java    From HaoReader with GNU General Public License v3.0 4 votes vote down vote up
void setTriggerPercentage(float triggerPercentage) {
    this.mTriggerPercentage = triggerPercentage;
    this.mStartTime = 0L;
    ViewCompat.postInvalidateOnAnimation(this.mParent);
}
 
Example 19
Source File: TabLayout.java    From material-components-android with Apache License 2.0 3 votes vote down vote up
/**
 * Set the indicator gravity used to align the tab selection indicator in the {@link TabLayout}.
 * You must set the indicator height via the custom indicator drawable's intrinsic height
 * (preferred), via the {@code tabIndicatorHeight} attribute (deprecated), or via {@link
 * #setSelectedTabIndicatorHeight(int)} (deprecated). Otherwise, the indicator will not be shown
 * unless gravity is set to {@link #INDICATOR_GRAVITY_STRETCH}, in which case it will ignore
 * indicator height and stretch across the entire height and width of the {@link TabLayout}. This
 * defaults to {@link #INDICATOR_GRAVITY_BOTTOM} if not set.
 *
 * @param indicatorGravity one of {@link #INDICATOR_GRAVITY_BOTTOM}, {@link
 *     #INDICATOR_GRAVITY_CENTER}, {@link #INDICATOR_GRAVITY_TOP}, or {@link
 *     #INDICATOR_GRAVITY_STRETCH}
 * @attr ref com.google.android.material.R.styleable#TabLayout_tabIndicatorGravity
 */
public void setSelectedTabIndicatorGravity(@TabIndicatorGravity int indicatorGravity) {
  if (tabIndicatorGravity != indicatorGravity) {
    tabIndicatorGravity = indicatorGravity;
    ViewCompat.postInvalidateOnAnimation(slidingTabIndicator);
  }
}
 
Example 20
Source File: TabLayout.java    From material-components-android with Apache License 2.0 2 votes vote down vote up
/**
 * Enable or disable option to fit the tab selection indicator to the full width of the tab item
 * rather than to the tab item's content.
 *
 * <p>Defaults to true. If set to false and the tab item has a text label, the selection indicator
 * width will be set to the width of the text label. If the tab item has no text label, but does
 * have an icon, the selection indicator width will be set to the icon. If the tab item has
 * neither of these, or if the calculated width is less than a minimum width value, the selection
 * indicator width will be set to the minimum width value.
 *
 * @param tabIndicatorFullWidth Whether or not to fit selection indicator width to full width of
 *     the tab item
 * @attr ref com.google.android.material.R.styleable#TabLayout_tabIndicatorFullWidth
 * @see #isTabIndicatorFullWidth()
 */
public void setTabIndicatorFullWidth(boolean tabIndicatorFullWidth) {
  this.tabIndicatorFullWidth = tabIndicatorFullWidth;
  ViewCompat.postInvalidateOnAnimation(slidingTabIndicator);
}