package com.bytedance.android.livesdk.container.behavior;

import X.05s;
import X.1gt;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import com.bytedance.android.live.design.view.sheet.LiveBottomSheetBehavior;
import com.bytedance.android.livesdk.livesetting.hybrid.ContainerBehaviorEnableSetting;
import com.bytedance.covode.number.Covode;

public class ContainerBottomSheetBehavior<V extends View> extends LiveBottomSheetBehavior<V> {
    public boolean LJIJJLI;

    static {
        Covode.recordClassIndex(15493);
    }

    public ContainerBottomSheetBehavior() {
    }

    public static <V extends View> ContainerBottomSheetBehavior<V> LIZIZ(V v) {
        05s layoutParams = v.getLayoutParams();
        if (layoutParams instanceof 05s) {
            ContainerBottomSheetBehavior<V> containerBottomSheetBehavior = layoutParams.LIZ;
            if (containerBottomSheetBehavior instanceof ContainerBottomSheetBehavior) {
                return containerBottomSheetBehavior;
            }
            throw new IllegalArgumentException("The view is not associated with BottomSheetBehavior");
        }
        throw new IllegalArgumentException("The view is not a child of CoordinatorLayout");
    }

    public ContainerBottomSheetBehavior(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public boolean onInterceptTouchEvent(1gt r7, V v, MotionEvent motionEvent) {
        V v2 = v;
        if (!ContainerBehaviorEnableSetting.INSTANCE.getValue()) {
            return ContainerBottomSheetBehavior.super.onInterceptTouchEvent(r7, v2, motionEvent);
        }
        if (!this.LJIJJLI) {
            return ContainerBottomSheetBehavior.super.onInterceptTouchEvent(r7, v2, motionEvent);
        }
        if (LIZ(v2, 1, 1, (int) motionEvent.getX(), (int) motionEvent.getY())) {
            return false;
        }
        return ContainerBottomSheetBehavior.super.onInterceptTouchEvent(r7, v2, motionEvent);
    }

    private boolean LIZ(View view, int i, int i2, int i3, int i4) {
        int i5;
        int i6 = i;
        int i7 = i2;
        if (view instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) view;
            int scrollX = view.getScrollX();
            int scrollY = view.getScrollY();
            for (int childCount = viewGroup.getChildCount() - 1; childCount >= 0; childCount--) {
                View childAt = viewGroup.getChildAt(childCount);
                int i8 = i3 + scrollX;
                if (i8 >= childAt.getLeft() && i8 < childAt.getRight() && (i5 = i4 + scrollY) >= childAt.getTop() && i5 < childAt.getBottom()) {
                    if (LIZ(childAt, i6, i7, i8 - childAt.getLeft(), i5 - childAt.getTop())) {
                        return true;
                    }
                }
            }
        }
        if (view.canScrollHorizontally(-i6) || view.canScrollVertically(-i7)) {
            return true;
        }
        return false;
    }
}
