Example usage for android.graphics Canvas translate

List of usage examples for android.graphics Canvas translate

Introduction

In this page you can find the example usage for android.graphics Canvas translate.

Prototype

public void translate(float dx, float dy) 

Source Link

Document

Preconcat the current matrix with the specified translation

Usage

From source file:net.opacapp.multilinecollapsingtoolbar.CollapsingTextHelper.java

public void draw(Canvas canvas) {
    final int saveCount = canvas.save();

    if (mTextToDraw != null && mDrawTitle) {
        float x = mCurrentDrawX;
        float y = mCurrentDrawY;

        final boolean drawTexture = mUseTexture && mExpandedTitleTexture != null;
        final float ascent;
        // MODIFICATION: removed now unused "descent" variable declaration

        // Update the TextPaint to the current text size
        mTextPaint.setTextSize(mCurrentTextSize);

        // BEGIN MODIFICATION: new drawing code
        if (drawTexture) {
            ascent = 0;//from   w w w  .j  a  v  a  2  s . c o m
        } else {
            ascent = mTextPaint.ascent() * mScale;
        }

        if (DEBUG_DRAW) {
            // Just a debug tool, which drawn a Magneta rect in the text bounds
            canvas.drawRect(mCurrentBounds.left, y, mCurrentBounds.right, y + mTextLayout.getHeight() * mScale,
                    DEBUG_DRAW_PAINT);
        }
        if (mScale != 1f) {
            canvas.scale(mScale, mScale, x, y);
        }

        // Compute where to draw mTextLayout for this frame
        final float currentExpandedX = mCurrentDrawX + mTextLayout.getLineLeft(0) - mExpandedFirstLineDrawX * 2;
        if (drawTexture) {
            // If we should use a texture, draw it instead of text
            // Expanded text
            mTexturePaint.setAlpha((int) (mExpandedTextBlend * 255));
            canvas.drawBitmap(mExpandedTitleTexture, currentExpandedX, y, mTexturePaint);
            // Collapsed text
            mTexturePaint.setAlpha((int) (mCollapsedTextBlend * 255));
            canvas.drawBitmap(mCollapsedTitleTexture, x, y, mTexturePaint);
            // Cross-section between both texts (should stay at alpha = 255)
            mTexturePaint.setAlpha(255);
            canvas.drawBitmap(mCrossSectionTitleTexture, x, y, mTexturePaint);
        } else {
            // positon expanded text appropriately
            canvas.translate(currentExpandedX, y);
            // Expanded text
            mTextPaint.setAlpha((int) (mExpandedTextBlend * 255));
            mTextLayout.draw(canvas);

            // position the overlays
            canvas.translate(x - currentExpandedX, 0);

            // Collapsed text
            mTextPaint.setAlpha((int) (mCollapsedTextBlend * 255));
            canvas.drawText(mTextToDrawCollapsed, 0, mTextToDrawCollapsed.length(), 0, -ascent / mScale,
                    mTextPaint);
            // Cross-section between both texts (should stay at alpha = 255)
            mTextPaint.setAlpha(255);
            canvas.drawText(mTextToDraw, mTextLayout.getLineStart(0), mTextLayout.getLineEnd(0), 0,
                    -ascent / mScale, mTextPaint);
        }
        // END MODIFICATION
    }
    canvas.restoreToCount(saveCount);
}

From source file:com.bettervectordrawable.lib.graphics.drawable.VectorDrawable.java

@Override
public void draw(Canvas canvas) {
    // We will offset the bounds for drawBitmap, so copyBounds() here instead
    // of getBounds().
    copyBounds(mTmpBounds);//from  w  w w.j ava  2  s  .c om
    if (mTmpBounds.width() <= 0 || mTmpBounds.height() <= 0) {
        // Nothing to draw
        return;
    }
    // Color filters always override tint filters.
    final ColorFilter colorFilter = (mColorFilter == null ? mTintFilter : mColorFilter);
    // The imageView can scale the canvas in different ways, in order to
    // avoid blurry scaling, we have to draw into a bitmap with exact pixel
    // size first. This bitmap size is determined by the bounds and the
    // canvas scale.
    canvas.getMatrix(mTmpMatrix);
    mTmpMatrix.getValues(mTmpFloats);
    float canvasScaleX = Math.abs(mTmpFloats[Matrix.MSCALE_X]);
    float canvasScaleY = Math.abs(mTmpFloats[Matrix.MSCALE_Y]);
    int scaledWidth = (int) (mTmpBounds.width() * canvasScaleX);
    int scaledHeight = (int) (mTmpBounds.height() * canvasScaleY);
    scaledWidth = Math.min(MAX_CACHED_BITMAP_SIZE, scaledWidth);
    scaledHeight = Math.min(MAX_CACHED_BITMAP_SIZE, scaledHeight);
    if (scaledWidth <= 0 || scaledHeight <= 0) {
        return;
    }
    final int saveCount = canvas.save();
    canvas.translate(mTmpBounds.left, mTmpBounds.top);
    // Handle RTL mirroring.
    final boolean needMirroring = needMirroring();
    if (needMirroring) {
        canvas.translate(mTmpBounds.width(), 0);
        canvas.scale(-1.0f, 1.0f);
    }
    // At this point, canvas has been translated to the right position.
    // And we use this bound for the destination rect for the drawBitmap, so
    // we offset to (0, 0);
    mTmpBounds.offsetTo(0, 0);
    mVectorState.createCachedBitmapIfNeeded(scaledWidth, scaledHeight);
    if (!mAllowCaching) {
        mVectorState.updateCachedBitmap(scaledWidth, scaledHeight);
    } else {
        if (!mVectorState.canReuseCache()) {
            mVectorState.updateCachedBitmap(scaledWidth, scaledHeight);
            mVectorState.updateCacheStates();
        }
    }
    mVectorState.drawCachedBitmapWithRootAlpha(canvas, colorFilter, mTmpBounds);
    canvas.restoreToCount(saveCount);
}

From source file:com.yek.keyboard.keyboards.views.CandidateView.java

/**
 * If the canvas is null, then only touch calculations are performed to pick
 * the target candidate./*ww w  .j  a  v a  2s. co  m*/
 */
@Override
protected void onDraw(Canvas canvas) {
    if (canvas != null) {
        super.onDraw(canvas);
    }
    mTotalWidth = 0;

    final int height = getHeight();
    if (mBgPadding == null) {
        mBgPadding = new Rect(0, 0, 0, 0);
        if (getBackground() != null) {
            getBackground().getPadding(mBgPadding);
        }
        mDivider.setBounds(0, 0, mDivider.getIntrinsicWidth(), mDivider.getIntrinsicHeight());
    }

    final int dividerYOffset = (height - mDivider.getMinimumHeight()) / 2;
    final int count = mSuggestions.size();
    final Rect bgPadding = mBgPadding;
    final Paint paint = mPaint;
    final int touchX = mTouchX;
    final int scrollX = getScrollX();
    final boolean scrolled = mScrolled;
    final boolean typedWordValid = mTypedWordValid;

    int x = 0;
    for (int i = 0; i < count; i++) {
        CharSequence suggestion = mSuggestions.get(i);
        if (suggestion == null)
            continue;
        final int wordLength = suggestion.length();

        paint.setColor(mColorNormal);
        if (mHaveMinimalSuggestion && ((i == 1 && !typedWordValid) || (i == 0 && typedWordValid))) {
            paint.setTypeface(Typeface.DEFAULT_BOLD);
            paint.setColor(mColorRecommended);
            // existsAutoCompletion = true;
        } else if (i != 0 || (wordLength == 1 && count > 1)) {
            // HACK: even if i == 0, we use mColorOther when this
            // suggestion's length is 1 and
            // there are multiple suggestions, such as the default
            // punctuation list.
            paint.setColor(mColorOther);
        }

        // now that we set the typeFace, we can measure
        int wordWidth;
        if ((wordWidth = mWordWidth[i]) == 0) {
            float textWidth = paint.measureText(suggestion, 0, wordLength);
            // wordWidth = Math.max(0, (int) textWidth + X_GAP * 2);
            wordWidth = (int) (textWidth + mXGap * 2);
            mWordWidth[i] = wordWidth;
        }

        mWordX[i] = x;

        if (touchX != OUT_OF_BOUNDS_X_CORD && !scrolled && touchX + scrollX >= x
                && touchX + scrollX < x + wordWidth) {
            if (canvas != null && !mShowingAddToDictionary) {
                canvas.translate(x, 0);
                mSelectionHighlight.setBounds(0, bgPadding.top, wordWidth, height);
                mSelectionHighlight.draw(canvas);
                canvas.translate(-x, 0);
            }
            mSelectedString = suggestion;
            mSelectedIndex = i;
        }

        if (canvas != null) {
            // (+)This is the trick to get RTL/LTR text correct
            if (AnyApplication.getConfig().workaround_alwaysUseDrawText()) {
                final int y = (int) (height + paint.getTextSize() - paint.descent()) / 2;
                canvas.drawText(suggestion, 0, wordLength, x + wordWidth / 2, y, paint);
            } else {
                final int y = (int) (height - paint.getTextSize() + paint.descent()) / 2;
                // no matter what: StaticLayout
                float textX = x + (wordWidth / 2) - mXGap;
                float textY = y - bgPadding.bottom - bgPadding.top;

                canvas.translate(textX, textY);
                mTextPaint.setTypeface(paint.getTypeface());
                mTextPaint.setColor(paint.getColor());

                StaticLayout suggestionText = new StaticLayout(suggestion, mTextPaint, wordWidth,
                        Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
                suggestionText.draw(canvas);

                canvas.translate(-textX, -textY);
            }
            // (-)
            paint.setColor(mColorOther);
            canvas.translate(x + wordWidth, 0);
            // Draw a divider unless it's after the hint
            //or the last suggested word
            if (count > 1 && (!mShowingAddToDictionary) && i != (count - 1)) {
                canvas.translate(0, dividerYOffset);
                mDivider.draw(canvas);
                canvas.translate(0, -dividerYOffset);
            }
            canvas.translate(-x - wordWidth, 0);
        }
        paint.setTypeface(Typeface.DEFAULT);
        x += wordWidth;
    }
    mTotalWidth = x;
    if (mTargetScrollX != scrollX) {
        scrollToTarget();
    }
}

From source file:com.anysoftkeyboard.keyboards.views.CandidateView.java

/**
 * If the canvas is null, then only touch calculations are performed to pick
 * the target candidate.//from  w w w . ja v  a  2 s  .c o m
 */
@Override
protected void onDraw(Canvas canvas) {
    if (canvas != null) {
        super.onDraw(canvas);
    }
    mTotalWidth = 0;

    final int height = getHeight();
    if (mBgPadding == null) {
        mBgPadding = new Rect(0, 0, 0, 0);
        if (getBackground() != null) {
            getBackground().getPadding(mBgPadding);
        }
        mDivider.setBounds(0, 0, mDivider.getIntrinsicWidth(), mDivider.getIntrinsicHeight());
    }

    final int dividerYOffset = (height - mDivider.getMinimumHeight()) / 2;
    final int count = mSuggestions.size();
    final Rect bgPadding = mBgPadding;
    final Paint paint = mPaint;
    final int touchX = mTouchX;
    final int scrollX = getScrollX();
    final boolean scrolled = mScrolled;
    final boolean typedWordValid = mTypedWordValid;

    int x = 0;
    for (int i = 0; i < count; i++) {
        CharSequence suggestion = mSuggestions.get(i);
        if (suggestion == null)
            continue;
        final int wordLength = suggestion.length();

        paint.setColor(mColorNormal);
        if (mHaveMinimalSuggestion && ((i == 1 && !typedWordValid) || (i == 0 && typedWordValid))) {
            paint.setTypeface(Typeface.DEFAULT_BOLD);
            paint.setColor(mColorRecommended);
            // existsAutoCompletion = true;
        } else if (i != 0 || (wordLength == 1 && count > 1)) {
            // HACK: even if i == 0, we use mColorOther when this
            // suggestion's length is 1 and
            // there are multiple suggestions, such as the default
            // punctuation list.
            paint.setColor(mColorOther);
        }

        // now that we set the typeFace, we can measure
        int wordWidth;
        if ((wordWidth = mWordWidth[i]) == 0) {
            float textWidth = paint.measureText(suggestion, 0, wordLength);
            // wordWidth = Math.max(0, (int) textWidth + X_GAP * 2);
            wordWidth = (int) (textWidth + mHorizontalGap * 2);
            mWordWidth[i] = wordWidth;
        }

        mWordX[i] = x;

        if (touchX != OUT_OF_BOUNDS_X_CORD && !scrolled && touchX + scrollX >= x
                && touchX + scrollX < x + wordWidth) {
            if (canvas != null && !mShowingAddToDictionary) {
                canvas.translate(x, 0);
                mSelectionHighlight.setBounds(0, bgPadding.top, wordWidth, height);
                mSelectionHighlight.draw(canvas);
                canvas.translate(-x, 0);
            }
            mSelectedString = suggestion;
            mSelectedIndex = i;
        }

        if (canvas != null) {
            // (+)This is the trick to get RTL/LTR text correct
            if (AnyApplication.getConfig().workaround_alwaysUseDrawText()) {
                final int y = (int) (height + paint.getTextSize() - paint.descent()) / 2;
                canvas.drawText(suggestion, 0, wordLength, x + wordWidth / 2, y, paint);
            } else {
                final int y = (int) (height - paint.getTextSize() + paint.descent()) / 2;
                // no matter what: StaticLayout
                float textX = x + (wordWidth / 2) - mHorizontalGap;
                float textY = y - bgPadding.bottom - bgPadding.top;

                canvas.translate(textX, textY);
                mTextPaint.setTypeface(paint.getTypeface());
                mTextPaint.setColor(paint.getColor());

                StaticLayout suggestionText = new StaticLayout(suggestion, mTextPaint, wordWidth,
                        Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
                suggestionText.draw(canvas);

                canvas.translate(-textX, -textY);
            }
            // (-)
            paint.setColor(mColorOther);
            canvas.translate(x + wordWidth, 0);
            // Draw a divider unless it's after the hint
            //or the last suggested word
            if (count > 1 && (!mShowingAddToDictionary) && i != (count - 1)) {
                canvas.translate(0, dividerYOffset);
                mDivider.draw(canvas);
                canvas.translate(0, -dividerYOffset);
            }
            canvas.translate(-x - wordWidth, 0);
        }
        paint.setTypeface(Typeface.DEFAULT);
        x += wordWidth;
    }
    mTotalWidth = x;
    if (mTargetScrollX != scrollX) {
        scrollToTarget();
    }
}

From source file:administrator.example.com.myscrollview.VerticalViewPager.java

@Override
public void draw(Canvas canvas) {
    // XXX ?/*from  www. j  a v a2s  . c om*/
    super.draw(canvas);
    boolean needsInvalidate = false;

    final int overScrollMode = ViewCompat.getOverScrollMode(this);
    if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS
            || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null
                    && mAdapter.getCount() > 1)) {
        if (!mTopEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();

            canvas.rotate(270);
            canvas.translate(-width + getPaddingLeft(), 0);
            mTopEdge.setSize(width, getHeight());
            needsInvalidate |= mTopEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        } /* end of if */
        if (!mBottomEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();
            final int height = getHeight();
            final int itemCount = mAdapter != null ? mAdapter.getCount() : 1;

            canvas.rotate(180);
            canvas.translate(-width + getPaddingLeft(), -itemCount * (height + mPageMargin) + mPageMargin);
            mBottomEdge.setSize(width, height);
            needsInvalidate |= mBottomEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        } /* end of if */
    } else {
        mTopEdge.finish();
        mBottomEdge.finish();
    } /* end of if */

    if (needsInvalidate) {
        // Keep animating
        invalidate();
    } /* end of if */
}

From source file:com.lanou.mirror.tool.VerticalViewPager.java

@Override
public void draw(Canvas canvas) {
    // XXX /*from w w w  .  j  a  v  a 2s. c  om*/
    super.draw(canvas);
    boolean needsInvalidate = false;

    final int overScrollMode = ViewCompat.getOverScrollMode(this);
    if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS
            || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null
                    && mAdapter.getCount() > 1)) {
        if (!mTopEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();

            canvas.rotate(270);
            canvas.translate(-width + getPaddingLeft(), 0);
            mTopEdge.setSize(width, getHeight());
            needsInvalidate |= mTopEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        } /* end of if */
        if (!mBottomEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();
            final int height = getHeight();
            final int itemCount = mAdapter != null ? mAdapter.getCount() : 1;

            canvas.rotate(180);
            canvas.translate(-width + getPaddingLeft(), -itemCount * (height + mPageMargin) + mPageMargin);
            mBottomEdge.setSize(width, height);
            needsInvalidate |= mBottomEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        } /* end of if */
    } else {
        mTopEdge.finish();
        mBottomEdge.finish();
    } /* end of if */

    if (needsInvalidate) {
        // Keep animating
        invalidate();
    } /* end of if */
}

From source file:com.bluetoothlamp.tiny.view.verticalview.VerticalViewPager.java

@Override
public void draw(Canvas canvas) {
    // XXX ??/*from   w  w w. j av a2 s.co m*/
    super.draw(canvas);
    boolean needsInvalidate = false;

    final int overScrollMode = ViewCompat.getOverScrollMode(this);
    if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS
            || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null
                    && mAdapter.getCount() > 1)) {
        if (!mTopEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();

            canvas.rotate(270);
            canvas.translate(-width + getPaddingLeft(), 0);
            mTopEdge.setSize(width, getHeight());
            needsInvalidate |= mTopEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        } /* end of if */
        if (!mBottomEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();
            final int height = getHeight();
            final int itemCount = mAdapter != null ? mAdapter.getCount() : 1;

            canvas.rotate(180);
            canvas.translate(-width + getPaddingLeft(), -itemCount * (height + mPageMargin) + mPageMargin);
            mBottomEdge.setSize(width, height);
            needsInvalidate |= mBottomEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        } /* end of if */
    } else {
        mTopEdge.finish();
        mBottomEdge.finish();
    } /* end of if */

    if (needsInvalidate) {
        // Keep animating
        invalidate();
    } /* end of if */
}

From source file:com.hippo.vector.VectorDrawable.java

@Override
@SuppressWarnings("deprecation")
public void draw(Canvas canvas) {
    // We will offset the bounds for drawBitmap, so copyBounds() here instead
    // of getBounds().
    copyBounds(mTmpBounds);//from  w  w w  .  ja v  a2s  .  c om
    if (mTmpBounds.width() <= 0 || mTmpBounds.height() <= 0) {
        // Nothing to draw
        return;
    }

    // Color filters always override tint filters.
    final ColorFilter colorFilter = (mColorFilter == null ? mTintFilter : mColorFilter);

    // The imageView can scale the canvas in different ways, in order to
    // avoid blurry scaling, we have to draw into a bitmap with exact pixel
    // size first. This bitmap size is determined by the bounds and the
    // canvas scale.
    canvas.getMatrix(mTmpMatrix);
    mTmpMatrix.getValues(mTmpFloats);
    float canvasScaleX = Math.abs(mTmpFloats[Matrix.MSCALE_X]);
    float canvasScaleY = Math.abs(mTmpFloats[Matrix.MSCALE_Y]);
    int scaledWidth = (int) (mTmpBounds.width() * canvasScaleX);
    int scaledHeight = (int) (mTmpBounds.height() * canvasScaleY);
    scaledWidth = Math.min(MAX_CACHED_BITMAP_SIZE, scaledWidth);
    scaledHeight = Math.min(MAX_CACHED_BITMAP_SIZE, scaledHeight);

    if (scaledWidth <= 0 || scaledHeight <= 0) {
        return;
    }

    final int saveCount = canvas.save();
    canvas.translate(mTmpBounds.left, mTmpBounds.top);

    // Handle RTL mirroring.
    final boolean needMirroring = needMirroring();
    if (needMirroring) {
        canvas.translate(mTmpBounds.width(), 0);
        canvas.scale(-1.0f, 1.0f);
    }

    // At this point, canvas has been translated to the right position.
    // And we use this bound for the destination rect for the drawBitmap, so
    // we offset to (0, 0);
    mTmpBounds.offsetTo(0, 0);

    mVectorState.createCachedBitmapIfNeeded(scaledWidth, scaledHeight);
    if (!mAllowCaching) {
        mVectorState.updateCachedBitmap(scaledWidth, scaledHeight);
    } else {
        if (!mVectorState.canReuseCache()) {
            mVectorState.updateCachedBitmap(scaledWidth, scaledHeight);
            mVectorState.updateCacheStates();
        }
    }
    mVectorState.drawCachedBitmapWithRootAlpha(canvas, colorFilter, mTmpBounds);
    canvas.restoreToCount(saveCount);
}

From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java

@Override
protected void onDraw(Canvas canvas) {
    if (mRemeasure) {
        remeasure(getWidth(), getHeight());
        mRemeasure = false;/*www  .  ja  v  a2 s . com*/
    }
    canvas.save();

    float yTranslate = -mViewStartY + DAY_HEADER_HEIGHT;
    // offset canvas by the current drag and header position
    canvas.translate(-mViewStartX, yTranslate);
    // clip to everything below the allDay area
    Rect dest = mDestRect;
    dest.top = (int) (mFirstCell - yTranslate);
    dest.bottom = (int) (mViewHeight - yTranslate);
    dest.left = 0;
    dest.right = mViewWidth;
    canvas.save();
    canvas.clipRect(dest);
    // Draw the movable part of the view
    doDraw(canvas);
    // restore to having no clip
    canvas.restore();

    if ((mTouchMode & TOUCH_MODE_HSCROLL) != 0) {
        float xTranslate;
        if (mViewStartX > 0) {
            xTranslate = mViewWidth;
        } else {
            xTranslate = -mViewWidth;
        }
        // Move the canvas around to prep it for the next view
        // specifically, shift it by a screen and undo the
        // yTranslation which will be redone in the nextView's onDraw().
        canvas.translate(xTranslate, -yTranslate);
        DayView nextView = (DayView) mViewSwitcher.getNextView();

        // Prevent infinite recursive calls to onDraw().
        nextView.mTouchMode = TOUCH_MODE_INITIAL_STATE;

        nextView.onDraw(canvas);
        // Move it back for this view
        canvas.translate(-xTranslate, 0);
    } else {
        // If we drew another view we already translated it back
        // If we didn't draw another view we should be at the edge of the
        // screen
        canvas.translate(mViewStartX, -yTranslate);
    }

    // Draw the fixed areas (that don't scroll) directly to the canvas.
    drawAfterScroll(canvas);
    mComputeSelectedEvents = false;

    // Draw overscroll glow
    if (!mEdgeEffectTop.isFinished()) {
        if (DAY_HEADER_HEIGHT != 0) {
            canvas.translate(0, DAY_HEADER_HEIGHT);
        }
        if (mEdgeEffectTop.draw(canvas)) {
            invalidate();
        }
        if (DAY_HEADER_HEIGHT != 0) {
            canvas.translate(0, -DAY_HEADER_HEIGHT);
        }
    }
    if (!mEdgeEffectBottom.isFinished()) {
        canvas.rotate(180, mViewWidth / 2, mViewHeight / 2);
        if (mEdgeEffectBottom.draw(canvas)) {
            invalidate();
        }
    }
    canvas.restore();
}

From source file:com.ad.view.staggeredgridview.StaggeredGridView.java

@Override
public void draw(Canvas canvas) {
    super.draw(canvas);

    if (mTopEdge != null) {
        boolean needsInvalidate = false;
        if (!mTopEdge.isFinished()) {
            mTopEdge.draw(canvas);/*from w w w .ja  v  a 2 s  . com*/
            needsInvalidate = true;
        }
        if (!mBottomEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth();
            canvas.translate(-width, getHeight());
            canvas.rotate(180, width, 0);
            mBottomEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
            needsInvalidate = true;
        }

        if (needsInvalidate) {
            invalidate();
        }
    }

    // drawSelector(canvas);
}