package com.kwad.sdk.lib.desigin; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.Region; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Parcel; import android.os.Parcelable; import android.os.SystemClock; import android.text.TextUtils; import android.util.AttributeSet; import android.util.SparseArray; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; import android.view.ViewTreeObserver; import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.math.MathUtils; import androidx.core.util.ObjectsCompat; import androidx.core.util.Pools; import androidx.core.view.GravityCompat; import androidx.core.view.NestedScrollingParent2; import androidx.core.view.NestedScrollingParentHelper; import androidx.core.view.OnApplyWindowInsetsListener; import androidx.core.view.ViewCompat; import androidx.core.view.WindowInsetsCompat; import androidx.customview.view.AbsSavedState; import com.kwad.sdk.R; import com.kwad.sdk.core.e.b; import com.uc.crashsdk.export.LogType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; public class KSCoordinatorLayout extends ViewGroup implements NestedScrollingParent2 { static final Class<?>[] CONSTRUCTOR_PARAMS = {Context.class, AttributeSet.class}; static final int EVENT_NESTED_SCROLL = 1; static final int EVENT_PRE_DRAW = 0; static final int EVENT_VIEW_REMOVED = 2; static final String TAG = "CoordinatorLayout"; static final Comparator<View> TOP_SORTED_CHILDREN_COMPARATOR; private static final int TYPE_ON_INTERCEPT = 0; private static final int TYPE_ON_TOUCH = 1; static final String WIDGET_PACKAGE_NAME; static final ThreadLocal<Map<String, Constructor<Behavior>>> sConstructors = new ThreadLocal<>(); private static final Pools.Pool<Rect> sRectPool = new Pools.SynchronizedPool(12); private OnApplyWindowInsetsListener mApplyWindowInsetsListener; private View mBehaviorTouchView; private final KSDirectedAcyclicGraph<View> mChildDag; private final List<View> mDependencySortedChildren; private boolean mDisallowInterceptReset; private boolean mDrawStatusBarBackground; private boolean mIsAttachedToWindow; private int[] mKeylines; private WindowInsetsCompat mLastInsets; private boolean mNeedsPreDrawListener; private final NestedScrollingParentHelper mNestedScrollingParentHelper; private View mNestedScrollingTarget; ViewGroup.OnHierarchyChangeListener mOnHierarchyChangeListener; private OnPreDrawListener mOnPreDrawListener; private Paint mScrimPaint; private Drawable mStatusBarBackground; private final List<View> mTempDependenciesList; private final int[] mTempIntPair; private final List<View> mTempList1; public static abstract class Behavior<V extends View> { public Behavior() { } public Behavior(Context context, AttributeSet attributeSet) { } public static Object getTag(View view) { return ((LayoutParams) view.getLayoutParams()).mBehaviorTag; } public static void setTag(View view, Object obj) { ((LayoutParams) view.getLayoutParams()).mBehaviorTag = obj; } public boolean blocksInteractionBelow(KSCoordinatorLayout kSCoordinatorLayout, V v) { return getScrimOpacity(kSCoordinatorLayout, v) > 0.0f; } public boolean getInsetDodgeRect(KSCoordinatorLayout kSCoordinatorLayout, V v, Rect rect) { return false; } public int getScrimColor(KSCoordinatorLayout kSCoordinatorLayout, V v) { return -16777216; } public float getScrimOpacity(KSCoordinatorLayout kSCoordinatorLayout, V v) { return 0.0f; } public boolean layoutDependsOn(KSCoordinatorLayout kSCoordinatorLayout, V v, View view) { return false; } public WindowInsetsCompat onApplyWindowInsets(KSCoordinatorLayout kSCoordinatorLayout, V v, WindowInsetsCompat windowInsetsCompat) { return windowInsetsCompat; } public void onAttachedToLayoutParams(LayoutParams layoutParams) { } public boolean onDependentViewChanged(KSCoordinatorLayout kSCoordinatorLayout, V v, View view) { return false; } public void onDependentViewRemoved(KSCoordinatorLayout kSCoordinatorLayout, V v, View view) { } public void onDetachedFromLayoutParams() { } public boolean onInterceptTouchEvent(KSCoordinatorLayout kSCoordinatorLayout, V v, MotionEvent motionEvent) { return false; } public boolean onLayoutChild(KSCoordinatorLayout kSCoordinatorLayout, V v, int i) { return false; } public boolean onMeasureChild(KSCoordinatorLayout kSCoordinatorLayout, V v, int i, int i2, int i3, int i4) { return false; } public boolean onNestedFling(KSCoordinatorLayout kSCoordinatorLayout, V v, View view, float f, float f2, boolean z) { return false; } public boolean onNestedPreFling(KSCoordinatorLayout kSCoordinatorLayout, V v, View view, float f, float f2) { return false; } @Deprecated public void onNestedPreScroll(KSCoordinatorLayout kSCoordinatorLayout, V v, View view, int i, int i2, int[] iArr) { } public void onNestedPreScroll(KSCoordinatorLayout kSCoordinatorLayout, V v, View view, int i, int i2, int[] iArr, int i3) { if (i3 == 0) { onNestedPreScroll(kSCoordinatorLayout, v, view, i, i2, iArr); } } @Deprecated public void onNestedScroll(KSCoordinatorLayout kSCoordinatorLayout, V v, View view, int i, int i2, int i3, int i4) { } public void onNestedScroll(KSCoordinatorLayout kSCoordinatorLayout, V v, View view, int i, int i2, int i3, int i4, int i5) { if (i5 == 0) { onNestedScroll(kSCoordinatorLayout, v, view, i, i2, i3, i4); } } @Deprecated public void onNestedScrollAccepted(KSCoordinatorLayout kSCoordinatorLayout, V v, View view, View view2, int i) { } public void onNestedScrollAccepted(KSCoordinatorLayout kSCoordinatorLayout, V v, View view, View view2, int i, int i2) { if (i2 == 0) { onNestedScrollAccepted(kSCoordinatorLayout, v, view, view2, i); } } public boolean onRequestChildRectangleOnScreen(KSCoordinatorLayout kSCoordinatorLayout, V v, Rect rect, boolean z) { return false; } public void onRestoreInstanceState(KSCoordinatorLayout kSCoordinatorLayout, V v, Parcelable parcelable) { } public Parcelable onSaveInstanceState(KSCoordinatorLayout kSCoordinatorLayout, V v) { return View.BaseSavedState.EMPTY_STATE; } @Deprecated public boolean onStartNestedScroll(KSCoordinatorLayout kSCoordinatorLayout, V v, View view, View view2, int i) { return false; } public boolean onStartNestedScroll(KSCoordinatorLayout kSCoordinatorLayout, V v, View view, View view2, int i, int i2) { if (i2 == 0) { return onStartNestedScroll(kSCoordinatorLayout, v, view, view2, i); } return false; } @Deprecated public void onStopNestedScroll(KSCoordinatorLayout kSCoordinatorLayout, V v, View view) { } public void onStopNestedScroll(KSCoordinatorLayout kSCoordinatorLayout, V v, View view, int i) { if (i == 0) { onStopNestedScroll(kSCoordinatorLayout, v, view); } } public boolean onTouchEvent(KSCoordinatorLayout kSCoordinatorLayout, V v, MotionEvent motionEvent) { return false; } } @Retention(RetentionPolicy.RUNTIME) public @interface DefaultBehavior { Class<? extends Behavior> value(); } @Retention(RetentionPolicy.SOURCE) public @interface DispatchChangeEvent { } class HierarchyChangeListener implements ViewGroup.OnHierarchyChangeListener { HierarchyChangeListener() { } public void onChildViewAdded(View view, View view2) { if (KSCoordinatorLayout.this.mOnHierarchyChangeListener != null) { KSCoordinatorLayout.this.mOnHierarchyChangeListener.onChildViewAdded(view, view2); } } public void onChildViewRemoved(View view, View view2) { KSCoordinatorLayout.this.onChildViewsChanged(2); if (KSCoordinatorLayout.this.mOnHierarchyChangeListener != null) { KSCoordinatorLayout.this.mOnHierarchyChangeListener.onChildViewRemoved(view, view2); } } } public static class LayoutParams extends ViewGroup.MarginLayoutParams { public int anchorGravity = 0; public int dodgeInsetEdges = 0; public int gravity = 0; public int insetEdge = 0; public int keyline = -1; View mAnchorDirectChild; int mAnchorId = -1; View mAnchorView; Behavior mBehavior; boolean mBehaviorResolved = false; Object mBehaviorTag; private boolean mDidAcceptNestedScrollNonTouch; private boolean mDidAcceptNestedScrollTouch; private boolean mDidBlockInteraction; private boolean mDidChangeAfterNestedScroll; int mInsetOffsetX; int mInsetOffsetY; final Rect mLastChildRect = new Rect(); public LayoutParams(int i, int i2) { super(i, i2); } LayoutParams(Context context, AttributeSet attributeSet) { super(context, attributeSet); TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.ksad_CoordinatorLayout_Layout); this.gravity = obtainStyledAttributes.getInteger(R.styleable.ksad_CoordinatorLayout_Layout_ksad_layout_gravity, 0); this.mAnchorId = obtainStyledAttributes.getResourceId(R.styleable.ksad_CoordinatorLayout_Layout_ksad_layout_anchor, -1); this.anchorGravity = obtainStyledAttributes.getInteger(R.styleable.ksad_CoordinatorLayout_Layout_ksad_layout_anchorGravity, 0); this.keyline = obtainStyledAttributes.getInteger(R.styleable.ksad_CoordinatorLayout_Layout_ksad_layout_keyline, -1); this.insetEdge = obtainStyledAttributes.getInt(R.styleable.ksad_CoordinatorLayout_Layout_ksad_layout_insetEdge, 0); this.dodgeInsetEdges = obtainStyledAttributes.getInt(R.styleable.ksad_CoordinatorLayout_Layout_ksad_layout_dodgeInsetEdges, 0); boolean hasValue = obtainStyledAttributes.hasValue(R.styleable.ksad_CoordinatorLayout_Layout_ksad_layout_behavior); this.mBehaviorResolved = hasValue; if (hasValue) { this.mBehavior = KSCoordinatorLayout.parseBehavior(context, attributeSet, obtainStyledAttributes.getString(R.styleable.ksad_CoordinatorLayout_Layout_ksad_layout_behavior)); } obtainStyledAttributes.recycle(); Behavior behavior = this.mBehavior; if (behavior != null) { behavior.onAttachedToLayoutParams(this); } } public LayoutParams(ViewGroup.LayoutParams layoutParams) { super(layoutParams); } public LayoutParams(ViewGroup.MarginLayoutParams marginLayoutParams) { super(marginLayoutParams); } public LayoutParams(LayoutParams layoutParams) { super((ViewGroup.MarginLayoutParams) layoutParams); } private void resolveAnchorView(View view, KSCoordinatorLayout kSCoordinatorLayout) { View findViewById = kSCoordinatorLayout.findViewById(this.mAnchorId); this.mAnchorView = findViewById; if (findViewById != null) { if (findViewById != kSCoordinatorLayout) { ViewParent parent = findViewById.getParent(); while (parent != kSCoordinatorLayout && parent != null) { if (parent != view) { if (parent instanceof View) { findViewById = (View) parent; } parent = parent.getParent(); } else if (!kSCoordinatorLayout.isInEditMode()) { throw new IllegalStateException("Anchor must not be a descendant of the anchored view"); } } this.mAnchorDirectChild = findViewById; return; } else if (!kSCoordinatorLayout.isInEditMode()) { throw new IllegalStateException("View can not be anchored to the the parent CoordinatorLayout"); } } else if (!kSCoordinatorLayout.isInEditMode()) { throw new IllegalStateException("Could not find CoordinatorLayout descendant view with id " + kSCoordinatorLayout.getResources().getResourceName(this.mAnchorId) + " to anchor view " + view); } this.mAnchorDirectChild = null; this.mAnchorView = null; } private boolean shouldDodge(View view, int i) { int absoluteGravity = GravityCompat.getAbsoluteGravity(((LayoutParams) view.getLayoutParams()).insetEdge, i); return absoluteGravity != 0 && (GravityCompat.getAbsoluteGravity(this.dodgeInsetEdges, i) & absoluteGravity) == absoluteGravity; } private boolean verifyAnchorView(View view, KSCoordinatorLayout kSCoordinatorLayout) { if (this.mAnchorView.getId() != this.mAnchorId) { return false; } View view2 = this.mAnchorView; for (ViewParent parent = view2.getParent(); parent != kSCoordinatorLayout; parent = parent.getParent()) { if (parent == null || parent == view) { this.mAnchorDirectChild = null; this.mAnchorView = null; return false; } if (parent instanceof View) { view2 = (View) parent; } } this.mAnchorDirectChild = view2; return true; } /* access modifiers changed from: package-private */ public boolean checkAnchorChanged() { return this.mAnchorView == null && this.mAnchorId != -1; } /* access modifiers changed from: package-private */ public boolean dependsOn(KSCoordinatorLayout kSCoordinatorLayout, View view, View view2) { if (view2 == this.mAnchorDirectChild || shouldDodge(view2, ViewCompat.getLayoutDirection(kSCoordinatorLayout))) { return true; } Behavior behavior = this.mBehavior; return behavior != null && behavior.layoutDependsOn(kSCoordinatorLayout, view, view2); } /* access modifiers changed from: package-private */ public boolean didBlockInteraction() { if (this.mBehavior == null) { this.mDidBlockInteraction = false; } return this.mDidBlockInteraction; } /* access modifiers changed from: package-private */ public View findAnchorView(KSCoordinatorLayout kSCoordinatorLayout, View view) { if (this.mAnchorId == -1) { this.mAnchorDirectChild = null; this.mAnchorView = null; return null; } if (this.mAnchorView == null || !verifyAnchorView(view, kSCoordinatorLayout)) { resolveAnchorView(view, kSCoordinatorLayout); } return this.mAnchorView; } public int getAnchorId() { return this.mAnchorId; } public Behavior getBehavior() { return this.mBehavior; } /* access modifiers changed from: package-private */ public boolean getChangedAfterNestedScroll() { return this.mDidChangeAfterNestedScroll; } /* access modifiers changed from: package-private */ public Rect getLastChildRect() { return this.mLastChildRect; } /* access modifiers changed from: package-private */ public void invalidateAnchor() { this.mAnchorDirectChild = null; this.mAnchorView = null; } /* access modifiers changed from: package-private */ public boolean isBlockingInteractionBelow(KSCoordinatorLayout kSCoordinatorLayout, View view) { boolean z = this.mDidBlockInteraction; if (z) { return true; } Behavior behavior = this.mBehavior; boolean blocksInteractionBelow = (behavior != null ? behavior.blocksInteractionBelow(kSCoordinatorLayout, view) : false) | z; this.mDidBlockInteraction = blocksInteractionBelow; return blocksInteractionBelow; } /* access modifiers changed from: package-private */ public boolean isNestedScrollAccepted(int i) { if (i == 0) { return this.mDidAcceptNestedScrollTouch; } if (i != 1) { return false; } return this.mDidAcceptNestedScrollNonTouch; } /* access modifiers changed from: package-private */ public void resetChangedAfterNestedScroll() { this.mDidChangeAfterNestedScroll = false; } /* access modifiers changed from: package-private */ public void resetNestedScroll(int i) { setNestedScrollAccepted(i, false); } /* access modifiers changed from: package-private */ public void resetTouchBehaviorTracking() { this.mDidBlockInteraction = false; } public void setAnchorId(int i) { invalidateAnchor(); this.mAnchorId = i; } public void setBehavior(Behavior behavior) { Behavior behavior2 = this.mBehavior; if (behavior2 != behavior) { if (behavior2 != null) { behavior2.onDetachedFromLayoutParams(); } this.mBehavior = behavior; this.mBehaviorTag = null; this.mBehaviorResolved = true; if (behavior != null) { behavior.onAttachedToLayoutParams(this); } } } /* access modifiers changed from: package-private */ public void setChangedAfterNestedScroll(boolean z) { this.mDidChangeAfterNestedScroll = z; } /* access modifiers changed from: package-private */ public void setLastChildRect(Rect rect) { this.mLastChildRect.set(rect); } /* access modifiers changed from: package-private */ public void setNestedScrollAccepted(int i, boolean z) { if (i == 0) { this.mDidAcceptNestedScrollTouch = z; } else if (i == 1) { this.mDidAcceptNestedScrollNonTouch = z; } } } /* access modifiers changed from: package-private */ public class OnPreDrawListener implements ViewTreeObserver.OnPreDrawListener { OnPreDrawListener() { } public boolean onPreDraw() { KSCoordinatorLayout.this.onChildViewsChanged(0); return true; } } /* access modifiers changed from: protected */ public static class SavedState extends AbsSavedState { public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.ClassLoaderCreator<SavedState>() { /* class com.kwad.sdk.lib.desigin.KSCoordinatorLayout.SavedState.AnonymousClass1 */ @Override // android.os.Parcelable.Creator public final SavedState createFromParcel(Parcel parcel) { return new SavedState(parcel, null); } @Override // android.os.Parcelable.ClassLoaderCreator public final SavedState createFromParcel(Parcel parcel, ClassLoader classLoader) { return new SavedState(parcel, classLoader); } @Override // android.os.Parcelable.Creator public final SavedState[] newArray(int i) { return new SavedState[i]; } }; SparseArray<Parcelable> behaviorStates; public SavedState(Parcel parcel, ClassLoader classLoader) { super(parcel, classLoader); int readInt = parcel.readInt(); int[] iArr = new int[readInt]; parcel.readIntArray(iArr); Parcelable[] readParcelableArray = parcel.readParcelableArray(classLoader); this.behaviorStates = new SparseArray<>(readInt); for (int i = 0; i < readInt; i++) { this.behaviorStates.append(iArr[i], readParcelableArray[i]); } } public SavedState(Parcelable parcelable) { super(parcelable); } @Override // androidx.customview.view.AbsSavedState public void writeToParcel(Parcel parcel, int i) { super.writeToParcel(parcel, i); SparseArray<Parcelable> sparseArray = this.behaviorStates; int size = sparseArray != null ? sparseArray.size() : 0; parcel.writeInt(size); int[] iArr = new int[size]; Parcelable[] parcelableArr = new Parcelable[size]; for (int i2 = 0; i2 < size; i2++) { iArr[i2] = this.behaviorStates.keyAt(i2); parcelableArr[i2] = this.behaviorStates.valueAt(i2); } parcel.writeIntArray(iArr); parcel.writeParcelableArray(parcelableArr, i); } } static class ViewElevationComparator implements Comparator<View> { ViewElevationComparator() { } public int compare(View view, View view2) { float z = ViewCompat.getZ(view); float z2 = ViewCompat.getZ(view2); if (z > z2) { return -1; } return z < z2 ? 1 : 0; } } static { Package r0 = KSCoordinatorLayout.class.getPackage(); WIDGET_PACKAGE_NAME = r0 != null ? r0.getName() : null; if (Build.VERSION.SDK_INT >= 21) { TOP_SORTED_CHILDREN_COMPARATOR = new ViewElevationComparator(); } else { TOP_SORTED_CHILDREN_COMPARATOR = null; } } public KSCoordinatorLayout(Context context) { this(context, null); } public KSCoordinatorLayout(Context context, AttributeSet attributeSet) { this(context, attributeSet, 0); } public KSCoordinatorLayout(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); this.mDependencySortedChildren = new ArrayList(); this.mChildDag = new KSDirectedAcyclicGraph<>(); this.mTempList1 = new ArrayList(); this.mTempDependenciesList = new ArrayList(); this.mTempIntPair = new int[2]; this.mNestedScrollingParentHelper = new NestedScrollingParentHelper(this); TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.ksad_KSCoordinatorLayout, i, R.style.ksad_Widget_Design_KSADCoordinatorLayout); int resourceId = obtainStyledAttributes.getResourceId(R.styleable.ksad_KSCoordinatorLayout_ksad_keylines, 0); if (resourceId != 0) { Resources resources = context.getResources(); this.mKeylines = resources.getIntArray(resourceId); float f = resources.getDisplayMetrics().density; int length = this.mKeylines.length; for (int i2 = 0; i2 < length; i2++) { int[] iArr = this.mKeylines; iArr[i2] = (int) (((float) iArr[i2]) * f); } } this.mStatusBarBackground = obtainStyledAttributes.getDrawable(R.styleable.ksad_KSCoordinatorLayout_ksad_statusBarBackground); obtainStyledAttributes.recycle(); setupForInsets(); super.setOnHierarchyChangeListener(new HierarchyChangeListener()); } private static Rect acquireTempRect() { Rect acquire = sRectPool.acquire(); return acquire == null ? new Rect() : acquire; } private void constrainChildRect(LayoutParams layoutParams, Rect rect, int i, int i2) { int width = getWidth(); int height = getHeight(); int max = Math.max(getPaddingLeft() + layoutParams.leftMargin, Math.min(rect.left, ((width - getPaddingRight()) - i) - layoutParams.rightMargin)); int max2 = Math.max(getPaddingTop() + layoutParams.topMargin, Math.min(rect.top, ((height - getPaddingBottom()) - i2) - layoutParams.bottomMargin)); rect.set(max, max2, i + max, i2 + max2); } private WindowInsetsCompat dispatchApplyWindowInsetsToBehaviors(WindowInsetsCompat windowInsetsCompat) { Behavior behavior; if (windowInsetsCompat.isConsumed()) { return windowInsetsCompat; } int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { View childAt = getChildAt(i); if (ViewCompat.getFitsSystemWindows(childAt) && (behavior = ((LayoutParams) childAt.getLayoutParams()).getBehavior()) != null) { windowInsetsCompat = behavior.onApplyWindowInsets(this, childAt, windowInsetsCompat); if (windowInsetsCompat.isConsumed()) { break; } } } return windowInsetsCompat; } private void getDesiredAnchoredChildRectWithoutConstraints(View view, int i, Rect rect, Rect rect2, LayoutParams layoutParams, int i2, int i3) { int absoluteGravity = GravityCompat.getAbsoluteGravity(resolveAnchoredChildGravity(layoutParams.gravity), i); int absoluteGravity2 = GravityCompat.getAbsoluteGravity(resolveGravity(layoutParams.anchorGravity), i); int i4 = absoluteGravity & 7; int i5 = absoluteGravity & 112; int i6 = absoluteGravity2 & 7; int i7 = absoluteGravity2 & 112; int width = i6 != 1 ? i6 != 5 ? rect.left : rect.right : rect.left + (rect.width() / 2); int height = i7 != 16 ? i7 != 80 ? rect.top : rect.bottom : rect.top + (rect.height() / 2); if (i4 == 1) { width -= i2 / 2; } else if (i4 != 5) { width -= i2; } if (i5 == 16) { height -= i3 / 2; } else if (i5 != 80) { height -= i3; } rect2.set(width, height, i2 + width, i3 + height); } private int getKeyline(int i) { StringBuilder sb; int[] iArr = this.mKeylines; if (iArr == null) { sb = new StringBuilder("No keylines defined for "); sb.append(this); sb.append(" - attempted index lookup "); sb.append(i); } else if (i >= 0 && i < iArr.length) { return iArr[i]; } else { sb = new StringBuilder("Keyline index "); sb.append(i); sb.append(" out of range for "); sb.append(this); } b.e(TAG, sb.toString()); return 0; } private void getTopSortedChildren(List<View> list) { list.clear(); boolean isChildrenDrawingOrderEnabled = isChildrenDrawingOrderEnabled(); int childCount = getChildCount(); for (int i = childCount - 1; i >= 0; i--) { list.add(getChildAt(isChildrenDrawingOrderEnabled ? getChildDrawingOrder(childCount, i) : i)); } Comparator<View> comparator = TOP_SORTED_CHILDREN_COMPARATOR; if (comparator != null) { Collections.sort(list, comparator); } } private boolean hasDependencies(View view) { return this.mChildDag.hasOutgoingEdges(view); } private void layoutChild(View view, int i) { LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); Rect acquireTempRect = acquireTempRect(); acquireTempRect.set(getPaddingLeft() + layoutParams.leftMargin, getPaddingTop() + layoutParams.topMargin, (getWidth() - getPaddingRight()) - layoutParams.rightMargin, (getHeight() - getPaddingBottom()) - layoutParams.bottomMargin); if (this.mLastInsets != null && ViewCompat.getFitsSystemWindows(this) && !ViewCompat.getFitsSystemWindows(view)) { acquireTempRect.left += this.mLastInsets.getSystemWindowInsetLeft(); acquireTempRect.top += this.mLastInsets.getSystemWindowInsetTop(); acquireTempRect.right -= this.mLastInsets.getSystemWindowInsetRight(); acquireTempRect.bottom -= this.mLastInsets.getSystemWindowInsetBottom(); } Rect acquireTempRect2 = acquireTempRect(); GravityCompat.apply(resolveGravity(layoutParams.gravity), view.getMeasuredWidth(), view.getMeasuredHeight(), acquireTempRect, acquireTempRect2, i); view.layout(acquireTempRect2.left, acquireTempRect2.top, acquireTempRect2.right, acquireTempRect2.bottom); releaseTempRect(acquireTempRect); releaseTempRect(acquireTempRect2); } private void layoutChildWithAnchor(View view, View view2, int i) { view.getLayoutParams(); Rect acquireTempRect = acquireTempRect(); Rect acquireTempRect2 = acquireTempRect(); try { getDescendantRect(view2, acquireTempRect); getDesiredAnchoredChildRect(view, i, acquireTempRect, acquireTempRect2); view.layout(acquireTempRect2.left, acquireTempRect2.top, acquireTempRect2.right, acquireTempRect2.bottom); } finally { releaseTempRect(acquireTempRect); releaseTempRect(acquireTempRect2); } } private void layoutChildWithKeyline(View view, int i, int i2) { LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); int absoluteGravity = GravityCompat.getAbsoluteGravity(resolveKeylineGravity(layoutParams.gravity), i2); int i3 = absoluteGravity & 7; int i4 = absoluteGravity & 112; int width = getWidth(); int height = getHeight(); int measuredWidth = view.getMeasuredWidth(); int measuredHeight = view.getMeasuredHeight(); if (i2 == 1) { i = width - i; } int keyline = getKeyline(i) - measuredWidth; if (i3 == 1) { keyline += measuredWidth / 2; } else if (i3 == 5) { keyline += measuredWidth; } int i5 = 0; if (i4 == 16) { i5 = 0 + (measuredHeight / 2); } else if (i4 == 80) { i5 = measuredHeight + 0; } int max = Math.max(getPaddingLeft() + layoutParams.leftMargin, Math.min(keyline, ((width - getPaddingRight()) - measuredWidth) - layoutParams.rightMargin)); int max2 = Math.max(getPaddingTop() + layoutParams.topMargin, Math.min(i5, ((height - getPaddingBottom()) - measuredHeight) - layoutParams.bottomMargin)); view.layout(max, max2, measuredWidth + max, measuredHeight + max2); } private void offsetChildByInset(View view, Rect rect, int i) { boolean z; boolean z2; int width; int i2; int height; int i3; if (ViewCompat.isLaidOut(view) && view.getWidth() > 0 && view.getHeight() > 0) { LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); Behavior behavior = layoutParams.getBehavior(); Rect acquireTempRect = acquireTempRect(); Rect acquireTempRect2 = acquireTempRect(); acquireTempRect2.set(view.getLeft(), view.getTop(), view.getRight(), view.getBottom()); if (behavior == null || !behavior.getInsetDodgeRect(this, view, acquireTempRect)) { acquireTempRect.set(acquireTempRect2); } else if (!acquireTempRect2.contains(acquireTempRect)) { throw new IllegalArgumentException("Rect should be within the child's bounds. Rect:" + acquireTempRect.toShortString() + " | Bounds:" + acquireTempRect2.toShortString()); } releaseTempRect(acquireTempRect2); if (acquireTempRect.isEmpty()) { releaseTempRect(acquireTempRect); return; } int absoluteGravity = GravityCompat.getAbsoluteGravity(layoutParams.dodgeInsetEdges, i); boolean z3 = true; if ((absoluteGravity & 48) != 48 || (i3 = (acquireTempRect.top - layoutParams.topMargin) - layoutParams.mInsetOffsetY) >= rect.top) { z = false; } else { setInsetOffsetY(view, rect.top - i3); z = true; } if ((absoluteGravity & 80) == 80 && (height = ((getHeight() - acquireTempRect.bottom) - layoutParams.bottomMargin) + layoutParams.mInsetOffsetY) < rect.bottom) { setInsetOffsetY(view, height - rect.bottom); z = true; } if (!z) { setInsetOffsetY(view, 0); } if ((absoluteGravity & 3) != 3 || (i2 = (acquireTempRect.left - layoutParams.leftMargin) - layoutParams.mInsetOffsetX) >= rect.left) { z2 = false; } else { setInsetOffsetX(view, rect.left - i2); z2 = true; } if ((absoluteGravity & 5) != 5 || (width = ((getWidth() - acquireTempRect.right) - layoutParams.rightMargin) + layoutParams.mInsetOffsetX) >= rect.right) { z3 = z2; } else { setInsetOffsetX(view, width - rect.right); } if (!z3) { setInsetOffsetX(view, 0); } releaseTempRect(acquireTempRect); } } /* JADX DEBUG: Multi-variable search result rejected for r0v9, resolved type: java.lang.Class<?> */ /* JADX WARN: Multi-variable type inference failed */ static Behavior parseBehavior(Context context, AttributeSet attributeSet, String str) { if (TextUtils.isEmpty(str)) { return null; } if (str.startsWith(".")) { str = context.getPackageName() + str; } else if (str.indexOf(46) < 0) { String str2 = WIDGET_PACKAGE_NAME; if (!TextUtils.isEmpty(str2)) { str = str2 + '.' + str; } } try { ThreadLocal<Map<String, Constructor<Behavior>>> threadLocal = sConstructors; Map<String, Constructor<Behavior>> map = threadLocal.get(); if (map == null) { map = new HashMap<>(); threadLocal.set(map); } Constructor<Behavior> constructor = map.get(str); if (constructor == null) { constructor = Class.forName(str, true, context.getClassLoader()).getConstructor(CONSTRUCTOR_PARAMS); constructor.setAccessible(true); map.put(str, constructor); } return constructor.newInstance(context, attributeSet); } catch (Exception e) { throw new RuntimeException("Could not inflate Behavior subclass " + str, e); } } private boolean performIntercept(MotionEvent motionEvent, int i) { int actionMasked = motionEvent.getActionMasked(); List<View> list = this.mTempList1; getTopSortedChildren(list); int size = list.size(); MotionEvent motionEvent2 = null; boolean z = false; boolean z2 = false; for (int i2 = 0; i2 < size; i2++) { View view = list.get(i2); LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); Behavior behavior = layoutParams.getBehavior(); if (!(z || z2) || actionMasked == 0) { if (!z && behavior != null) { if (i == 0) { z = behavior.onInterceptTouchEvent(this, view, motionEvent); } else if (i == 1) { z = behavior.onTouchEvent(this, view, motionEvent); } if (z) { this.mBehaviorTouchView = view; } } boolean didBlockInteraction = layoutParams.didBlockInteraction(); boolean isBlockingInteractionBelow = layoutParams.isBlockingInteractionBelow(this, view); z2 = isBlockingInteractionBelow && !didBlockInteraction; if (isBlockingInteractionBelow && !z2) { break; } } else if (behavior != null) { if (motionEvent2 == null) { long uptimeMillis = SystemClock.uptimeMillis(); motionEvent2 = MotionEvent.obtain(uptimeMillis, uptimeMillis, 3, 0.0f, 0.0f, 0); } if (i == 0) { behavior.onInterceptTouchEvent(this, view, motionEvent2); } else if (i == 1) { behavior.onTouchEvent(this, view, motionEvent2); } } } list.clear(); return z; } private void prepareChildren() { this.mDependencySortedChildren.clear(); this.mChildDag.clear(); int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { View childAt = getChildAt(i); LayoutParams resolvedLayoutParams = getResolvedLayoutParams(childAt); resolvedLayoutParams.findAnchorView(this, childAt); this.mChildDag.addNode(childAt); for (int i2 = 0; i2 < childCount; i2++) { if (i2 != i) { View childAt2 = getChildAt(i2); if (resolvedLayoutParams.dependsOn(this, childAt, childAt2)) { if (!this.mChildDag.contains(childAt2)) { this.mChildDag.addNode(childAt2); } this.mChildDag.addEdge(childAt2, childAt); } } } } this.mDependencySortedChildren.addAll(this.mChildDag.getSortedList()); Collections.reverse(this.mDependencySortedChildren); } private static void releaseTempRect(Rect rect) { rect.setEmpty(); sRectPool.release(rect); } private void resetTouchBehaviors(boolean z) { int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { View childAt = getChildAt(i); Behavior behavior = ((LayoutParams) childAt.getLayoutParams()).getBehavior(); if (behavior != null) { long uptimeMillis = SystemClock.uptimeMillis(); MotionEvent obtain = MotionEvent.obtain(uptimeMillis, uptimeMillis, 3, 0.0f, 0.0f, 0); if (z) { behavior.onInterceptTouchEvent(this, childAt, obtain); } else { behavior.onTouchEvent(this, childAt, obtain); } obtain.recycle(); } } for (int i2 = 0; i2 < childCount; i2++) { ((LayoutParams) getChildAt(i2).getLayoutParams()).resetTouchBehaviorTracking(); } this.mDisallowInterceptReset = false; } private static int resolveAnchoredChildGravity(int i) { if (i == 0) { return 17; } return i; } private static int resolveGravity(int i) { if ((i & 7) == 0) { i |= GravityCompat.START; } return (i & 112) == 0 ? i | 48 : i; } private static int resolveKeylineGravity(int i) { if (i == 0) { return 8388661; } return i; } private void setInsetOffsetX(View view, int i) { LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); if (layoutParams.mInsetOffsetX != i) { ViewCompat.offsetLeftAndRight(view, i - layoutParams.mInsetOffsetX); layoutParams.mInsetOffsetX = i; } } private void setInsetOffsetY(View view, int i) { LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); if (layoutParams.mInsetOffsetY != i) { ViewCompat.offsetTopAndBottom(view, i - layoutParams.mInsetOffsetY); layoutParams.mInsetOffsetY = i; } } private void setupForInsets() { if (Build.VERSION.SDK_INT >= 21) { if (ViewCompat.getFitsSystemWindows(this)) { if (this.mApplyWindowInsetsListener == null) { this.mApplyWindowInsetsListener = new OnApplyWindowInsetsListener() { /* class com.kwad.sdk.lib.desigin.KSCoordinatorLayout.AnonymousClass1 */ @Override // androidx.core.view.OnApplyWindowInsetsListener public WindowInsetsCompat onApplyWindowInsets(View view, WindowInsetsCompat windowInsetsCompat) { return KSCoordinatorLayout.this.setWindowInsets(windowInsetsCompat); } }; } ViewCompat.setOnApplyWindowInsetsListener(this, this.mApplyWindowInsetsListener); setSystemUiVisibility(LogType.UNEXP_ANR); return; } ViewCompat.setOnApplyWindowInsetsListener(this, null); } } /* access modifiers changed from: package-private */ public void addPreDrawListener() { if (this.mIsAttachedToWindow) { if (this.mOnPreDrawListener == null) { this.mOnPreDrawListener = new OnPreDrawListener(); } getViewTreeObserver().addOnPreDrawListener(this.mOnPreDrawListener); } this.mNeedsPreDrawListener = true; } /* access modifiers changed from: protected */ public boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) { return (layoutParams instanceof LayoutParams) && super.checkLayoutParams(layoutParams); } public void dispatchDependentViewsChanged(View view) { List incomingEdges = this.mChildDag.getIncomingEdges(view); if (!(incomingEdges == null || incomingEdges.isEmpty())) { for (int i = 0; i < incomingEdges.size(); i++) { View view2 = (View) incomingEdges.get(i); Behavior behavior = ((LayoutParams) view2.getLayoutParams()).getBehavior(); if (behavior != null) { behavior.onDependentViewChanged(this, view2, view); } } } } public boolean doViewsOverlap(View view, View view2) { boolean z = false; if (view.getVisibility() != 0 || view2.getVisibility() != 0) { return false; } Rect acquireTempRect = acquireTempRect(); getChildRect(view, view.getParent() != this, acquireTempRect); Rect acquireTempRect2 = acquireTempRect(); getChildRect(view2, view2.getParent() != this, acquireTempRect2); try { if (acquireTempRect.left <= acquireTempRect2.right && acquireTempRect.top <= acquireTempRect2.bottom && acquireTempRect.right >= acquireTempRect2.left && acquireTempRect.bottom >= acquireTempRect2.top) { z = true; } return z; } finally { releaseTempRect(acquireTempRect); releaseTempRect(acquireTempRect2); } } /* access modifiers changed from: protected */ public boolean drawChild(Canvas canvas, View view, long j) { LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); if (layoutParams.mBehavior != null) { float scrimOpacity = layoutParams.mBehavior.getScrimOpacity(this, view); if (scrimOpacity > 0.0f) { if (this.mScrimPaint == null) { this.mScrimPaint = new Paint(); } this.mScrimPaint.setColor(layoutParams.mBehavior.getScrimColor(this, view)); this.mScrimPaint.setAlpha(MathUtils.clamp(Math.round(scrimOpacity * 255.0f), 0, 255)); int save = canvas.save(); if (view.isOpaque()) { canvas.clipRect((float) view.getLeft(), (float) view.getTop(), (float) view.getRight(), (float) view.getBottom(), Region.Op.DIFFERENCE); } canvas.drawRect((float) getPaddingLeft(), (float) getPaddingTop(), (float) (getWidth() - getPaddingRight()), (float) (getHeight() - getPaddingBottom()), this.mScrimPaint); canvas.restoreToCount(save); } } return super.drawChild(canvas, view, j); } /* access modifiers changed from: protected */ public void drawableStateChanged() { super.drawableStateChanged(); int[] drawableState = getDrawableState(); Drawable drawable = this.mStatusBarBackground; boolean z = false; if (drawable != null && drawable.isStateful()) { z = false | drawable.setState(drawableState); } if (z) { invalidate(); } } /* access modifiers changed from: package-private */ public void ensurePreDrawListener() { int childCount = getChildCount(); boolean z = false; int i = 0; while (true) { if (i >= childCount) { break; } else if (hasDependencies(getChildAt(i))) { z = true; break; } else { i++; } } if (z == this.mNeedsPreDrawListener) { return; } if (z) { addPreDrawListener(); } else { removePreDrawListener(); } } /* access modifiers changed from: protected */ public LayoutParams generateDefaultLayoutParams() { return new LayoutParams(-2, -2); } @Override // android.view.ViewGroup public LayoutParams generateLayoutParams(AttributeSet attributeSet) { return new LayoutParams(getContext(), attributeSet); } /* access modifiers changed from: protected */ @Override // android.view.ViewGroup public LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) { return layoutParams instanceof LayoutParams ? new LayoutParams((LayoutParams) layoutParams) : layoutParams instanceof ViewGroup.MarginLayoutParams ? new LayoutParams((ViewGroup.MarginLayoutParams) layoutParams) : new LayoutParams(layoutParams); } /* access modifiers changed from: package-private */ public void getChildRect(View view, boolean z, Rect rect) { if (view.isLayoutRequested() || view.getVisibility() == 8) { rect.setEmpty(); } else if (z) { getDescendantRect(view, rect); } else { rect.set(view.getLeft(), view.getTop(), view.getRight(), view.getBottom()); } } public List<View> getDependencies(View view) { List<View> outgoingEdges = this.mChildDag.getOutgoingEdges(view); this.mTempDependenciesList.clear(); if (outgoingEdges != null) { this.mTempDependenciesList.addAll(outgoingEdges); } return this.mTempDependenciesList; } /* access modifiers changed from: package-private */ public final List<View> getDependencySortedChildren() { prepareChildren(); return Collections.unmodifiableList(this.mDependencySortedChildren); } public List<View> getDependents(View view) { List incomingEdges = this.mChildDag.getIncomingEdges(view); this.mTempDependenciesList.clear(); if (incomingEdges != null) { this.mTempDependenciesList.addAll(incomingEdges); } return this.mTempDependenciesList; } /* access modifiers changed from: package-private */ public void getDescendantRect(View view, Rect rect) { KSViewGroupUtils.getDescendantRect(this, view, rect); } /* access modifiers changed from: package-private */ public void getDesiredAnchoredChildRect(View view, int i, Rect rect, Rect rect2) { LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); int measuredWidth = view.getMeasuredWidth(); int measuredHeight = view.getMeasuredHeight(); getDesiredAnchoredChildRectWithoutConstraints(view, i, rect, rect2, layoutParams, measuredWidth, measuredHeight); constrainChildRect(layoutParams, rect2, measuredWidth, measuredHeight); } /* access modifiers changed from: package-private */ public void getLastChildRect(View view, Rect rect) { rect.set(((LayoutParams) view.getLayoutParams()).getLastChildRect()); } /* access modifiers changed from: package-private */ public final WindowInsetsCompat getLastWindowInsets() { return this.mLastInsets; } @Override // androidx.core.view.NestedScrollingParent public int getNestedScrollAxes() { return this.mNestedScrollingParentHelper.getNestedScrollAxes(); } /* access modifiers changed from: package-private */ public LayoutParams getResolvedLayoutParams(View view) { LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); if (!layoutParams.mBehaviorResolved) { DefaultBehavior defaultBehavior = null; for (Class<?> cls = view.getClass(); cls != null; cls = cls.getSuperclass()) { defaultBehavior = (DefaultBehavior) cls.getAnnotation(DefaultBehavior.class); if (defaultBehavior != null) { break; } } if (defaultBehavior != null) { try { layoutParams.setBehavior((Behavior) defaultBehavior.value().getDeclaredConstructor(new Class[0]).newInstance(new Object[0])); } catch (Exception e) { b.e(TAG, "Default behavior class " + defaultBehavior.value().getName() + " could not be instantiated. Did you forget a default constructor?", e); } } layoutParams.mBehaviorResolved = true; } return layoutParams; } public Drawable getStatusBarBackground() { return this.mStatusBarBackground; } /* access modifiers changed from: protected */ public int getSuggestedMinimumHeight() { return Math.max(super.getSuggestedMinimumHeight(), getPaddingTop() + getPaddingBottom()); } /* access modifiers changed from: protected */ public int getSuggestedMinimumWidth() { return Math.max(super.getSuggestedMinimumWidth(), getPaddingLeft() + getPaddingRight()); } public boolean isPointInChildBounds(View view, int i, int i2) { Rect acquireTempRect = acquireTempRect(); getDescendantRect(view, acquireTempRect); try { return acquireTempRect.contains(i, i2); } finally { releaseTempRect(acquireTempRect); } } /* access modifiers changed from: package-private */ public void offsetChildToAnchor(View view, int i) { Behavior behavior; LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); if (layoutParams.mAnchorView != null) { Rect acquireTempRect = acquireTempRect(); Rect acquireTempRect2 = acquireTempRect(); Rect acquireTempRect3 = acquireTempRect(); getDescendantRect(layoutParams.mAnchorView, acquireTempRect); boolean z = false; getChildRect(view, false, acquireTempRect2); int measuredWidth = view.getMeasuredWidth(); int measuredHeight = view.getMeasuredHeight(); getDesiredAnchoredChildRectWithoutConstraints(view, i, acquireTempRect, acquireTempRect3, layoutParams, measuredWidth, measuredHeight); if (!(acquireTempRect3.left == acquireTempRect2.left && acquireTempRect3.top == acquireTempRect2.top)) { z = true; } constrainChildRect(layoutParams, acquireTempRect3, measuredWidth, measuredHeight); int i2 = acquireTempRect3.left - acquireTempRect2.left; int i3 = acquireTempRect3.top - acquireTempRect2.top; if (i2 != 0) { ViewCompat.offsetLeftAndRight(view, i2); } if (i3 != 0) { ViewCompat.offsetTopAndBottom(view, i3); } if (z && (behavior = layoutParams.getBehavior()) != null) { behavior.onDependentViewChanged(this, view, layoutParams.mAnchorView); } releaseTempRect(acquireTempRect); releaseTempRect(acquireTempRect2); releaseTempRect(acquireTempRect3); } } public void onAttachedToWindow() { super.onAttachedToWindow(); resetTouchBehaviors(false); if (this.mNeedsPreDrawListener) { if (this.mOnPreDrawListener == null) { this.mOnPreDrawListener = new OnPreDrawListener(); } getViewTreeObserver().addOnPreDrawListener(this.mOnPreDrawListener); } if (this.mLastInsets == null && ViewCompat.getFitsSystemWindows(this)) { ViewCompat.requestApplyInsets(this); } this.mIsAttachedToWindow = true; } /* access modifiers changed from: package-private */ public final void onChildViewsChanged(int i) { boolean z; int layoutDirection = ViewCompat.getLayoutDirection(this); int size = this.mDependencySortedChildren.size(); Rect acquireTempRect = acquireTempRect(); Rect acquireTempRect2 = acquireTempRect(); Rect acquireTempRect3 = acquireTempRect(); for (int i2 = 0; i2 < size; i2++) { View view = this.mDependencySortedChildren.get(i2); LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); if (i != 0 || view.getVisibility() != 8) { for (int i3 = 0; i3 < i2; i3++) { if (layoutParams.mAnchorDirectChild == this.mDependencySortedChildren.get(i3)) { offsetChildToAnchor(view, layoutDirection); } } getChildRect(view, true, acquireTempRect2); if (layoutParams.insetEdge != 0 && !acquireTempRect2.isEmpty()) { int absoluteGravity = GravityCompat.getAbsoluteGravity(layoutParams.insetEdge, layoutDirection); int i4 = absoluteGravity & 112; if (i4 == 48) { acquireTempRect.top = Math.max(acquireTempRect.top, acquireTempRect2.bottom); } else if (i4 == 80) { acquireTempRect.bottom = Math.max(acquireTempRect.bottom, getHeight() - acquireTempRect2.top); } int i5 = absoluteGravity & 7; if (i5 == 3) { acquireTempRect.left = Math.max(acquireTempRect.left, acquireTempRect2.right); } else if (i5 == 5) { acquireTempRect.right = Math.max(acquireTempRect.right, getWidth() - acquireTempRect2.left); } } if (layoutParams.dodgeInsetEdges != 0 && view.getVisibility() == 0) { offsetChildByInset(view, acquireTempRect, layoutDirection); } if (i != 2) { getLastChildRect(view, acquireTempRect3); if (!acquireTempRect3.equals(acquireTempRect2)) { recordLastChildRect(view, acquireTempRect2); } } for (int i6 = i2 + 1; i6 < size; i6++) { View view2 = this.mDependencySortedChildren.get(i6); LayoutParams layoutParams2 = (LayoutParams) view2.getLayoutParams(); Behavior behavior = layoutParams2.getBehavior(); if (behavior != null && behavior.layoutDependsOn(this, view2, view)) { if (i != 0 || !layoutParams2.getChangedAfterNestedScroll()) { if (i != 2) { z = behavior.onDependentViewChanged(this, view2, view); } else { behavior.onDependentViewRemoved(this, view2, view); z = true; } if (i == 1) { layoutParams2.setChangedAfterNestedScroll(z); } } else { layoutParams2.resetChangedAfterNestedScroll(); } } } } } releaseTempRect(acquireTempRect); releaseTempRect(acquireTempRect2); releaseTempRect(acquireTempRect3); } public void onDetachedFromWindow() { super.onDetachedFromWindow(); resetTouchBehaviors(false); if (this.mNeedsPreDrawListener && this.mOnPreDrawListener != null) { getViewTreeObserver().removeOnPreDrawListener(this.mOnPreDrawListener); } View view = this.mNestedScrollingTarget; if (view != null) { onStopNestedScroll(view); } this.mIsAttachedToWindow = false; } public void onDraw(Canvas canvas) { super.onDraw(canvas); if (this.mDrawStatusBarBackground && this.mStatusBarBackground != null) { WindowInsetsCompat windowInsetsCompat = this.mLastInsets; int systemWindowInsetTop = windowInsetsCompat != null ? windowInsetsCompat.getSystemWindowInsetTop() : 0; if (systemWindowInsetTop > 0) { this.mStatusBarBackground.setBounds(0, 0, getWidth(), systemWindowInsetTop); this.mStatusBarBackground.draw(canvas); } } } public boolean onInterceptTouchEvent(MotionEvent motionEvent) { int actionMasked = motionEvent.getActionMasked(); if (actionMasked == 0) { resetTouchBehaviors(true); } boolean performIntercept = performIntercept(motionEvent, 0); if (actionMasked == 1 || actionMasked == 3) { resetTouchBehaviors(true); } return performIntercept; } /* access modifiers changed from: protected */ public void onLayout(boolean z, int i, int i2, int i3, int i4) { Behavior behavior; int layoutDirection = ViewCompat.getLayoutDirection(this); int size = this.mDependencySortedChildren.size(); for (int i5 = 0; i5 < size; i5++) { View view = this.mDependencySortedChildren.get(i5); if (view.getVisibility() != 8 && ((behavior = ((LayoutParams) view.getLayoutParams()).getBehavior()) == null || !behavior.onLayoutChild(this, view, layoutDirection))) { onLayoutChild(view, layoutDirection); } } } public void onLayoutChild(View view, int i) { LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); if (layoutParams.checkAnchorChanged()) { throw new IllegalStateException("An anchor may not be changed after CoordinatorLayout measurement begins before layout is complete."); } else if (layoutParams.mAnchorView != null) { layoutChildWithAnchor(view, layoutParams.mAnchorView, i); } else if (layoutParams.keyline >= 0) { layoutChildWithKeyline(view, layoutParams.keyline, i); } else { layoutChild(view, i); } } /* access modifiers changed from: protected */ /* JADX WARNING: Code restructure failed: missing block: B:40:0x0114, code lost: if (r0.onMeasureChild(r30, r20, r11, r21, r23, 0) == false) goto L_0x0124; */ /* JADX WARNING: Removed duplicated region for block: B:33:0x00bb */ /* JADX WARNING: Removed duplicated region for block: B:39:0x00f5 */ /* JADX WARNING: Removed duplicated region for block: B:41:0x0117 */ public void onMeasure(int i, int i2) { int i3; int i4; int i5; int i6; int i7; int i8; int i9; Behavior behavior; int i10; LayoutParams layoutParams; int i11; int i12; prepareChildren(); ensurePreDrawListener(); int paddingLeft = getPaddingLeft(); int paddingTop = getPaddingTop(); int paddingRight = getPaddingRight(); int paddingBottom = getPaddingBottom(); int layoutDirection = ViewCompat.getLayoutDirection(this); boolean z = layoutDirection == 1; int mode = View.MeasureSpec.getMode(i); int size = View.MeasureSpec.getSize(i); int mode2 = View.MeasureSpec.getMode(i2); int size2 = View.MeasureSpec.getSize(i2); int i13 = paddingLeft + paddingRight; int i14 = paddingTop + paddingBottom; int suggestedMinimumWidth = getSuggestedMinimumWidth(); int suggestedMinimumHeight = getSuggestedMinimumHeight(); boolean z2 = this.mLastInsets != null && ViewCompat.getFitsSystemWindows(this); int size3 = this.mDependencySortedChildren.size(); int i15 = suggestedMinimumWidth; int i16 = suggestedMinimumHeight; int i17 = 0; int i18 = 0; while (i18 < size3) { View view = this.mDependencySortedChildren.get(i18); if (view.getVisibility() != 8) { LayoutParams layoutParams2 = (LayoutParams) view.getLayoutParams(); if (layoutParams2.keyline < 0 || mode == 0) { i6 = i17; } else { int keyline = getKeyline(layoutParams2.keyline); int absoluteGravity = GravityCompat.getAbsoluteGravity(resolveKeylineGravity(layoutParams2.gravity), layoutDirection) & 7; i6 = i17; if ((absoluteGravity == 3 && !z) || (absoluteGravity == 5 && z)) { i7 = Math.max(0, (size - paddingRight) - keyline); if (z2) { } i9 = i; i8 = i2; behavior = layoutParams2.getBehavior(); if (behavior != null) { } onMeasureChild(view, i9, i7, i8, 0); int max = Math.max(i12, i13 + view.getMeasuredWidth() + layoutParams.leftMargin + layoutParams.rightMargin); int max2 = Math.max(i10, i14 + view.getMeasuredHeight() + layoutParams.topMargin + layoutParams.bottomMargin); i17 = View.combineMeasuredStates(i11, view.getMeasuredState()); i15 = max; i16 = max2; } else if ((absoluteGravity == 5 && !z) || (absoluteGravity == 3 && z)) { i7 = Math.max(0, keyline - paddingLeft); if (z2 || ViewCompat.getFitsSystemWindows(view)) { i9 = i; i8 = i2; } else { i9 = View.MeasureSpec.makeMeasureSpec(size - (this.mLastInsets.getSystemWindowInsetLeft() + this.mLastInsets.getSystemWindowInsetRight()), mode); i8 = View.MeasureSpec.makeMeasureSpec(size2 - (this.mLastInsets.getSystemWindowInsetTop() + this.mLastInsets.getSystemWindowInsetBottom()), mode2); } behavior = layoutParams2.getBehavior(); if (behavior != null) { layoutParams = layoutParams2; i11 = i6; i5 = i18; i10 = i16; i4 = paddingLeft; i12 = i15; i3 = size3; } else { layoutParams = layoutParams2; i10 = i16; i3 = size3; i4 = paddingLeft; i11 = i6; i5 = i18; i12 = i15; } onMeasureChild(view, i9, i7, i8, 0); int max3 = Math.max(i12, i13 + view.getMeasuredWidth() + layoutParams.leftMargin + layoutParams.rightMargin); int max22 = Math.max(i10, i14 + view.getMeasuredHeight() + layoutParams.topMargin + layoutParams.bottomMargin); i17 = View.combineMeasuredStates(i11, view.getMeasuredState()); i15 = max3; i16 = max22; } } i7 = 0; if (z2) { } i9 = i; i8 = i2; behavior = layoutParams2.getBehavior(); if (behavior != null) { } onMeasureChild(view, i9, i7, i8, 0); int max32 = Math.max(i12, i13 + view.getMeasuredWidth() + layoutParams.leftMargin + layoutParams.rightMargin); int max222 = Math.max(i10, i14 + view.getMeasuredHeight() + layoutParams.topMargin + layoutParams.bottomMargin); i17 = View.combineMeasuredStates(i11, view.getMeasuredState()); i15 = max32; i16 = max222; } else { i5 = i18; i3 = size3; i4 = paddingLeft; } i18 = i5 + 1; paddingLeft = i4; size3 = i3; } setMeasuredDimension(View.resolveSizeAndState(i15, i, -16777216 & i17), View.resolveSizeAndState(i16, i2, i17 << 16)); } public void onMeasureChild(View view, int i, int i2, int i3, int i4) { measureChildWithMargins(view, i, i2, i3, i4); } @Override // androidx.core.view.NestedScrollingParent public boolean onNestedFling(View view, float f, float f2, boolean z) { Behavior behavior; int childCount = getChildCount(); boolean z2 = false; for (int i = 0; i < childCount; i++) { View childAt = getChildAt(i); if (childAt.getVisibility() != 8) { LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams(); if (layoutParams.isNestedScrollAccepted(0) && (behavior = layoutParams.getBehavior()) != null) { z2 |= behavior.onNestedFling(this, childAt, view, f, f2, z); } } } if (z2) { onChildViewsChanged(1); } return z2; } @Override // androidx.core.view.NestedScrollingParent public boolean onNestedPreFling(View view, float f, float f2) { Behavior behavior; int childCount = getChildCount(); boolean z = false; for (int i = 0; i < childCount; i++) { View childAt = getChildAt(i); if (childAt.getVisibility() != 8) { LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams(); if (layoutParams.isNestedScrollAccepted(0) && (behavior = layoutParams.getBehavior()) != null) { z |= behavior.onNestedPreFling(this, childAt, view, f, f2); } } } return z; } @Override // androidx.core.view.NestedScrollingParent public void onNestedPreScroll(View view, int i, int i2, int[] iArr) { onNestedPreScroll(view, i, i2, iArr, 0); } @Override // androidx.core.view.NestedScrollingParent2 public void onNestedPreScroll(View view, int i, int i2, int[] iArr, int i3) { Behavior behavior; int childCount = getChildCount(); boolean z = false; int i4 = 0; int i5 = 0; for (int i6 = 0; i6 < childCount; i6++) { View childAt = getChildAt(i6); if (childAt.getVisibility() != 8) { LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams(); if (layoutParams.isNestedScrollAccepted(i3) && (behavior = layoutParams.getBehavior()) != null) { int[] iArr2 = this.mTempIntPair; iArr2[1] = 0; iArr2[0] = 0; behavior.onNestedPreScroll(this, childAt, view, i, i2, iArr2, i3); int[] iArr3 = this.mTempIntPair; i4 = i > 0 ? Math.max(i4, iArr3[0]) : Math.min(i4, iArr3[0]); int[] iArr4 = this.mTempIntPair; i5 = i2 > 0 ? Math.max(i5, iArr4[1]) : Math.min(i5, iArr4[1]); z = true; } } } iArr[0] = i4; iArr[1] = i5; if (z) { onChildViewsChanged(1); } } @Override // androidx.core.view.NestedScrollingParent public void onNestedScroll(View view, int i, int i2, int i3, int i4) { onNestedScroll(view, i, i2, i3, i4, 0); } @Override // androidx.core.view.NestedScrollingParent2 public void onNestedScroll(View view, int i, int i2, int i3, int i4, int i5) { Behavior behavior; int childCount = getChildCount(); boolean z = false; for (int i6 = 0; i6 < childCount; i6++) { View childAt = getChildAt(i6); if (childAt.getVisibility() != 8) { LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams(); if (layoutParams.isNestedScrollAccepted(i5) && (behavior = layoutParams.getBehavior()) != null) { behavior.onNestedScroll(this, childAt, view, i, i2, i3, i4, i5); z = true; } } } if (z) { onChildViewsChanged(1); } } @Override // androidx.core.view.NestedScrollingParent public void onNestedScrollAccepted(View view, View view2, int i) { onNestedScrollAccepted(view, view2, i, 0); } @Override // androidx.core.view.NestedScrollingParent2 public void onNestedScrollAccepted(View view, View view2, int i, int i2) { Behavior behavior; this.mNestedScrollingParentHelper.onNestedScrollAccepted(view, view2, i, i2); this.mNestedScrollingTarget = view2; int childCount = getChildCount(); for (int i3 = 0; i3 < childCount; i3++) { View childAt = getChildAt(i3); LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams(); if (layoutParams.isNestedScrollAccepted(i2) && (behavior = layoutParams.getBehavior()) != null) { behavior.onNestedScrollAccepted(this, childAt, view, view2, i, i2); } } } /* access modifiers changed from: protected */ public void onRestoreInstanceState(Parcelable parcelable) { Parcelable parcelable2; if (!(parcelable instanceof SavedState)) { super.onRestoreInstanceState(parcelable); return; } SavedState savedState = (SavedState) parcelable; super.onRestoreInstanceState(savedState.getSuperState()); SparseArray<Parcelable> sparseArray = savedState.behaviorStates; int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { View childAt = getChildAt(i); int id = childAt.getId(); Behavior behavior = getResolvedLayoutParams(childAt).getBehavior(); if (!(id == -1 || behavior == null || (parcelable2 = sparseArray.get(id)) == null)) { behavior.onRestoreInstanceState(this, childAt, parcelable2); } } } /* access modifiers changed from: protected */ public Parcelable onSaveInstanceState() { Parcelable onSaveInstanceState; SavedState savedState = new SavedState(super.onSaveInstanceState()); SparseArray<Parcelable> sparseArray = new SparseArray<>(); int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { View childAt = getChildAt(i); int id = childAt.getId(); Behavior behavior = ((LayoutParams) childAt.getLayoutParams()).getBehavior(); if (!(id == -1 || behavior == null || (onSaveInstanceState = behavior.onSaveInstanceState(this, childAt)) == null)) { sparseArray.append(id, onSaveInstanceState); } } savedState.behaviorStates = sparseArray; return savedState; } @Override // androidx.core.view.NestedScrollingParent public boolean onStartNestedScroll(View view, View view2, int i) { return onStartNestedScroll(view, view2, i, 0); } @Override // androidx.core.view.NestedScrollingParent2 public boolean onStartNestedScroll(View view, View view2, int i, int i2) { int childCount = getChildCount(); boolean z = false; for (int i3 = 0; i3 < childCount; i3++) { View childAt = getChildAt(i3); if (childAt.getVisibility() != 8) { LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams(); Behavior behavior = layoutParams.getBehavior(); if (behavior != null) { boolean onStartNestedScroll = behavior.onStartNestedScroll(this, childAt, view, view2, i, i2); z |= onStartNestedScroll; layoutParams.setNestedScrollAccepted(i2, onStartNestedScroll); } else { layoutParams.setNestedScrollAccepted(i2, false); } } } return z; } @Override // androidx.core.view.NestedScrollingParent public void onStopNestedScroll(View view) { onStopNestedScroll(view, 0); } @Override // androidx.core.view.NestedScrollingParent2 public void onStopNestedScroll(View view, int i) { this.mNestedScrollingParentHelper.onStopNestedScroll(view, i); int childCount = getChildCount(); for (int i2 = 0; i2 < childCount; i2++) { View childAt = getChildAt(i2); LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams(); if (layoutParams.isNestedScrollAccepted(i)) { Behavior behavior = layoutParams.getBehavior(); if (behavior != null) { behavior.onStopNestedScroll(this, childAt, view, i); } layoutParams.resetNestedScroll(i); layoutParams.resetChangedAfterNestedScroll(); } } this.mNestedScrollingTarget = null; } /* JADX WARNING: Code restructure failed: missing block: B:3:0x0012, code lost: if (r3 != false) goto L_0x0016; */ /* JADX WARNING: Removed duplicated region for block: B:11:0x0031 */ /* JADX WARNING: Removed duplicated region for block: B:12:0x0037 */ /* JADX WARNING: Removed duplicated region for block: B:15:0x004c */ public boolean onTouchEvent(MotionEvent motionEvent) { boolean z; boolean z2; MotionEvent motionEvent2; int actionMasked = motionEvent.getActionMasked(); if (this.mBehaviorTouchView == null) { z2 = performIntercept(motionEvent, 1); } else { z2 = false; } Behavior behavior = ((LayoutParams) this.mBehaviorTouchView.getLayoutParams()).getBehavior(); if (behavior != null) { z = behavior.onTouchEvent(this, this.mBehaviorTouchView, motionEvent); motionEvent2 = null; if (this.mBehaviorTouchView != null) { z |= super.onTouchEvent(motionEvent); } else if (z2) { long uptimeMillis = SystemClock.uptimeMillis(); motionEvent2 = MotionEvent.obtain(uptimeMillis, uptimeMillis, 3, 0.0f, 0.0f, 0); super.onTouchEvent(motionEvent2); } if (motionEvent2 != null) { motionEvent2.recycle(); } if (actionMasked == 1 || actionMasked == 3) { resetTouchBehaviors(false); } return z; } z = false; motionEvent2 = null; if (this.mBehaviorTouchView != null) { } if (motionEvent2 != null) { } resetTouchBehaviors(false); return z; } /* access modifiers changed from: package-private */ public void recordLastChildRect(View view, Rect rect) { ((LayoutParams) view.getLayoutParams()).setLastChildRect(rect); } /* access modifiers changed from: package-private */ public void removePreDrawListener() { if (this.mIsAttachedToWindow && this.mOnPreDrawListener != null) { getViewTreeObserver().removeOnPreDrawListener(this.mOnPreDrawListener); } this.mNeedsPreDrawListener = false; } public boolean requestChildRectangleOnScreen(View view, Rect rect, boolean z) { Behavior behavior = ((LayoutParams) view.getLayoutParams()).getBehavior(); if (behavior == null || !behavior.onRequestChildRectangleOnScreen(this, view, rect, z)) { return super.requestChildRectangleOnScreen(view, rect, z); } return true; } public void requestDisallowInterceptTouchEvent(boolean z) { super.requestDisallowInterceptTouchEvent(z); if (z && !this.mDisallowInterceptReset) { resetTouchBehaviors(false); this.mDisallowInterceptReset = true; } } public void setFitsSystemWindows(boolean z) { super.setFitsSystemWindows(z); setupForInsets(); } public void setOnHierarchyChangeListener(ViewGroup.OnHierarchyChangeListener onHierarchyChangeListener) { this.mOnHierarchyChangeListener = onHierarchyChangeListener; } public void setStatusBarBackground(Drawable drawable) { Drawable drawable2 = this.mStatusBarBackground; if (drawable2 != drawable) { Drawable drawable3 = null; if (drawable2 != null) { drawable2.setCallback(null); } if (drawable != null) { drawable3 = drawable.mutate(); } this.mStatusBarBackground = drawable3; if (drawable3 != null) { if (drawable3.isStateful()) { this.mStatusBarBackground.setState(getDrawableState()); } DrawableCompat.setLayoutDirection(this.mStatusBarBackground, ViewCompat.getLayoutDirection(this)); this.mStatusBarBackground.setVisible(getVisibility() == 0, false); this.mStatusBarBackground.setCallback(this); } ViewCompat.postInvalidateOnAnimation(this); } } public void setStatusBarBackgroundColor(int i) { setStatusBarBackground(new ColorDrawable(i)); } public void setStatusBarBackgroundResource(int i) { setStatusBarBackground(i != 0 ? ContextCompat.getDrawable(getContext(), i) : null); } public void setVisibility(int i) { super.setVisibility(i); boolean z = i == 0; Drawable drawable = this.mStatusBarBackground; if (drawable != null && drawable.isVisible() != z) { this.mStatusBarBackground.setVisible(z, false); } } /* access modifiers changed from: package-private */ public final WindowInsetsCompat setWindowInsets(WindowInsetsCompat windowInsetsCompat) { if (ObjectsCompat.equals(this.mLastInsets, windowInsetsCompat)) { return windowInsetsCompat; } this.mLastInsets = windowInsetsCompat; boolean z = true; boolean z2 = windowInsetsCompat != null && windowInsetsCompat.getSystemWindowInsetTop() > 0; this.mDrawStatusBarBackground = z2; if (z2 || getBackground() != null) { z = false; } setWillNotDraw(z); WindowInsetsCompat dispatchApplyWindowInsetsToBehaviors = dispatchApplyWindowInsetsToBehaviors(windowInsetsCompat); requestLayout(); return dispatchApplyWindowInsetsToBehaviors; } /* access modifiers changed from: protected */ public boolean verifyDrawable(Drawable drawable) { return super.verifyDrawable(drawable) || drawable == this.mStatusBarBackground; } }