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);
}
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);
}
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;
}
}
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);
}
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);
}
Aggregations