alexandroid/decompiled/jadx/sources/androidx/transition/GhostViewHolder.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

143 lines
4.7 KiB
Java

package androidx.transition;
import android.annotation.SuppressLint;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import androidx.annotation.DoNotInline;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import java.util.ArrayList;
import rx.Single$$ExternalSyntheticBUOutline0;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
@SuppressLint({"ViewConstructor"})
/* loaded from: classes14.dex */
class GhostViewHolder extends FrameLayout {
private boolean mAttached;
@NonNull
private ViewGroup mParent;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
@RequiresApi(21)
public static class Api21Impl {
private Api21Impl() {
}
@DoNotInline
public static float getZ(View view) {
return view.getZ();
}
}
public GhostViewHolder(ViewGroup viewGroup) {
super(viewGroup.getContext());
setClipChildren(false);
this.mParent = viewGroup;
viewGroup.setTag(R.id.ghost_view_holder, this);
this.mParent.getOverlay().add(this);
this.mAttached = true;
}
public static GhostViewHolder getHolder(@NonNull ViewGroup viewGroup) {
return (GhostViewHolder) viewGroup.getTag(R.id.ghost_view_holder);
}
private int getInsertIndex(ArrayList<View> arrayList) {
ArrayList arrayList2 = new ArrayList();
int childCount = getChildCount() - 1;
int i = 0;
while (i <= childCount) {
int i2 = (i + childCount) / 2;
getParents(((GhostViewPort) getChildAt(i2)).mView, arrayList2);
if (isOnTop(arrayList, (ArrayList<View>) arrayList2)) {
i = i2 + 1;
} else {
childCount = i2 - 1;
}
arrayList2.clear();
}
return i;
}
private static void getParents(View view, ArrayList<View> arrayList) {
Object parent = view.getParent();
if (parent instanceof ViewGroup) {
getParents((View) parent, arrayList);
}
arrayList.add(view);
}
private static boolean isOnTop(ArrayList<View> arrayList, ArrayList<View> arrayList2) {
if (arrayList.isEmpty() || arrayList2.isEmpty() || arrayList.get(0) != arrayList2.get(0)) {
return true;
}
int min = Math.min(arrayList.size(), arrayList2.size());
for (int i = 1; i < min; i++) {
View view = arrayList.get(i);
View view2 = arrayList2.get(i);
if (view != view2) {
return isOnTop(view, view2);
}
}
return arrayList2.size() == min;
}
public void addGhostView(GhostViewPort ghostViewPort) {
ArrayList<View> arrayList = new ArrayList<>();
getParents(ghostViewPort.mView, arrayList);
int insertIndex = getInsertIndex(arrayList);
if (insertIndex < 0 || insertIndex >= getChildCount()) {
addView(ghostViewPort);
} else {
addView(ghostViewPort, insertIndex);
}
}
@Override // android.view.ViewGroup
public void onViewAdded(View view) {
if (this.mAttached) {
super.onViewAdded(view);
} else {
Single$$ExternalSyntheticBUOutline0.m$2("This GhostViewHolder is detached!");
}
}
@Override // android.view.ViewGroup
public void onViewRemoved(View view) {
super.onViewRemoved(view);
if ((getChildCount() == 1 && getChildAt(0) == view) || getChildCount() == 0) {
this.mParent.setTag(R.id.ghost_view_holder, null);
this.mParent.getOverlay().remove(this);
this.mAttached = false;
}
}
public void popToOverlayTop() {
if (!this.mAttached) {
Single$$ExternalSyntheticBUOutline0.m$2("This GhostViewHolder is detached!");
} else {
this.mParent.getOverlay().remove(this);
this.mParent.getOverlay().add(this);
}
}
private static boolean isOnTop(View view, View view2) {
ViewGroup viewGroup = (ViewGroup) view.getParent();
int childCount = viewGroup.getChildCount();
if (Api21Impl.getZ(view) != Api21Impl.getZ(view2)) {
return Api21Impl.getZ(view) > Api21Impl.getZ(view2);
}
for (int i = 0; i < childCount; i++) {
View childAt = viewGroup.getChildAt(ViewGroupUtils.getChildDrawingOrder(viewGroup, i));
if (childAt == view) {
return false;
}
if (childAt == view2) {
return true;
}
}
return true;
}
}