Example usage for android.view View getMatrix

List of usage examples for android.view View getMatrix

Introduction

In this page you can find the example usage for android.view View getMatrix.

Prototype

public Matrix getMatrix() 

Source Link

Document

The transform matrix of this view, which is calculated based on the current rotation, scale, and pivot properties.

Usage

From source file:cc.flydev.launcher.Page.java

float[] mapPointFromViewToParent(View v, float x, float y) {
    mTmpPoint[0] = x;//from w w  w  .j a  v a2  s .co  m
    mTmpPoint[1] = y;
    v.getMatrix().mapPoints(mTmpPoint);
    mTmpPoint[0] += v.getLeft();
    mTmpPoint[1] += v.getTop();
    return mTmpPoint;
}

From source file:cc.flydev.launcher.Page.java

float[] mapPointFromParentToView(View v, float x, float y) {
    mTmpPoint[0] = x - v.getLeft();/*from  ww w  . j a  va 2 s .co  m*/
    mTmpPoint[1] = y - v.getTop();
    v.getMatrix().invert(mTmpInvMatrix);
    mTmpInvMatrix.mapPoints(mTmpPoint);
    return mTmpPoint;
}

From source file:com.android.launcher2.Workspace.java

void mapPointFromChildToSelf(View v, float[] xy) {
    v.getMatrix().mapPoints(xy);
    int scrollX = getScrollX();
    if (mNextPage != INVALID_PAGE) {
        scrollX = mScroller.getFinalX();
    }/* ww w  .j ava  2 s  . com*/
    xy[0] -= (scrollX - v.getLeft());
    xy[1] -= (getScrollY() - v.getTop());
}

From source file:com.android.launcher2.Workspace.java

void mapPointFromSelfToChild(View v, float[] xy, Matrix cachedInverseMatrix) {
    if (cachedInverseMatrix == null) {
        v.getMatrix().invert(mTempInverseMatrix);
        cachedInverseMatrix = mTempInverseMatrix;
    }//from  w  ww .ja va 2s.  c  om
    int scrollX = getScrollX();
    if (mNextPage != INVALID_PAGE) {
        scrollX = mScroller.getFinalX();
    }
    xy[0] = xy[0] + scrollX - v.getLeft();
    xy[1] = xy[1] + getScrollY() - v.getTop();
    cachedInverseMatrix.mapPoints(xy);
}

From source file:com.wb.launcher3.Page.java

@Override
protected void dispatchDraw(Canvas canvas) {
    int halfScreenSize = getViewportWidth() / 2;
    // mOverScrollX is equal to getScrollX() when we're within the normal scroll range.
    // Otherwise it is equal to the scaled overscroll position.
    int screenCenter = mOverScrollX + halfScreenSize;

    if (screenCenter != mLastScreenCenter || mForceScreenScrolled) {
        // set mForceScreenScrolled before calling screenScrolled so that screenScrolled can
        // set it for the next frame
        mForceScreenScrolled = false;//  ww w.  j  av a  2s.  c om
        screenScrolled(screenCenter);
        mLastScreenCenter = screenCenter;
    }

    // Find out which screens are visible; as an optimization we only call draw on them
    final int pageCount = getChildCount();
    if (pageCount > 0) {
        //*/Modified by tyd Greg 2014-03-20,for transition effect
        boolean allowed = true;
        Workspace workspace = null;
        if (this instanceof Workspace) {
            workspace = (Workspace) this;
            allowed = !workspace.isSmall();
        }
        if (TydtechConfig.TYDTECH_DEBUG_FLAG) {
            Log.d("Greg", "allowed: " + allowed);
        }
        /*/
        if(!allowed || !TydtechConfig.TRANSITION_EFFECT_ENABLED){
        getVisiblePages(mTempVisiblePagesRange);
        }else{
        getVisiblePagesExt(mTempVisiblePagesRange);
        }
        //*/
        getVisiblePages(mTempVisiblePagesRange);
        //*/
        final int leftScreen = mTempVisiblePagesRange[0];
        final int rightScreen = mTempVisiblePagesRange[1];
        if (leftScreen != -1 && rightScreen != -1) {
            final long drawingTime = getDrawingTime();
            // Clip to the bounds
            canvas.save();
            canvas.clipRect(getScrollX(), getScrollY(), getScrollX() + getRight() - getLeft(),
                    getScrollY() + getBottom() - getTop());

            // Draw all the children, leaving the drag view for last
            for (int i = pageCount - 1; i >= 0; i--) {
                final View v = getPageAt(i);
                if (v == mDragView)
                    continue;
                if (mForceDrawAllChildrenNextFrame
                        || (leftScreen <= i && i <= rightScreen && shouldDrawChild(v))) {
                    drawChild(canvas, v, drawingTime);
                }
            }
            // Draw the drag view on top (if there is one)
            if (mDragView != null) {
                drawChild(canvas, mDragView, drawingTime);
            }

            mForceDrawAllChildrenNextFrame = false;
            canvas.restore();
        }

        //*/Added by TYD Theobald_Wu on 20130223 [begin] for cycle rolling pages
        if (TydtechConfig.CYCLE_ROLL_PAGES_ENABLED && allowed) {
            canvas.save();
            int width = 0;
            final int pageW = getViewportWidth();
            View v = null;
            int scrollOffset = (pageW - getChildWidth(0)) / 2;
            if (mOverScrollX < 0) {
                int index = pageCount - 1;
                v = getPageAt(index);
                width = getViewportOffsetX() - scrollOffset - v.getWidth();
            } else if (mOverScrollX > mMaxScrollX) {
                v = getPageAt(0);
                width = getViewportOffsetX() + pageW * pageCount + scrollOffset;
            }
            if (TydtechConfig.TYDTECH_DEBUG_FLAG) {
                Log.d("Greg", "width: " + width);
                Log.d("Greg", "mOverScrollX: " + mOverScrollX);
            }
            if (v != null) {
                canvas.translate(width, v.getY());
                canvas.concat(v.getMatrix());
                final int w = v.getWidth();
                final int h = v.getHeight();
                final int sx = v.getScrollX();
                final int sy = v.getScrollY();
                Rect rect = new Rect(sx, sy, sx + w, sy + h);
                ///* zhangwuba mark this, user verison lead to screen flash 2014-5-12
                //canvas.saveLayerAlpha(sx, sy, sx + w, sy + h, (int) (v.getAlpha() * 255),
                //  Canvas.HAS_ALPHA_LAYER_SAVE_FLAG | Canvas.CLIP_TO_LAYER_SAVE_FLAG);
                //*/
                v.draw(canvas);
            }
            canvas.restore();
        }
        //*/
    }
}