public class CubeTransformer extends BaseTransformer { @Override protected void onTransform(View view, float position) { float rotationY = (float) mapValueFromRangeToRange((double) position, -1.0d, 1.0d, -90.0d, 90.0d); view.setCameraDistance((float) dp(5600)); if (position > 0.0f) { view.setRotationY(rotationY); view.setPivotX(0.0f); view.setPivotY(((float) view.getHeight()) * 0.5f); } else if (position < 0.0f) { view.setRotationY(rotationY); view.setPivotX((float) view.getWidth()); view.setPivotY(((float) view.getHeight()) * 0.5f); } else { view.setRotationY(0.0f); view.setPivotX(((float) view.getWidth()) * 0.5f); view.setPivotY(((float) view.getHeight()) * 0.5f); } } @Override public boolean isPagingEnabled() { return true; } @SuppressWarnings("SameParameterValue") private static double mapValueFromRangeToRange(double value, double fromLow, double fromHigh, double toLow, double toHigh) { return (((value - fromLow) / (fromHigh - fromLow)) * (toHigh - toLow)) + toLow; } }