use of android.graphics.RectF in project ENViews by codeestX.
the class ENDownloadView method onSizeChanged.
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
mWidth = w;
mHeight = h;
mCenterX = mWidth / 2;
mCenterY = mHeight / 2;
mCircleRadius = mWidth * 5 / 12;
mBaseLength = mCircleRadius / 3;
mBaseRippleLength = 4.4f * mBaseLength / 12;
mCurrentRippleX = mCenterX - mBaseRippleLength * 10;
mRectF = new RectF(mCenterX - mCircleRadius, mCenterY - mCircleRadius, mCenterX + mCircleRadius, mCenterY + mCircleRadius);
mClipRectF = new RectF(mCenterX - 6 * mBaseRippleLength, 0, mCenterX + 6 * mBaseRippleLength, mHeight);
}
use of android.graphics.RectF in project ENViews by codeestX.
the class ENPlayView method onSizeChanged.
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
mWidth = w * 9 / 10;
mHeight = h * 9 / 10;
mCircleRadius = mWidth / 10;
mCenterX = w / 2;
mCenterY = h / 2;
mRectF = new RectF(mCenterX - mCircleRadius, mCenterY + 0.6f * mCircleRadius, mCenterX + mCircleRadius, mCenterY + 2.6f * mCircleRadius);
mBgRectF = new RectF(mCenterX - mWidth / 2, mCenterY - mHeight / 2, mCenterX + mWidth / 2, mCenterY + mHeight / 2);
mPath.moveTo(mCenterX - mCircleRadius, mCenterY + 1.8f * mCircleRadius);
mPath.lineTo(mCenterX - mCircleRadius, mCenterY - 1.8f * mCircleRadius);
mPath.lineTo(mCenterX + mCircleRadius, mCenterY);
mPath.close();
mPathMeasure.setPath(mPath, false);
mPathLength = mPathMeasure.getLength();
}
use of android.graphics.RectF in project ENViews by codeestX.
the class ENSearchView method onSizeChanged.
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
mWidth = w;
mHeight = h;
mCenterX = mWidth / 2;
mCenterY = mHeight / 2;
mCircleRadius = mWidth / 4;
mRectF = new RectF(mCenterX - 0.95f * mCircleRadius, mCenterY - 0.95f * mCircleRadius, mCenterX + 0.95f * mCircleRadius, mCenterY + 0.95f * mCircleRadius);
mPath.moveTo(mCenterX + 2.2f * mCircleRadius / (float) Math.sqrt(2), mCenterY + 2.2f * mCircleRadius / (float) Math.sqrt(2));
mPath.lineTo(mCenterX, mCenterY);
mPath.lineTo(mCenterX - 0.45f * mCircleRadius * (float) Math.sqrt(3), mCenterY + 0.45f * mCircleRadius);
mPath.lineTo(mCenterX - 0.45f * mCircleRadius * (float) Math.sqrt(3), mCenterY - 0.45f * mCircleRadius);
mPath.lineTo(mCenterX + 0.45f * mCircleRadius * (float) Math.sqrt(3), mCenterY);
mPath.lineTo(mCenterX, mCenterY);
mPath.lineTo(mCenterX + 2.2f * mCircleRadius / (float) Math.sqrt(2), mCenterY + 2.2f * mCircleRadius / (float) Math.sqrt(2));
mPathMeasure.setPath(mPath, false);
mPathLength = mPathMeasure.getLength();
}
use of android.graphics.RectF in project cw-omnibus by commonsguy.
the class AnimatorProxy method invalidateAfterUpdate.
private void invalidateAfterUpdate() {
View view = mView.get();
if (view == null) {
return;
}
View parent = (View) view.getParent();
if (parent == null) {
return;
}
view.setAnimation(this);
final RectF after = mAfter;
computeRect(after, view);
after.union(mBefore);
parent.invalidate((int) FloatMath.floor(after.left), (int) FloatMath.floor(after.top), (int) FloatMath.ceil(after.right), (int) FloatMath.ceil(after.bottom));
}
use of android.graphics.RectF in project Launcher3 by chislon.
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] = FloatMath.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] = FloatMath.ceil(adjustment[dim]);
}
mInverseRotateMatrix.mapPoints(adjustment);
mCenterX += adjustment[0];
mCenterY += adjustment[1];
updateCenter();
}
}
mLastX = x;
mLastY = y;
return true;
}
Aggregations