List of usage examples for android.graphics Canvas restoreToCount
public void restoreToCount(int saveCount)
From source file:com.aliasapps.seq.scroller.TwoWayView.java
private boolean drawEndEdge(Canvas canvas) { if (mEndEdge.isFinished()) { return false; }/*from w w w . ja va2 s .c o m*/ final int restoreCount = canvas.save(); final int width = getWidth() - getPaddingLeft() - getPaddingRight(); final int height = getHeight() - getPaddingTop() - getPaddingBottom(); if (mIsVertical) { canvas.translate(-width, height); canvas.rotate(180, width, 0); } else { canvas.translate(width, 0); canvas.rotate(90); } final boolean needsInvalidate = mEndEdge.draw(canvas); canvas.restoreToCount(restoreCount); return needsInvalidate; }
From source file:com.appunite.list.AbsHorizontalListView.java
@Override public void draw(Canvas canvas) { super.draw(canvas); if (mEdgeGlowLeft != null) { final int scrollX = getScrollX(); boolean needsInvalidate = false; if (!mEdgeGlowLeft.isFinished()) { final int restoreCount = canvas.save(); final int topPadding = mListPadding.top + mGlowPaddingTop; final int bottomPadding = mListPadding.bottom + mGlowPaddingBottom; final int height = getHeight() - topPadding - bottomPadding; int edgeX = Math.min(0, scrollX + mFirstPositionDistanceGuess); canvas.translate(edgeX, height + topPadding); canvas.rotate(-90, 0, 0);//from w ww . jav a 2s. c o m mEdgeGlowLeft.setSize(height, getWidth()); if (mEdgeGlowLeft.draw(canvas)) { needsInvalidate = true; } canvas.restoreToCount(restoreCount); } if (!mEdgeGlowRight.isFinished()) { final int restoreCount = canvas.save(); final int topPadding = mListPadding.top + mGlowPaddingTop; final int bottomPadding = mListPadding.bottom + mGlowPaddingBottom; final int height = getHeight() - topPadding - bottomPadding; final int width = getWidth(); int edgeY = topPadding; int edgeX = Math.max(width, scrollX + mLastPositionDistanceGuess); canvas.translate(edgeX, edgeY); canvas.rotate(90, 0, 0); mEdgeGlowRight.setSize(height, width); if (mEdgeGlowRight.draw(canvas)) { needsInvalidate = true; } canvas.restoreToCount(restoreCount); } if (needsInvalidate) { invalidate(); } } }
From source file:com.appunite.list.AbsListView.java
@Override public void draw(Canvas canvas) { super.draw(canvas); if (mEdgeGlowTop != null) { final int scrollY = getScrollY(); boolean needsInvalidate = false; if (!mEdgeGlowTop.isFinished()) { final int restoreCount = canvas.save(); final int leftPadding = mListPadding.left + mGlowPaddingLeft; final int rightPadding = mListPadding.right + mGlowPaddingRight; final int width = getWidth() - leftPadding - rightPadding; int edgeY = Math.min(0, scrollY + mFirstPositionDistanceGuess); canvas.translate(leftPadding, edgeY); mEdgeGlowTop.setSize(width, getHeight()); if (mEdgeGlowTop.draw(canvas)) { needsInvalidate = true;//from w w w . j a v a2 s .c o m } canvas.restoreToCount(restoreCount); } if (!mEdgeGlowBottom.isFinished()) { final int restoreCount = canvas.save(); final int leftPadding = mListPadding.left + mGlowPaddingLeft; final int rightPadding = mListPadding.right + mGlowPaddingRight; final int width = getWidth() - leftPadding - rightPadding; final int height = getHeight(); int edgeX = -width + leftPadding; int edgeY = Math.max(height, scrollY + mLastPositionDistanceGuess); canvas.translate(edgeX, edgeY); canvas.rotate(180, width, 0); mEdgeGlowBottom.setSize(width, height); if (mEdgeGlowBottom.draw(canvas)) { needsInvalidate = true; } canvas.restoreToCount(restoreCount); } if (needsInvalidate) { invalidate(); } } if (mFastScroller != null) { final int scrollY = getScrollY(); if (scrollY != 0) { // Pin to the top/bottom during overscroll int restoreCount = canvas.save(); canvas.translate(0, (float) scrollY); mFastScroller.draw(canvas); canvas.restoreToCount(restoreCount); } else { mFastScroller.draw(canvas); } } }
From source file:com.appunite.list.AbsHorizontalListView.java
@Override protected void dispatchDraw(Canvas canvas) { int saveCount = 0; final boolean clipToPadding = mClipToPadding; if (clipToPadding) { saveCount = canvas.save();// www.j a va2s. c o m final int scrollX = getScrollX(); final int scrollY = getScrollY(); final int paddingLeft = getPaddingLeft(); final int paddingTop = getPaddingTop(); final int paddingRight = getPaddingRight(); final int paddingBottom = getPaddingBottom(); final int left = getLeft(); final int top = getTop(); final int right = getRight(); final int bottom = getBottom(); canvas.clipRect(scrollX + paddingLeft, scrollY + paddingTop, scrollX + right - left - paddingRight, scrollY + bottom - top - paddingBottom); setClipToPadding(false); } final boolean drawSelectorOnTop = mDrawSelectorOnTop; if (!drawSelectorOnTop) { drawSelector(canvas); } super.dispatchDraw(canvas); if (drawSelectorOnTop) { drawSelector(canvas); } if (clipToPadding) { canvas.restoreToCount(saveCount); setClipToPadding(true); } }
From source file:com.artifex.mupdflib.TwoWayView.java
private boolean drawStartEdge(Canvas canvas) { if (mStartEdge.isFinished()) { return false; }/*ww w .j av a 2s . c om*/ if (mIsVertical) { return mStartEdge.draw(canvas); } final int restoreCount = canvas.save(); final int height = getHeight(); canvas.translate(0, height); canvas.rotate(270); final boolean needsInvalidate = mStartEdge.draw(canvas); canvas.restoreToCount(restoreCount); return needsInvalidate; }
From source file:com.artifex.mupdflib.TwoWayView.java
private boolean drawEndEdge(Canvas canvas) { if (mEndEdge.isFinished()) { return false; }/* www. j ava 2 s. c o m*/ final int restoreCount = canvas.save(); final int width = getWidth(); final int height = getHeight(); if (mIsVertical) { canvas.translate(-width, height); canvas.rotate(180, width, 0); } else { canvas.translate(width, 0); canvas.rotate(90); } final boolean needsInvalidate = mEndEdge.draw(canvas); canvas.restoreToCount(restoreCount); return needsInvalidate; }
From source file:android.support.v7.widget.RecyclerViewEx.java
@Override public void draw(Canvas c) { super.draw(c); final int count = mItemDecorations.size(); for (int i = 0; i < count; i++) { mItemDecorations.get(i).onDrawOver(c, this, mState); }//from w w w .j a v a2s. co m // TODO If padding is not 0 and chilChildrenToPadding is false, to draw glows properly, we // need find children closest to edges. Not sure if it is worth the effort. boolean needsInvalidate = false; if (mLeftGlow != null && !mLeftGlow.isFinished()) { final int restore = c.save(); final int padding = mClipToPadding ? getPaddingBottom() : 0; c.rotate(270); c.translate(-getHeight() + padding, 0); needsInvalidate = mLeftGlow != null && mLeftGlow.draw(c); c.restoreToCount(restore); } if (mTopGlow != null && !mTopGlow.isFinished()) { final int restore = c.save(); if (mClipToPadding) { c.translate(getPaddingLeft(), getPaddingTop()); } needsInvalidate |= mTopGlow != null && mTopGlow.draw(c); c.restoreToCount(restore); } if (mRightGlow != null && !mRightGlow.isFinished()) { final int restore = c.save(); final int width = getWidth(); final int padding = mClipToPadding ? getPaddingTop() : 0; c.rotate(90); c.translate(-padding, -width); needsInvalidate |= mRightGlow != null && mRightGlow.draw(c); c.restoreToCount(restore); } if (mBottomGlow != null && !mBottomGlow.isFinished()) { final int restore = c.save(); c.rotate(180); if (mClipToPadding) { c.translate(-getWidth() + getPaddingRight(), -getHeight() + getPaddingBottom()); } else { c.translate(-getWidth(), -getHeight()); } needsInvalidate |= mBottomGlow != null && mBottomGlow.draw(c); c.restoreToCount(restore); } // If some views are animating, ItemDecorators are likely to move/change with them. // Invalidate RecyclerViewEx to re-draw decorators. This is still efficient because children's // display lists are not invalidated. if (!needsInvalidate && mItemAnimator != null && mItemDecorations.size() > 0 && mItemAnimator.isRunning()) { needsInvalidate = true; } if (needsInvalidate) { ViewCompat.postInvalidateOnAnimation(this); } }
From source file:cn.ismartv.recyclerview.widget.RecyclerView.java
@Override public void draw(Canvas c) { super.draw(c); final int count = mItemDecorations.size(); for (int i = 0; i < count; i++) { mItemDecorations.get(i).onDrawOver(c, this, mState); }/*from w ww. jav a 2 s . c o m*/ // TODO If padding is not 0 and chilChildrenToPadding is false, to draw glows properly, we // need find children closest to edges. Not sure if it is worth the effort. boolean needsInvalidate = false; if (mLeftGlow != null && !mLeftGlow.isFinished()) { final int restore = c.save(); final int padding = mClipToPadding ? getPaddingBottom() : 0; c.rotate(270); c.translate(-getHeight() + padding, 0); needsInvalidate = mLeftGlow != null && mLeftGlow.draw(c); c.restoreToCount(restore); } if (mTopGlow != null && !mTopGlow.isFinished()) { final int restore = c.save(); if (mClipToPadding) { c.translate(getPaddingLeft(), getPaddingTop()); } needsInvalidate |= mTopGlow != null && mTopGlow.draw(c); c.restoreToCount(restore); } if (mRightGlow != null && !mRightGlow.isFinished()) { final int restore = c.save(); final int width = getWidth(); final int padding = mClipToPadding ? getPaddingTop() : 0; c.rotate(90); c.translate(-padding, -width); needsInvalidate |= mRightGlow != null && mRightGlow.draw(c); c.restoreToCount(restore); } if (mBottomGlow != null && !mBottomGlow.isFinished()) { final int restore = c.save(); c.rotate(180); if (mClipToPadding) { c.translate(-getWidth() + getPaddingRight(), -getHeight() + getPaddingBottom()); } else { c.translate(-getWidth(), -getHeight()); } needsInvalidate |= mBottomGlow != null && mBottomGlow.draw(c); c.restoreToCount(restore); } // If some views are animating, ItemDecorators are likely to move/change with them. // Invalidate RecyclerView to re-draw decorators. This is still efficient because children's // display lists are not invalidated. if (!needsInvalidate && mItemAnimator != null && mItemDecorations.size() > 0 && mItemAnimator.isRunning()) { needsInvalidate = true; } if (needsInvalidate) { ViewCompat.postInvalidateOnAnimation(this); } }
From source file:com.b44t.messenger.support.widget.RecyclerView.java
@Override public void draw(Canvas c) { super.draw(c); final int count = mItemDecorations.size(); for (int i = 0; i < count; i++) { mItemDecorations.get(i).onDrawOver(c, this, mState); }//from w ww .ja va 2 s.c o m // TODO If padding is not 0 and chilChildrenToPadding is false, to draw glows properly, we // need find children closest to edges. Not sure if it is worth the effort. boolean needsInvalidate = false; if (mLeftGlow != null && !mLeftGlow.isFinished()) { final int restore = c.save(); final int padding = mClipToPadding ? getPaddingBottom() : 0; c.rotate(270); c.translate(-getHeight() + padding, 0); needsInvalidate = mLeftGlow != null && mLeftGlow.draw(c); c.restoreToCount(restore); } if (mTopGlow != null && !mTopGlow.isFinished()) { final int restore = c.save(); if (mClipToPadding) { c.translate(getPaddingLeft(), getPaddingTop()); } c.translate(0, topGlowOffset); needsInvalidate |= mTopGlow != null && mTopGlow.draw(c); c.restoreToCount(restore); } if (mRightGlow != null && !mRightGlow.isFinished()) { final int restore = c.save(); final int width = getWidth(); final int padding = mClipToPadding ? getPaddingTop() : 0; c.rotate(90); c.translate(-padding, -width); needsInvalidate |= mRightGlow != null && mRightGlow.draw(c); c.restoreToCount(restore); } if (mBottomGlow != null && !mBottomGlow.isFinished()) { final int restore = c.save(); c.rotate(180); if (mClipToPadding) { c.translate(-getWidth() + getPaddingRight(), -getHeight() + getPaddingBottom()); } else { c.translate(-getWidth(), -getHeight()); } needsInvalidate |= mBottomGlow != null && mBottomGlow.draw(c); c.restoreToCount(restore); } // If some views are animating, ItemDecorators are likely to move/change with them. // Invalidate RecyclerView to re-draw decorators. This is still efficient because children's // display lists are not invalidated. if (!needsInvalidate && mItemAnimator != null && mItemDecorations.size() > 0 && mItemAnimator.isRunning()) { needsInvalidate = true; } if (needsInvalidate) { ViewCompat.postInvalidateOnAnimation(this); } }
From source file:android.support.v71.widget.RecyclerView.java
@Override public void draw(Canvas c) { super.draw(c); // //from w ww. ja v a 2s. c o m final int count = mItemDecorations.size(); for (int i = 0; i < count; i++) { mItemDecorations.get(i).onDrawOver(c, this, mState); } // TODO If padding is not 0 and chilChildrenToPadding is false, to draw glows properly, we // need find children closest to edges. Not sure if it is worth the effort. boolean needsInvalidate = false; // ? if (mLeftGlow != null && !mLeftGlow.isFinished()) { final int restore = c.save(); final int padding = mClipToPadding ? getPaddingBottom() : 0; c.rotate(270); c.translate(-getHeight() + padding, 0); needsInvalidate = mLeftGlow != null && mLeftGlow.draw(c); c.restoreToCount(restore); } if (mTopGlow != null && !mTopGlow.isFinished()) { final int restore = c.save(); if (mClipToPadding) { c.translate(getPaddingLeft(), getPaddingTop()); } needsInvalidate |= mTopGlow != null && mTopGlow.draw(c); c.restoreToCount(restore); } if (mRightGlow != null && !mRightGlow.isFinished()) { final int restore = c.save(); final int width = getWidth(); final int padding = mClipToPadding ? getPaddingTop() : 0; c.rotate(90); c.translate(-padding, -width); needsInvalidate |= mRightGlow != null && mRightGlow.draw(c); c.restoreToCount(restore); } if (mBottomGlow != null && !mBottomGlow.isFinished()) { final int restore = c.save(); c.rotate(180); if (mClipToPadding) { c.translate(-getWidth() + getPaddingRight(), -getHeight() + getPaddingBottom()); } else { c.translate(-getWidth(), -getHeight()); } needsInvalidate |= mBottomGlow != null && mBottomGlow.draw(c); c.restoreToCount(restore); } // If some views are animating, ItemDecorators are likely to move/change with them. // Invalidate RecyclerView to re-draw decorators. This is still efficient because children's // display lists are not invalidated. // VIew , Item ??, ?? ? if (!needsInvalidate && mItemAnimator != null && mItemDecorations.size() > 0 && mItemAnimator.isRunning()) { needsInvalidate = true; } if (needsInvalidate) { ViewCompat.postInvalidateOnAnimation(this); } }