private static void transformMatrixToPager(Matrix matrix, View view, ViewPager pager) { if (view.getParent() instanceof View) { View parent = (View) view.getParent(); if (parent != pager) { transformMatrixToPager(matrix, parent, pager); } matrix.preTranslate(-parent.getScrollX(), -parent.getScrollY()); } matrix.preTranslate(view.getLeft(), view.getTop()); matrix.preConcat(view.getMatrix()); }
private void captureValues(@NonNull TransitionValues transitionValues) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { return; } View view = transitionValues.view; if (view.getVisibility() == View.GONE) { return; } transitionValues.values.put(PROPNAME_PARENT, view.getParent()); Transforms transforms = new Transforms(view); transitionValues.values.put(PROPNAME_TRANSFORMS, transforms); Matrix matrix = view.getMatrix(); if (matrix == null || matrix.isIdentity()) { matrix = null; } else { matrix = new Matrix(matrix); } transitionValues.values.put(PROPNAME_MATRIX, matrix); if (mReparent) { Matrix parentMatrix = new Matrix(); ViewGroup parent = (ViewGroup) view.getParent(); ViewUtils.transformMatrixToGlobal(parent, parentMatrix); parentMatrix.preTranslate(-parent.getScrollX(), -parent.getScrollY()); transitionValues.values.put(PROPNAME_PARENT_MATRIX, parentMatrix); transitionValues.values.put(PROPNAME_INTERMEDIATE_MATRIX, view.getTag(R.id.transitionTransform)); transitionValues.values.put(PROPNAME_INTERMEDIATE_PARENT_MATRIX, view.getTag(R.id.parentMatrix)); } }
@Override protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) { if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null)) { ShadowView shadowView = (ShadowView) child; shadowView.drawShadow(canvas); } if (child instanceof RippleView) { RippleView rippleView = (RippleView) child; RippleDrawable rippleDrawable = rippleView.getRippleDrawable(); if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) { int saveCount = canvas.save(); canvas.translate(child.getLeft(), child.getTop()); canvas.concat(child.getMatrix()); rippleDrawable.draw(canvas); canvas.restoreToCount(saveCount); } } return super.drawChild(canvas, child, drawingTime); }
@Override protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) { if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null)) { ShadowView shadowView = (ShadowView) child; shadowView.drawShadow(canvas); } if (child instanceof RippleView) { RippleView rippleView = (RippleView) child; RippleDrawable rippleDrawable = rippleView.getRippleDrawable(); if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) { int saveCount = canvas.save(); canvas.translate(child.getLeft(), child.getTop()); canvas.concat(child.getMatrix()); rippleDrawable.draw(canvas); canvas.restoreToCount(saveCount); } } return super.drawChild(canvas, child, drawingTime); }
@Override protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) { if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null)) { ShadowView shadowView = (ShadowView) child; shadowView.drawShadow(canvas); } if (child instanceof RippleView) { RippleView rippleView = (RippleView) child; RippleDrawable rippleDrawable = rippleView.getRippleDrawable(); if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) { int saveCount = canvas.save(); canvas.translate(child.getLeft(), child.getTop()); canvas.concat(child.getMatrix()); rippleDrawable.draw(canvas); canvas.restoreToCount(saveCount); } } return super.drawChild(canvas, child, drawingTime); }
@Override protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) { if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null)) { ShadowView shadowView = (ShadowView) child; shadowView.drawShadow(canvas); } if (child instanceof RippleView) { RippleView rippleView = (RippleView) child; RippleDrawable rippleDrawable = rippleView.getRippleDrawable(); if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) { int saveCount = canvas.save(); canvas.translate(child.getLeft(), child.getTop()); canvas.concat(child.getMatrix()); rippleDrawable.draw(canvas); canvas.restoreToCount(saveCount); } } return super.drawChild(canvas, child, drawingTime); }
@Override protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) { if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null)) { ShadowView shadowView = (ShadowView) child; shadowView.drawShadow(canvas); } if (child instanceof RippleView) { RippleView rippleView = (RippleView) child; RippleDrawable rippleDrawable = rippleView.getRippleDrawable(); if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) { int saveCount = canvas.save(); canvas.translate(child.getLeft(), child.getTop()); canvas.concat(child.getMatrix()); rippleDrawable.draw(canvas); canvas.restoreToCount(saveCount); } } return super.drawChild(canvas, child, drawingTime); }
@Override protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) { if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null)) { ShadowView shadowView = (ShadowView) child; shadowView.drawShadow(canvas); } if (child instanceof RippleView) { RippleView rippleView = (RippleView) child; RippleDrawable rippleDrawable = rippleView.getRippleDrawable(); if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) { int saveCount = canvas.save(); canvas.translate(child.getLeft(), child.getTop()); canvas.concat(child.getMatrix()); rippleDrawable.draw(canvas); canvas.restoreToCount(saveCount); } } return super.drawChild(canvas, child, drawingTime); }
@Override protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) { if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null)) { ShadowView shadowView = (ShadowView) child; shadowView.drawShadow(canvas); } if (child instanceof RippleView) { RippleView rippleView = (RippleView) child; RippleDrawable rippleDrawable = rippleView.getRippleDrawable(); if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) { int saveCount = canvas.save(); canvas.translate(child.getLeft(), child.getTop()); canvas.concat(child.getMatrix()); rippleDrawable.draw(canvas); canvas.restoreToCount(saveCount); } } return super.drawChild(canvas, child, drawingTime); }
@Override protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) { // TODO: why isShown() returns false after being reattached? if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null && !Carbon.IS_PIE_OR_HIGHER)) { ShadowView shadowView = (ShadowView) child; shadowView.drawShadow(canvas); } if (child instanceof RippleView) { RippleView rippleView = (RippleView) child; RippleDrawable rippleDrawable = rippleView.getRippleDrawable(); if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) { int saveCount = canvas.save(); canvas.translate(child.getLeft(), child.getTop()); canvas.concat(child.getMatrix()); rippleDrawable.draw(canvas); canvas.restoreToCount(saveCount); } } return super.drawChild(canvas, child, drawingTime); }
@Override public boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) { // TODO: why isShown() returns false after being reattached? if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null)) { ShadowView shadowView = (ShadowView) child; shadowView.drawShadow(canvas); } if (child instanceof RippleView) { RippleView rippleView = (RippleView) child; RippleDrawable rippleDrawable = rippleView.getRippleDrawable(); if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) { int saveCount = canvas.save(); canvas.translate(child.getLeft(), child.getTop()); canvas.concat(child.getMatrix()); rippleDrawable.draw(canvas); canvas.restoreToCount(saveCount); } } return super.drawChild(canvas, child, drawingTime); }
@Override protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) { // TODO: why isShown() returns false after being reattached? if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null)) { ShadowView shadowView = (ShadowView) child; shadowView.drawShadow(canvas); } if (child instanceof RippleView) { RippleView rippleView = (RippleView) child; RippleDrawable rippleDrawable = rippleView.getRippleDrawable(); if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) { int saveCount = canvas.save(); canvas.translate(child.getLeft(), child.getTop()); canvas.concat(child.getMatrix()); rippleDrawable.draw(canvas); canvas.restoreToCount(saveCount); } } return super.drawChild(canvas, child, drawingTime); }
@Override protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) { // TODO: why isShown() returns false after being reattached? if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null)) { ShadowView shadowView = (ShadowView) child; shadowView.drawShadow(canvas); } if (child instanceof RippleView) { RippleView rippleView = (RippleView) child; RippleDrawable rippleDrawable = rippleView.getRippleDrawable(); if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) { int saveCount = canvas.save(); canvas.translate(child.getLeft(), child.getTop()); canvas.concat(child.getMatrix()); rippleDrawable.draw(canvas); canvas.restoreToCount(saveCount); } } return super.drawChild(canvas, child, drawingTime); }
@Override protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) { // TODO: why isShown() returns false after being reattached? if (child instanceof ShadowView && (!Carbon.IS_LOLLIPOP_OR_HIGHER || ((RenderingModeView) child).getRenderingMode() == RenderingMode.Software || ((ShadowView) child).getElevationShadowColor() != null)) { ShadowView shadowView = (ShadowView) child; shadowView.drawShadow(canvas); } if (child instanceof RippleView) { RippleView rippleView = (RippleView) child; RippleDrawable rippleDrawable = rippleView.getRippleDrawable(); if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) { int saveCount = canvas.save(); canvas.translate(child.getLeft(), child.getTop()); canvas.concat(child.getMatrix()); rippleDrawable.draw(canvas); canvas.restoreToCount(saveCount); } } return super.drawChild(canvas, child, drawingTime); }
private static void adjustTranslation(View view, float deltaX, float deltaY) { float[] deltaVector = {deltaX, deltaY}; view.getMatrix().mapVectors(deltaVector); view.setTranslationX(view.getTranslationX() + deltaVector[0]); view.setTranslationY(view.getTranslationY() + deltaVector[1]); }
private static void offsetDescendantMatrix(ViewParent target, View view, Matrix m) { final ViewParent parent = view.getParent(); if (parent instanceof View && parent != target) { final View vp = (View) parent; offsetDescendantMatrix(target, vp, m); m.preTranslate(-vp.getScrollX(), -vp.getScrollY()); } m.preTranslate(view.getLeft(), view.getTop()); if (!view.getMatrix().isIdentity()) { m.preConcat(view.getMatrix()); } } }
private static void computeRenderOffset(View view, float pivotX, float pivotY) { if (view.getPivotX() == pivotX && view.getPivotY() == pivotY) { return; } float[] prevPoint = {0.0f, 0.0f}; view.getMatrix().mapPoints(prevPoint); view.setPivotX(pivotX); view.setPivotY(pivotY); float[] currPoint = {0.0f, 0.0f}; view.getMatrix().mapPoints(currPoint); float offsetX = currPoint[0] - prevPoint[0]; float offsetY = currPoint[1] - prevPoint[1]; view.setTranslationX(view.getTranslationX() - offsetX); view.setTranslationY(view.getTranslationY() - offsetY); }
private float[] mapPointFromParentToView(View v, float x, float y) { sTmpPoint[0] = x - v.getLeft(); sTmpPoint[1] = y - v.getTop(); v.getMatrix().invert(sTmpInvMatrix); sTmpInvMatrix.mapPoints(sTmpPoint); return sTmpPoint; }
private float[] mapPointFromParentToView(View v, float x, float y) { sTmpPoint[0] = x - v.getLeft(); sTmpPoint[1] = y - v.getTop(); v.getMatrix().invert(sTmpInvMatrix); sTmpInvMatrix.mapPoints(sTmpPoint); return sTmpPoint; }
private float[] mapPointFromParentToView(View v, float x, float y) { sTmpPoint[0] = x - v.getLeft(); sTmpPoint[1] = y - v.getTop(); v.getMatrix().invert(sTmpInvMatrix); sTmpInvMatrix.mapPoints(sTmpPoint); return sTmpPoint; }