Search in sources :

Example 21 with Point

use of android.graphics.Point in project platform_frameworks_base by android.

the class MultiSelectManager_GridModelTest method testSelectionAboveItems.

public void testSelectionAboveItems() {
    initData(20, 4);
    startSelection(new Point(10, 0));
    resizeSelection(new Point(11, 1));
    assertNoSelection();
    assertEquals(NOT_SET, model.getPositionNearestOrigin());
}
Also used : Point(android.graphics.Point)

Example 22 with Point

use of android.graphics.Point in project platform_frameworks_base by android.

the class MultiSelectManager_GridModelTest method testVerticalSelectionBetweenItems.

public void testVerticalSelectionBetweenItems() {
    initData(20, 4);
    startSelection(new Point(106, 0));
    resizeSelection(new Point(107, 200));
    assertNoSelection();
    assertEquals(NOT_SET, model.getPositionNearestOrigin());
}
Also used : Point(android.graphics.Point)

Example 23 with Point

use of android.graphics.Point in project platform_frameworks_base by android.

the class MultiSelectManager_GridModelTest method testScrollingBandSelect.

public void testScrollingBandSelect() {
    initData(40, 4);
    startSelection(new Point(0, 0));
    resizeSelection(new Point(100, VIEWPORT_HEIGHT - 1));
    verifySelection();
    scroll(CHILD_VIEW_EDGE_PX);
    verifySelection();
    resizeSelection(new Point(200, VIEWPORT_HEIGHT - 1));
    verifySelection();
    scroll(CHILD_VIEW_EDGE_PX);
    verifySelection();
    scroll(-2 * CHILD_VIEW_EDGE_PX);
    verifySelection();
    resizeSelection(new Point(100, VIEWPORT_HEIGHT - 1));
    verifySelection();
    assertEquals(0, model.getPositionNearestOrigin());
}
Also used : Point(android.graphics.Point)

Example 24 with Point

use of android.graphics.Point in project platform_frameworks_base by android.

the class DessertCaseView method getOccupied.

private Point[] getOccupied(View v) {
    final int scale = (Integer) v.getTag(TAG_SPAN);
    final Point pt = (Point) v.getTag(TAG_POS);
    if (pt == null || scale == 0)
        return new Point[0];
    final Point[] result = new Point[scale * scale];
    int p = 0;
    for (int i = 0; i < scale; i++) {
        for (int j = 0; j < scale; j++) {
            result[p++] = new Point(pt.x + i, pt.y + j);
        }
    }
    return result;
}
Also used : Point(android.graphics.Point) Point(android.graphics.Point) Paint(android.graphics.Paint)

Example 25 with Point

use of android.graphics.Point in project platform_frameworks_base by android.

the class CropView method onTouchEvent.

@Override
public boolean onTouchEvent(MotionEvent event) {
    int action = event.getActionMasked();
    final boolean pointerUp = action == MotionEvent.ACTION_POINTER_UP;
    final int skipIndex = pointerUp ? event.getActionIndex() : -1;
    // Determine focal point
    float sumX = 0, sumY = 0;
    final int count = event.getPointerCount();
    for (int i = 0; i < count; i++) {
        if (skipIndex == i)
            continue;
        sumX += event.getX(i);
        sumY += event.getY(i);
    }
    final int div = pointerUp ? count - 1 : count;
    float x = sumX / div;
    float y = sumY / div;
    if (action == MotionEvent.ACTION_DOWN) {
        mFirstX = x;
        mFirstY = y;
        mTouchDownTime = System.currentTimeMillis();
        if (mTouchCallback != null) {
            mTouchCallback.onTouchDown();
        }
    } else if (action == MotionEvent.ACTION_UP) {
        ViewConfiguration config = ViewConfiguration.get(getContext());
        float squaredDist = (mFirstX - x) * (mFirstX - x) + (mFirstY - y) * (mFirstY - y);
        float slop = config.getScaledTouchSlop() * config.getScaledTouchSlop();
        long now = System.currentTimeMillis();
        if (mTouchCallback != null) {
            // only do this if it's a small movement
            if (squaredDist < slop && now < mTouchDownTime + ViewConfiguration.getTapTimeout()) {
                mTouchCallback.onTap();
            }
            mTouchCallback.onTouchUp();
        }
    }
    if (!mTouchEnabled) {
        return true;
    }
    synchronized (mLock) {
        mScaleGestureDetector.onTouchEvent(event);
        switch(action) {
            case MotionEvent.ACTION_MOVE:
                float[] point = mTempPoint;
                point[0] = (mLastX - x) / mRenderer.scale;
                point[1] = (mLastY - y) / mRenderer.scale;
                mInverseRotateMatrix.mapPoints(point);
                mCenterX += point[0];
                mCenterY += point[1];
                updateCenter();
                invalidate();
                break;
        }
        if (mRenderer.source != null) {
            // Adjust position so that the wallpaper covers the entire area
            // of the screen
            final RectF edges = mTempEdges;
            getEdgesHelper(edges);
            final float scale = mRenderer.scale;
            float[] coef = mTempCoef;
            coef[0] = 1;
            coef[1] = 1;
            mRotateMatrix.mapPoints(coef);
            float[] adjustment = mTempAdjustment;
            mTempAdjustment[0] = 0;
            mTempAdjustment[1] = 0;
            if (edges.left > 0) {
                adjustment[0] = edges.left / scale;
            } else if (edges.right < getWidth()) {
                adjustment[0] = (edges.right - getWidth()) / scale;
            }
            if (edges.top > 0) {
                adjustment[1] = (float) Math.ceil(edges.top / scale);
            } else if (edges.bottom < getHeight()) {
                adjustment[1] = (edges.bottom - getHeight()) / scale;
            }
            for (int dim = 0; dim <= 1; dim++) {
                if (coef[dim] > 0)
                    adjustment[dim] = (float) Math.ceil(adjustment[dim]);
            }
            mInverseRotateMatrix.mapPoints(adjustment);
            mCenterX += adjustment[0];
            mCenterY += adjustment[1];
            updateCenter();
        }
    }
    mLastX = x;
    mLastY = y;
    return true;
}
Also used : RectF(android.graphics.RectF) ViewConfiguration(android.view.ViewConfiguration) Point(android.graphics.Point)

Aggregations

Point (android.graphics.Point)1151 Display (android.view.Display)217 Rect (android.graphics.Rect)194 Paint (android.graphics.Paint)170 WindowManager (android.view.WindowManager)138 RemoteException (android.os.RemoteException)76 RectF (android.graphics.RectF)62 Bitmap (android.graphics.Bitmap)54 Resources (android.content.res.Resources)41 View (android.view.View)41 ArrayList (java.util.ArrayList)40 ImageView (android.widget.ImageView)37 Camera (android.hardware.Camera)36 Canvas (android.graphics.Canvas)31 Matrix (android.graphics.Matrix)29 Animator (android.animation.Animator)27 SuppressLint (android.annotation.SuppressLint)27 Configuration (android.content.res.Configuration)26 IOException (java.io.IOException)24 Message (android.os.Message)22