Search in sources :

Example 91 with Point

use of android.graphics.Point in project ZI by yixia.

the class ColorPickerView method onTouchEvent.

@Override
public boolean onTouchEvent(MotionEvent event) {
    boolean update = false;
    switch(event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            mStartTouchPoint = new Point((int) event.getX(), (int) event.getY());
            update = moveTrackersIfNeeded(event);
            break;
        case MotionEvent.ACTION_MOVE:
            update = moveTrackersIfNeeded(event);
            break;
        case MotionEvent.ACTION_UP:
            mStartTouchPoint = null;
            update = moveTrackersIfNeeded(event);
            break;
    }
    if (update) {
        if (mListener != null) {
            mListener.onColorChanged(Color.HSVToColor(mAlpha, new float[] { mHue, mSat, mVal }));
        }
        invalidate();
        return true;
    }
    return super.onTouchEvent(event);
}
Also used : Point(android.graphics.Point)

Example 92 with Point

use of android.graphics.Point in project ZI by yixia.

the class ColorPickerView method drawHuePanel.

private void drawHuePanel(Canvas canvas) {
    final RectF rect = mHueRect;
    if (BORDER_WIDTH_PX > 0) {
        mBorderPaint.setColor(mBorderColor);
        canvas.drawRect(rect.left - BORDER_WIDTH_PX, rect.top - BORDER_WIDTH_PX, rect.right + BORDER_WIDTH_PX, rect.bottom + BORDER_WIDTH_PX, mBorderPaint);
    }
    if (mHueShader == null) {
        mHueShader = new LinearGradient(rect.left, rect.top, rect.left, rect.bottom, buildHueColorArray(), null, TileMode.CLAMP);
        mHuePaint.setShader(mHueShader);
    }
    canvas.drawRect(rect, mHuePaint);
    float rectHeight = 4 * mDensity / 2;
    Point p = hueToPoint(mHue);
    RectF r = new RectF();
    r.left = rect.left - RECTANGLE_TRACKER_OFFSET;
    r.right = rect.right + RECTANGLE_TRACKER_OFFSET;
    r.top = p.y - rectHeight;
    r.bottom = p.y + rectHeight;
    canvas.drawRoundRect(r, 2, 2, mHueTrackerPaint);
}
Also used : RectF(android.graphics.RectF) LinearGradient(android.graphics.LinearGradient) Point(android.graphics.Point)

Example 93 with Point

use of android.graphics.Point in project PhotoNoter by yydcdut.

the class MaterialRippleLayout method onTouchEvent.

@Override
public boolean onTouchEvent(MotionEvent event) {
    //父类的返回方法
    boolean superOnTouchEvent = super.onTouchEvent(event);
    //自己是enable并且子view不能enable的话,返回父类的事件
    if (!isEnabled() || !childView.isEnabled()) {
        return superOnTouchEvent;
    }
    //touch的地方是不是在边界内
    boolean isEventInBounds = bounds.contains((int) event.getX(), (int) event.getY());
    //如果在边界内
    if (isEventInBounds) {
        previousCoords.set(currentCoords.x, currentCoords.y);
        currentCoords.set((int) event.getX(), (int) event.getY());
    }
    boolean gestureResult = gestureDetector.onTouchEvent(event);
    if (gestureResult || mHasPerformedLongPress) {
        return true;
    } else {
        int action = event.getActionMasked();
        switch(action) {
            case MotionEvent.ACTION_UP:
                pendingClickEvent = new PerformClickEvent();
                if (prepressed) {
                    childView.setPressed(true);
                    postDelayed(new Runnable() {

                        @Override
                        public void run() {
                            childView.setPressed(false);
                        }
                    }, ViewConfiguration.getPressedStateDuration());
                }
                if (isEventInBounds) {
                    startRipple(pendingClickEvent);
                } else if (!rippleHover) {
                    setRadius(0);
                }
                if (!rippleDelayClick && isEventInBounds) {
                    pendingClickEvent.run();
                }
                cancelPressedEvent();
                break;
            case MotionEvent.ACTION_DOWN:
                setPositionInAdapter();
                eventCancelled = false;
                pendingPressEvent = new PressedEvent(event);
                if (isInScrollingContainer()) {
                    cancelPressedEvent();
                    prepressed = true;
                    postDelayed(pendingPressEvent, ViewConfiguration.getTapTimeout());
                } else {
                    pendingPressEvent.run();
                }
                break;
            case MotionEvent.ACTION_CANCEL:
                if (rippleInAdapter) {
                    // dont use current coords in adapter since they tend to jump drastically on scroll
                    currentCoords.set(previousCoords.x, previousCoords.y);
                    previousCoords = new Point();
                }
                childView.onTouchEvent(event);
                if (rippleHover) {
                    if (!prepressed) {
                        startRipple(null);
                    }
                } else {
                    childView.setPressed(false);
                }
                cancelPressedEvent();
                break;
            case MotionEvent.ACTION_MOVE:
                if (rippleHover) {
                    if (isEventInBounds && !eventCancelled) {
                        invalidate();
                    } else if (!isEventInBounds) {
                        startRipple(null);
                    }
                }
                if (!isEventInBounds) {
                    cancelPressedEvent();
                    if (hoverAnimator != null) {
                        hoverAnimator.cancel();
                    }
                    childView.onTouchEvent(event);
                    eventCancelled = true;
                }
                break;
        }
        return true;
    }
}
Also used : Point(android.graphics.Point) Point(android.graphics.Point) Paint(android.graphics.Paint)

Example 94 with Point

use of android.graphics.Point in project PhotoNoter by yydcdut.

the class MaterialRippleLayout method performRipple.

public void performRipple() {
    currentCoords = new Point(getWidth() / 2, getHeight() / 2);
    startRipple(null);
}
Also used : Point(android.graphics.Point)

Example 95 with Point

use of android.graphics.Point in project PhotoNoter by yydcdut.

the class DetailActivity method closeRevealColorView.

/**
     * 关闭activity之后的动画或者onActivityResult
     */
public void closeRevealColorView() {
    mIsIgnoreBackPress = true;
    final Point p = getLocationInView(mRevealView, mFab);
    mRevealView.hide(p.x, p.y, Color.TRANSPARENT, Const.RADIUS, Const.DURATION, () -> mIsIgnoreBackPress = false);
}
Also used : 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