@Override protected void onTargetFound(View targetView, RecyclerView.State state, Action action) { int[] snapDistances = calculateDistanceToFinalSnap(mRecyclerView.getLayoutManager(), targetView); final int dx = snapDistances[0]; final int dy = snapDistances[1]; final int time = calculateTimeForDeceleration(Math.max(Math.abs(dx), Math.abs(dy))); if (time > 0) { action.update(dx, dy, time, mDecelerateInterpolator); } }
public RecyclerViewSmoothScrollerActionAssert hasDuration(int duration) { isNotNull(); int actualDuration = actual.getDuration(); assertThat(actualDuration) // .overridingErrorMessage("Expected duration <%s> but was <%s>.", duration, actualDuration) // .isEqualTo(duration); return this; }
public RecyclerViewSmoothScrollerActionAssert hasDx(int dx) { isNotNull(); int actualDx = actual.getDx(); assertThat(actualDx) // .overridingErrorMessage("Expected dx <%s> but was <%s>.", dx, actualDx) // .isEqualTo(dx); return this; }
final int time = calculateTimeForDeceleration(distance); if (time > 0) { action.update(-dx, -dy, time, mDecelerateInterpolator);
case AutomaticSwipe: setting = manager.getCardStackSetting().swipeAnimationSetting; action.update( -getDx(setting), -getDy(setting), case AutomaticRewind: setting = manager.getCardStackSetting().rewindAnimationSetting; action.update( x, y, int dy = -y * 10; setting = manager.getCardStackSetting().swipeAnimationSetting; action.update( dx, dy, case ManualCancel: setting = manager.getCardStackSetting().rewindAnimationSetting; action.update( x, y,
@Override protected void onTargetFound(View targetView, RecyclerView.State state, Action action) { if (getLayoutManager() == null) { return; } int dx = calculateDxToMakeVisible(targetView, getHorizontalSnapPreference()); int dy = calculateDyToMakeVisible(targetView, getVerticalSnapPreference()); if (dx > 0) { dx = dx - getLayoutManager() .getLeftDecorationWidth(targetView); } else { dx = dx + getLayoutManager() .getRightDecorationWidth(targetView); } if (dy > 0) { dy = dy - getLayoutManager() .getTopDecorationHeight(targetView); } else { dy = dy + getLayoutManager() .getBottomDecorationHeight(targetView); } final int distance = (int) Math.sqrt(dx * dx + dy * dy); final int time = calculateTimeForDeceleration(distance); if (time > 0) { action.update(-dx, -dy, time, mDecelerateInterpolator); } } };
/** * When the target scroll position is not a child of the RecyclerView, this method calculates * a direction vector towards that child and triggers a smooth scroll. * * @see #computeScrollVectorForPosition(int) */ protected void updateActionForInterimTarget(Action action) { // find an interim target position PointF scrollVector = computeScrollVectorForPosition(getTargetPosition()); if (scrollVector == null || (scrollVector.x == 0 && scrollVector.y == 0)) { final int target = getTargetPosition(); action.jumpTo(target); stop(); return; } normalize(scrollVector); mTargetVector = scrollVector; mInterimTargetDx = (int) (TARGET_SEEK_SCROLL_DISTANCE_PX * scrollVector.x); mInterimTargetDy = (int) (TARGET_SEEK_SCROLL_DISTANCE_PX * scrollVector.y); final int time = calculateTimeForScrolling(TARGET_SEEK_SCROLL_DISTANCE_PX); // To avoid UI hiccups, trigger a smooth scroll to a distance little further than the // interim target. Since we track the distance travelled in onSeekTargetStep callback, it // won't actually scroll more than what we need. action.update((int) (mInterimTargetDx * TARGET_SEEK_EXTRA_SCROLL_RATIO), (int) (mInterimTargetDy * TARGET_SEEK_EXTRA_SCROLL_RATIO), (int) (time * TARGET_SEEK_EXTRA_SCROLL_RATIO), mLinearInterpolator); }
@Override protected void onTargetFound(View targetView, RecyclerView.State state, Action action) { int xOffset = 0; int yOffset = 0; if (llm.getOrientation() == LinearLayoutManager.VERTICAL) { yOffset = offset; } else if (llm.getOrientation() == LinearLayoutManager.HORIZONTAL) { xOffset = offset; } final int dx = calculateDxToMakeVisible(targetView, getHorizontalSnapPreference()) + xOffset; final int dy = calculateDyToMakeVisible(targetView, getVerticalSnapPreference()) + yOffset + getTopOffset(); final int distance = (int) Math.sqrt(dx * dx + dy * dy); final int time = calculateTimeForDeceleration(distance); if (time > 0) { action.update(-dx, -dy, time, mDecelerateInterpolator); } } @Override
@Override protected void onSeekTargetStep(int dx, int dy, RecyclerView.State state, Action action) { if (getChildCount() == 0) { stop(); return; } final WheelRotationDirection rotationDirection = computeRotationDirectionForPosition(getTargetPosition()); final int targetSeekScrollDistanceAsInt = (int) layoutManager.computationHelper.fromWheelRotationAngleToTraveledDistance(targetSeekScrollAngleInRad); final int time = calculateTimeForScrolling(targetSeekScrollDistanceAsInt); // final int newDy = (int) (targetSeekScrollDistanceAsInt * TARGET_SEEK_EXTRA_SCROLL_RATIO); final int newDy = rotationDirection == WheelRotationDirection.Anticlockwise ? targetSeekScrollDistanceAsInt : -targetSeekScrollDistanceAsInt; action.update(0, newDy, time, mLinearInterpolator); }
@Override protected void onTargetFound(View targetView, RecyclerView.State state, Action action) { // String title = ((WheelBigWrapperView) targetView).getTitle(); final double rotationAngleInRad = calculateAngleInRadToMakeSectorInvisible(targetView); // final int dy = (int) Math.round(layoutManager.fromWheelRotationAngleToTraveledDistance(rotationAngleInRad)); int dy = (int) layoutManager.computationHelper.fromWheelRotationAngleToTraveledDistance(rotationAngleInRad); // Log.e(TAG, "WheelSmoothScroller title [" + title + "], " + // "dy [" + dy + "], " + // "rotationAngleInRad [" + WheelComputationHelper.radToDegree(rotationAngleInRad) + "]"); final int time = calculateTimeForDeceleration(dy); if (time > 0) { action.update(0, -dy, time, decelerateInterpolator); } }
@Override protected void onTargetFound(View targetView, RecyclerView.State state, Action action) { int[] snapDistances = calculateDistanceToFinalSnap(mRecyclerView.getLayoutManager(), targetView); final int dx = snapDistances[0]; final int dy = snapDistances[1]; final int time = calculateTimeForDeceleration(Math.max(Math.abs(dx), Math.abs(dy))); if (time > 0) { action.update(dx, dy, time, mDecelerateInterpolator); } }
@Override protected void onTargetFound(View targetView, RecyclerView.State state, Action action) { int[] snapDistances = calculateDistanceToFinalSnap(mRecyclerView.getLayoutManager(), targetView); final int dx = snapDistances[0]; final int dy = snapDistances[1]; final int time = calculateTimeForDeceleration(Math.max(Math.abs(dx), Math.abs(dy))); if (time > 0) { action.update(dx, dy, time, mDecelerateInterpolator); } }
@Override protected void onTargetFound(View targetView, RecyclerView.State state, Action action) { final int dx = calculateDxToMakeVisible(targetView, getHorizontalSnapPreference()); final int dy = calculateDyToMakeVisible(targetView, getVerticalSnapPreference()); action.update(-dx, -dy, snapDuration, snapInterpolator); }
public RecyclerViewSmoothScrollerActionAssert hasInterpolator(Interpolator interpolator) { isNotNull(); Interpolator actualInterpolator = actual.getInterpolator(); assertThat(actualInterpolator) // .overridingErrorMessage("Expected interpolator <%s> but was <%s>.", interpolator, actualInterpolator) // .isEqualTo(interpolator); return this; } }
@Override protected void onTargetFound(View targetView, RecyclerView.State state, Action action) { int[] snapDistances = calculateDistanceToFinalSnap(mRecyclerView.getLayoutManager(), targetView); final int dx = snapDistances[0]; final int dy = snapDistances[1]; final int time = calculateTimeForDeceleration(Math.max(Math.abs(dx), Math.abs(dy))); if (time > 0) { action.update(dx, dy, time, mDecelerateInterpolator); } }
@Override protected void onTargetFound(View targetView, RecyclerView.State state, Action action) { final int dx = calculateDxToMakeCentral(targetView); final int dy = calculateDyToMakeCentral(targetView); final int distance = (int) Math.sqrt(dx * dx + dy * dy); final int time = calculateTimeForDeceleration(distance); if (time > 0) { action.update(-dx, -dy, time, mDecelerateInterpolator); } } }
public RecyclerViewSmoothScrollerActionAssert hasDuration(int duration) { isNotNull(); int actualDuration = actual.getDuration(); assertThat(actualDuration) // .overridingErrorMessage("Expected duration <%s> but was <%s>.", duration, actualDuration) // .isEqualTo(duration); return this; }
public RecyclerViewSmoothScrollerActionAssert hasDx(int dx) { isNotNull(); int actualDx = actual.getDx(); assertThat(actualDx) // .overridingErrorMessage("Expected dx <%s> but was <%s>.", dx, actualDx) // .isEqualTo(dx); return this; }
public RecyclerViewSmoothScrollerActionAssert hasDy(int dy) { isNotNull(); int actualDy = actual.getDy(); assertThat(actualDy) // .overridingErrorMessage("Expected dy <%s> but was <%s>.", dy, actualDy) // .isEqualTo(dy); return this; }
@Override protected void onSeekTargetStep(int dx, int dy, RecyclerView.State state, Action action) { if (type == ScrollType.AutomaticRewind) { RewindAnimationSetting setting = manager.getCardStackSetting().rewindAnimationSetting; action.update( -getDx(setting), -getDy(setting), setting.getDuration(), setting.getInterpolator() ); } }