alexandroid/decompiled/jadx/sources/androidx/transition/GhostViewPort.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

176 lines
6.5 KiB
Java

package androidx.transition;
import android.annotation.SuppressLint;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import rx.Single$$ExternalSyntheticBUOutline0;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
@SuppressLint({"ViewConstructor"})
/* loaded from: classes14.dex */
class GhostViewPort extends ViewGroup implements GhostView {
@Nullable
private Matrix mMatrix;
private final ViewTreeObserver.OnPreDrawListener mOnPreDrawListener;
int mReferences;
ViewGroup mStartParent;
View mStartView;
final View mView;
public GhostViewPort(View view) {
super(view.getContext());
this.mOnPreDrawListener = new ViewTreeObserver.OnPreDrawListener() { // from class: androidx.transition.GhostViewPort.1
@Override // android.view.ViewTreeObserver.OnPreDrawListener
public boolean onPreDraw() {
View view2;
GhostViewPort.this.postInvalidateOnAnimation();
GhostViewPort ghostViewPort = GhostViewPort.this;
ViewGroup viewGroup = ghostViewPort.mStartParent;
if (viewGroup == null || (view2 = ghostViewPort.mStartView) == null) {
return true;
}
viewGroup.endViewTransition(view2);
GhostViewPort.this.mStartParent.postInvalidateOnAnimation();
GhostViewPort ghostViewPort2 = GhostViewPort.this;
ghostViewPort2.mStartParent = null;
ghostViewPort2.mStartView = null;
return true;
}
};
this.mView = view;
setWillNotDraw(false);
setClipChildren(false);
setLayerType(2, null);
}
public static GhostViewPort addGhost(View view, ViewGroup viewGroup, Matrix matrix) {
int i;
GhostViewHolder ghostViewHolder;
if (!(view.getParent() instanceof ViewGroup)) {
Single$$ExternalSyntheticBUOutline0.m$3("Ghosted views must be parented by a ViewGroup");
return null;
}
GhostViewHolder holder = GhostViewHolder.getHolder(viewGroup);
GhostViewPort ghostView = getGhostView(view);
if (ghostView == null || (ghostViewHolder = (GhostViewHolder) ghostView.getParent()) == holder) {
i = 0;
} else {
i = ghostView.mReferences;
ghostViewHolder.removeView(ghostView);
ghostView = null;
}
if (ghostView == null) {
if (matrix == null) {
matrix = new Matrix();
calculateMatrix(view, viewGroup, matrix);
}
ghostView = new GhostViewPort(view);
ghostView.setMatrix(matrix);
if (holder == null) {
holder = new GhostViewHolder(viewGroup);
} else {
holder.popToOverlayTop();
}
copySize(viewGroup, holder);
copySize(viewGroup, ghostView);
holder.addGhostView(ghostView);
ghostView.mReferences = i;
} else if (matrix != null) {
ghostView.setMatrix(matrix);
}
ghostView.mReferences++;
return ghostView;
}
public static void calculateMatrix(View view, ViewGroup viewGroup, Matrix matrix) {
ViewGroup viewGroup2 = (ViewGroup) view.getParent();
matrix.reset();
ViewUtils.transformMatrixToGlobal(viewGroup2, matrix);
matrix.preTranslate(-viewGroup2.getScrollX(), -viewGroup2.getScrollY());
ViewUtils.transformMatrixToLocal(viewGroup, matrix);
}
public static void copySize(View view, View view2) {
ViewUtils.setLeftTopRightBottom(view2, view2.getLeft(), view2.getTop(), view.getWidth() + view2.getLeft(), view.getHeight() + view2.getTop());
}
public static GhostViewPort getGhostView(View view) {
return (GhostViewPort) view.getTag(R.id.ghost_view);
}
public static void removeGhost(View view) {
GhostViewPort ghostView = getGhostView(view);
if (ghostView != null) {
int i = ghostView.mReferences - 1;
ghostView.mReferences = i;
if (i <= 0) {
((GhostViewHolder) ghostView.getParent()).removeView(ghostView);
}
}
}
public static void setGhostView(@NonNull View view, @Nullable GhostViewPort ghostViewPort) {
view.setTag(R.id.ghost_view, ghostViewPort);
}
@Override // android.view.ViewGroup, android.view.View
public void onAttachedToWindow() {
super.onAttachedToWindow();
setGhostView(this.mView, this);
this.mView.getViewTreeObserver().addOnPreDrawListener(this.mOnPreDrawListener);
ViewUtils.setTransitionVisibility(this.mView, 4);
if (this.mView.getParent() != null) {
((View) this.mView.getParent()).invalidate();
}
}
@Override // android.view.ViewGroup, android.view.View
public void onDetachedFromWindow() {
this.mView.getViewTreeObserver().removeOnPreDrawListener(this.mOnPreDrawListener);
ViewUtils.setTransitionVisibility(this.mView, 0);
setGhostView(this.mView, null);
if (this.mView.getParent() != null) {
((View) this.mView.getParent()).invalidate();
}
super.onDetachedFromWindow();
}
@Override // android.view.View
public void onDraw(@NonNull Canvas canvas) {
CanvasUtils.enableZ(canvas, true);
canvas.setMatrix(this.mMatrix);
ViewUtils.setTransitionVisibility(this.mView, 0);
this.mView.invalidate();
ViewUtils.setTransitionVisibility(this.mView, 4);
drawChild(canvas, this.mView, getDrawingTime());
CanvasUtils.enableZ(canvas, false);
}
@Override // androidx.transition.GhostView
public void reserveEndViewTransition(ViewGroup viewGroup, View view) {
this.mStartParent = viewGroup;
this.mStartView = view;
}
public void setMatrix(@NonNull Matrix matrix) {
this.mMatrix = matrix;
}
@Override // android.view.View, androidx.transition.GhostView
public void setVisibility(int i) {
super.setVisibility(i);
if (getGhostView(this.mView) == this) {
ViewUtils.setTransitionVisibility(this.mView, i == 0 ? 4 : 0);
}
}
@Override // android.view.ViewGroup, android.view.View
public void onLayout(boolean z, int i, int i2, int i3, int i4) {
}
}