package com.bytedance.ies.xelement;

import X.C4398QmZ;
import X.C4502QoF;
import X.C4590Qpf;
import X.C4596Qpl;
import X.C4600Qpp;
import X.LC0;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.view.View;
import com.bytedance.covode.number.Covode;
import com.lynx.tasm.base.LLog;
import com.lynx.tasm.behavior.ui.LynxBaseUI;
import com.lynx.tasm.behavior.ui.LynxFlattenUI;
import com.lynx.tasm.behavior.ui.scroll.AbsLynxUIScroll;
import java.util.Map;

public class LynxNestedScrollView extends AbsLynxUIScroll<C4590Qpf> implements C4600Qpp {
    public boolean LIZ;
    public boolean LIZIZ;
    public boolean LIZJ;
    public boolean LIZLLL;
    public boolean LJ;

    static {
        Covode.recordClassIndex(31962);
    }

    public final void LIZ(int i) {
    }

    public final void LIZ(LynxBaseUI lynxBaseUI, boolean z, String str, String str2) {
    }

    public final void LIZ(LynxBaseUI lynxBaseUI, boolean z, String str, String str2, int i) {
    }

    public Rect getBoundRectForOverflow() {
        return null;
    }

    public void scrollToIndex(int i) {
    }

    public void setLowerThreshole(int i) {
    }

    public void setScrollLeft(int i) {
    }

    public void setScrollTop(int i) {
    }

    public void setUpperThreshole(int i) {
    }

    public int getScrollX() {
        return ((C4590Qpf) this.mView).getHScrollView().getScrollX();
    }

    public int getScrollY() {
        return ((C4590Qpf) this.mView).getScrollY();
    }

    public void invalidate() {
        ((C4590Qpf) this.mView).getLinearLayout().invalidate();
    }

    private void LIZ() {
        if (this.LIZIZ) {
            ((C4590Qpf) this.mView).setOrientation(1);
        } else {
            ((C4590Qpf) this.mView).setOrientation(0);
        }
    }

    public void onLayoutUpdated() {
        super.onLayoutUpdated();
        int i = this.mPaddingLeft + this.mBorderLeftWidth;
        int i2 = this.mPaddingRight + this.mBorderRightWidth;
        ((C4590Qpf) this.mView).setPadding(i, this.mPaddingTop + this.mBorderTopWidth, i2, this.mPaddingBottom + this.mBorderBottomWidth);
    }

    public void measure() {
        boolean z;
        if (((C4590Qpf) this.mView).getOrientation() == 0) {
            z = true;
        } else {
            z = false;
        }
        int width = getWidth();
        int height = getHeight();
        for (int i = 0; i < getChildCount(); i++) {
            LynxBaseUI childAt = getChildAt(i);
            if (z) {
                width = Math.max(width, childAt.getWidth() + childAt.getLeft());
            } else {
                height = Math.max(height, childAt.getHeight() + childAt.getTop());
            }
        }
        C4590Qpf qpf = (C4590Qpf) this.mView;
        qpf.LJIIIIZZ = height;
        qpf.LJII = width;
        if (qpf.LIZLLL != null) {
            qpf.LIZLLL.requestLayout();
        }
        super.measure();
    }

    public LynxNestedScrollView(C4398QmZ qmZ) {
        super(qmZ);
    }

    public void setScrollTap(boolean z) {
        this.LIZ = z;
    }

    public final void LIZIZ(boolean z) {
        this.LIZIZ = !z;
        LIZ();
    }

    /* JADX WARNING: type inference failed for: r1v0, types: [android.view.View, X.Qpf] */
    public /* synthetic */ View createView(Context context) {
        ? qpf = new C4590Qpf(context);
        qpf.setOnScrollListener(new C4600Qpp() {
            static {
                Covode.recordClassIndex(31965);
            }

            public final void LIZ(int i, int i2, int i3, int i4) {
            }

            public final void LIZ(int i) {
                if (!LynxNestedScrollView.this.LIZ) {
                    if (i != 0) {
                        LynxNestedScrollView.this.recognizeGesturere();
                    }
                } else if (i == 1) {
                    LynxNestedScrollView.this.recognizeGesturere();
                }
            }
        });
        return qpf;
    }

    public void setScrollBarEnable(boolean z) {
        try {
            ((C4590Qpf) this.mView).setScrollBarEnable(Boolean.valueOf(z).booleanValue());
        } catch (Exception e) {
            LLog.LIZ(6, "UIScrollView", e.getMessage());
        }
    }

    public void setEvents(Map<String, LC0> map) {
        super.setEvents(map);
        if (map != null) {
            this.LIZJ = false;
            this.LIZLLL = false;
            this.LJ = false;
            if (map.containsKey("scrolltolower")) {
                this.LIZLLL = true;
            }
            if (map.containsKey("scrolltoupper")) {
                this.LIZJ = true;
            }
            if (map.containsKey("scroll")) {
                this.LJ = true;
            }
            if (this.LIZLLL || this.LIZJ || this.LJ) {
                ((C4590Qpf) this.mView).setOnScrollListener(this);
            }
        }
    }

    public final void LIZ(boolean z) {
        this.LIZIZ = z;
        LIZ();
    }

    public void drawChild(LynxFlattenUI lynxFlattenUI, Canvas canvas) {
        lynxFlattenUI.LIZIZ(canvas);
    }

    public final void LIZ(int i, int i2, int i3, int i4) {
        View childAt;
        int i5 = i2;
        int i6 = i;
        int i7 = i4;
        int i8 = i3;
        if (this.LJ) {
            LIZ(i6, i5, i8, i7, "scroll");
        }
        if (i6 == i8 && i6 == 0) {
            if (i5 != 0) {
                View childAt2 = ((C4590Qpf) this.mView).getChildAt(0);
                if (childAt2 != null && childAt2.getMeasuredHeight() == getScrollY() + ((C4590Qpf) this.mView).getMeasuredHeight() && this.LIZLLL) {
                    LIZ(0, i5, i8, i7, "scrolltolower");
                }
            } else if (this.LIZJ) {
                LIZ(0, 0, i8, i7, "scrolltoupper");
            }
        } else if (i5 != i7 || i5 != 0) {
        } else {
            if (i6 == 0 || (i6 > 0 && i8 == 0)) {
                if (this.LIZJ) {
                    LIZ(i6, 0, i8, i7, "scrolltoupper");
                }
            } else if (((C4590Qpf) this.mView).getHScrollView() != null && (childAt = ((C4590Qpf) this.mView).getHScrollView().getChildAt(0)) != null && i6 == childAt.getMeasuredWidth() - ((C4590Qpf) this.mView).getMeasuredWidth() && this.LIZLLL) {
                LIZ(i6, 0, i8, i7, "scrolltolower");
            }
        }
    }

    private void LIZ(int i, int i2, int i3, int i4, String str) {
        C4596Qpl LIZ2 = C4596Qpl.LIZ(getSign(), str);
        int i5 = i;
        int i6 = i2;
        LIZ2.LIZ(i5, i6, ((C4590Qpf) this.mView).getContentHeight(), ((C4590Qpf) this.mView).getContentWidth(), i3 - i5, i4 - i6);
        if (this.mContext != null) {
            this.mContext.LJFF.LIZ((C4502QoF) LIZ2);
        }
    }
}
