List of usage examples for android.graphics PointF PointF
public PointF(float x, float y)
From source file:android.support.v7.widget.StaggeredGridLayoutManager.java
@Override public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) { LinearSmoothScroller scroller = new LinearSmoothScroller(recyclerView.getContext()) { @Override/*from www . j ava2 s .com*/ public PointF computeScrollVectorForPosition(int targetPosition) { final int direction = calculateScrollDirectionForPosition(targetPosition); if (direction == 0) { return null; } if (mOrientation == HORIZONTAL) { return new PointF(direction, 0); } else { return new PointF(0, direction); } } }; scroller.setTargetPosition(position); startSmoothScroll(scroller); }
From source file:com.bizcom.vc.widget.cus.SubsamplingScaleImageView.java
public PointF getCenter() { return new PointF(centerX, centerY); }
From source file:android.support.v17.leanback.widget.GridLayoutManager.java
void startPositionSmoothScroller(int position) { LinearSmoothScroller linearSmoothScroller = new GridLinearSmoothScroller() { @Override// w w w . j av a 2s . c o m public PointF computeScrollVectorForPosition(int targetPosition) { if (getChildCount() == 0) { return null; } final int firstChildPos = getPosition(getChildAt(0)); // TODO We should be able to deduce direction from bounds of current and target // focus, rather than making assumptions about positions and directionality final boolean isStart = mReverseFlowPrimary ? targetPosition > firstChildPos : targetPosition < firstChildPos; final int direction = isStart ? -1 : 1; if (mOrientation == HORIZONTAL) { return new PointF(direction, 0); } else { return new PointF(0, direction); } } }; linearSmoothScroller.setTargetPosition(position); startSmoothScroll(linearSmoothScroller); }
From source file:me.ccrama.redditslide.Views.SubsamplingScaleImageView.java
/** * Get the translation required to place a given source coordinate at the center of the screen, with the center * adjusted for asymmetric padding. Accepts the desired scale as an argument, so this is independent of current * translate and scale. The result is fitted to bounds, putting the image point as near to the screen center as permitted. *//* w ww. j ava 2s . com*/ private PointF vTranslateForSCenter(float sCenterX, float sCenterY, float scale) { int vxCenter = getPaddingLeft() + (getWidth() - getPaddingRight() - getPaddingLeft()) / 2; int vyCenter = getPaddingTop() + (getHeight() - getPaddingBottom() - getPaddingTop()) / 2; if (satTemp == null) { satTemp = new ScaleAndTranslate(0, new PointF(0, 0)); } satTemp.scale = scale; satTemp.vTranslate.set(vxCenter - (sCenterX * scale), vyCenter - (sCenterY * scale)); fitToBounds(true, satTemp); return satTemp.vTranslate; }
From source file:cc.flydev.launcher.Page.java
private PointF isFlingingToDelete() { ViewConfiguration config = ViewConfiguration.get(getContext()); mVelocityTracker.computeCurrentVelocity(1000, config.getScaledMaximumFlingVelocity()); if (mVelocityTracker.getYVelocity() < mFlingToDeleteThresholdVelocity) { // Do a quick dot product test to ensure that we are flinging upwards PointF vel = new PointF(mVelocityTracker.getXVelocity(), mVelocityTracker.getYVelocity()); PointF upVec = new PointF(0f, -1f); float theta = (float) Math .acos(((vel.x * upVec.x) + (vel.y * upVec.y)) / (vel.length() * upVec.length())); if (theta <= Math.toRadians(FLING_TO_DELETE_MAX_FLING_DEGREES)) { return vel; }//w w w . j ava2 s . c o m } return null; }
From source file:com.n2hsu.launcher.Page.java
private PointF isFlingingToDelete() { ViewConfiguration config = ViewConfiguration.get(getContext()); mVelocityTracker.computeCurrentVelocity(1000, config.getScaledMaximumFlingVelocity()); if (mVelocityTracker.getYVelocity() < mFlingToDeleteThresholdVelocity) { // Do a quick dot product test to ensure that we are flinging // upwards PointF vel = new PointF(mVelocityTracker.getXVelocity(), mVelocityTracker.getYVelocity()); PointF upVec = new PointF(0f, -1f); float theta = (float) Math .acos(((vel.x * upVec.x) + (vel.y * upVec.y)) / (vel.length() * upVec.length())); if (theta <= Math.toRadians(FLING_TO_DELETE_MAX_FLING_DEGREES)) { return vel; }// ww w . ja v a 2 s . com } return null; }
From source file:me.ccrama.redditslide.Views.SubsamplingScaleImageView.java
/** * Fully zoom out and return the image to the middle of the screen. This might be useful if you have a view pager * and want images to be reset when the user has moved to another page. *//*w ww .j av a 2s .com*/ public final void resetScaleAndCenter() { this.anim = null; this.pendingScale = limitedScale(0); if (isReady()) { this.sPendingCenter = new PointF(sWidth() / 2, sHeight() / 2); } else { this.sPendingCenter = new PointF(0, 0); } invalidate(); }