package com.bytedance.ies.xelement.viewpager;

import X.2Pr;
import X.2te;
import X.2th;
import X.7tl;
import X.7xU;
import X.C3308QOb;
import X.C4398QmZ;
import X.C5128QyL;
import X.C5134QyR;
import X.C5136QyT;
import X.C5141QyY;
import X.C5144Qyb;
import X.C5150Qyh;
import X.C5156Qyn;
import X.C5159Qyq;
import X.LC0;
import X.Ls0;
import X.M12;
import X.Q39;
import X.QNL;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.LayerDrawable;
import android.os.Build;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import androidx.core.g.t;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.xelement.viewpager.childitem.LynxTabbarItem;
import com.lynx.react.bridge.Callback;
import com.lynx.react.bridge.JavaOnlyMap;
import com.lynx.react.bridge.ReadableMap;
import com.lynx.tasm.behavior.ui.LynxBaseUI;
import com.lynx.tasm.behavior.ui.LynxUI;
import com.lynx.tasm.behavior.ui.view.UISimpleView;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import kotlin.h.b.n;

public class LynxTabBarView extends UISimpleView<C5156Qyn> {
    public static final C5134QyR LJFF = new C5134QyR((byte) 0);
    public boolean LIZ;
    public C5156Qyn LIZIZ;
    public C5150Qyh LIZJ;
    public C5159Qyq LIZLLL;
    public Map<Integer, String> LJ = new HashMap();
    public float LJI = 9.0f;
    public boolean LJII = true;
    public final ArrayList<C3308QOb> LJIIIIZZ = new ArrayList<>();
    public float LJIIIZ = -1.0f;
    public final C5128QyL LJIIJ = new C5128QyL(this);

    static {
        Covode.recordClassIndex(32620);
    }

    public boolean needCustomLayout() {
        return true;
    }

    public final C5156Qyn LIZ() {
        C5156Qyn qyn = this.LIZIZ;
        if (qyn == null) {
            n.LIZ(Q39.LIZJ);
        }
        return qyn;
    }

    private final void LIZLLL() {
        C5156Qyn qyn = this.LIZIZ;
        if (qyn == null) {
            n.LIZ(Q39.LIZJ);
        }
        if (qyn.getBackground() == null) {
            C5156Qyn qyn2 = this.LIZIZ;
            if (qyn2 == null) {
                n.LIZ(Q39.LIZJ);
            }
            qyn2.setBackgroundResource(2131233368);
            C5156Qyn qyn3 = this.LIZIZ;
            if (qyn3 == null) {
                n.LIZ(Q39.LIZJ);
            }
            qyn3.getBackground().mutate();
        }
    }

    public final void LIZIZ() {
        T t;
        int i;
        Integer num;
        List<LynxBaseUI> list = this.mChildren;
        n.LIZ(list, Q39.LIZJ);
        Iterator<T> it = list.iterator();
        while (true) {
            if (!it.hasNext()) {
                t = null;
                break;
            }
            t = it.next();
            LynxBaseUI lynxBaseUI = (LynxBaseUI) t;
            if ((lynxBaseUI instanceof LynxTabbarItem) && ((LynxTabbarItem) lynxBaseUI).LIZLLL) {
                break;
            }
        }
        LynxTabbarItem lynxTabbarItem = (LynxTabbarItem) t;
        if (lynxTabbarItem == null || (num = lynxTabbarItem.LIZ) == null) {
            i = 0;
        } else {
            i = num.intValue();
        }
        LIZ(0, i);
    }

    public final void LIZJ() {
        C5156Qyn qyn = this.LIZIZ;
        if (qyn == null) {
            n.LIZ(Q39.LIZJ);
        }
        qyn.addOnTabSelectedListener(this.LJIIJ);
        if (!this.LJII) {
            C5128QyL qyL = this.LJIIJ;
            C5156Qyn qyn2 = this.LIZIZ;
            if (qyn2 == null) {
                n.LIZ(Q39.LIZJ);
            }
            C5156Qyn qyn3 = this.LIZIZ;
            if (qyn3 == null) {
                n.LIZ(Q39.LIZJ);
            }
            qyL.LIZ(qyn2.getTabAt(qyn3.getSelectedTabPosition()));
        }
    }

    public void measure() {
        if (this.LJIIIZ > 0.0f) {
            C5156Qyn qyn = this.LIZIZ;
            if (qyn == null) {
                n.LIZ(Q39.LIZJ);
            }
            ViewGroup.LayoutParams layoutParams = qyn.getLayoutParams();
            if (layoutParams != null) {
                C5136QyT qyT = C5136QyT.LIZ;
                C4398QmZ qmZ = this.mContext;
                n.LIZ(qmZ, Q39.LIZJ);
                layoutParams.height = qyT.LIZIZ(qmZ, this.LJIIIZ);
            }
        }
        super.measure();
    }

    @QNL(LIZ = "disable-attach-event", LJFF = true)
    public final void setDisableAttachEvent(boolean z) {
        this.LJII = z;
    }

    public ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return new LinearLayout.LayoutParams(-2, -2);
    }

    @QNL(LIZ = "tab-inter-space")
    public final void setTabInterspace(float f) {
        this.LJI = f / 2.0f;
    }

    public void setEvents(Map<String, LC0> map) {
        super.setEvents(map);
        if (map != null) {
            this.LIZ = map.containsKey("change");
        }
    }

    @QNL(LIZ = "android-force-bind-change-event", LJFF = false)
    public final void setOriginChangeEvent(boolean z) {
        if (this.LIZIZ != null) {
            LIZJ();
        }
    }

    @QNL(LIZ = "tab-indicator-color")
    public final void setTabIndicatorColor(String str) {
        M12.LIZ(str);
        C5156Qyn qyn = this.LIZIZ;
        if (qyn == null) {
            n.LIZ(Q39.LIZJ);
        }
        qyn.setSelectedTabIndicatorColor(C5136QyT.LIZ.LIZ(str));
    }

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

    public /* synthetic */ View createView(Context context) {
        if (context == null) {
            return null;
        }
        this.LIZIZ = LJFF.LIZ(context);
        this.LIZJ = new C5144Qyb(this);
        C5156Qyn qyn = this.LIZIZ;
        if (qyn == null) {
            n.LIZ(Q39.LIZJ);
        }
        qyn.addOnAttachStateChangeListener(new C5141QyY(this));
        C5156Qyn qyn2 = this.LIZIZ;
        if (qyn2 != null) {
            return qyn2;
        }
        n.LIZ(Q39.LIZJ);
        return qyn2;
    }

    public void removeChild(LynxBaseUI lynxBaseUI) {
        if ((lynxBaseUI instanceof LynxUI) && (lynxBaseUI instanceof LynxTabbarItem)) {
            this.mChildren.remove(lynxBaseUI);
            ArrayList<C3308QOb> arrayList = this.LJIIIIZZ;
            LynxTabbarItem lynxTabbarItem = (LynxTabbarItem) lynxBaseUI;
            View view = lynxTabbarItem.LIZJ;
            if (arrayList != null) {
                Ls0.LIZIZ(arrayList).remove(view);
                C5156Qyn qyn = this.LIZIZ;
                if (qyn == null) {
                    n.LIZ(Q39.LIZJ);
                }
                qyn.removeTab(lynxTabbarItem.LIZIZ);
                return;
            }
            throw new 7xU("null cannot be cast to non-null type kotlin.collections.MutableCollection<T>");
        }
    }

    @QNL(LIZ = "tab-indicator-top")
    public final void set(float f) {
        C5156Qyn qyn = this.LIZIZ;
        if (qyn == null) {
            n.LIZ(Q39.LIZJ);
        }
        Drawable tabSelectedIndicator = qyn.getTabSelectedIndicator();
        if (tabSelectedIndicator != null) {
            C5136QyT qyT = C5136QyT.LIZ;
            C4398QmZ qmZ = this.mContext;
            n.LIZ(qmZ, Q39.LIZJ);
            ((LayerDrawable) tabSelectedIndicator).setLayerInset(0, 0, 0, 0, qyT.LIZ(qmZ, f));
            return;
        }
        throw new 7xU("null cannot be cast to non-null type android.graphics.drawable.LayerDrawable");
    }

    @QNL(LIZ = "border-top")
    public final void setBorderTop(float f) {
        if (Build.VERSION.SDK_INT >= 23) {
            LIZLLL();
            C5156Qyn qyn = this.LIZIZ;
            if (qyn == null) {
                n.LIZ(Q39.LIZJ);
            }
            Drawable background = qyn.getBackground();
            if (background != null) {
                C5136QyT qyT = C5136QyT.LIZ;
                C4398QmZ qmZ = this.mContext;
                n.LIZ(qmZ, Q39.LIZJ);
                ((LayerDrawable) background).setLayerInset(0, 0, 0, 0, qyT.LIZ(qmZ, f));
                return;
            }
            throw new 7xU("null cannot be cast to non-null type android.graphics.drawable.LayerDrawable");
        }
    }

    public void setLynxDirection(int i) {
        super.setLynxDirection(i);
        if (i == 2 || i == 2) {
            C5156Qyn qyn = this.LIZIZ;
            if (qyn == null) {
                n.LIZ(Q39.LIZJ);
            }
            qyn.setLayoutDirection(1);
            return;
        }
        C5156Qyn qyn2 = this.LIZIZ;
        if (qyn2 == null) {
            n.LIZ(Q39.LIZJ);
        }
        qyn2.setLayoutDirection(0);
    }

    @QNL(LIZ = "tab-height")
    public final void setTabHeight(float f) {
        C5156Qyn qyn = this.LIZIZ;
        if (qyn == null) {
            n.LIZ(Q39.LIZJ);
        }
        ViewGroup.LayoutParams layoutParams = qyn.getLayoutParams();
        if (layoutParams != null) {
            C5136QyT qyT = C5136QyT.LIZ;
            C4398QmZ qmZ = this.mContext;
            n.LIZ(qmZ, Q39.LIZJ);
            layoutParams.height = qyT.LIZ(qmZ, f);
        }
        C5156Qyn qyn2 = this.LIZIZ;
        if (qyn2 == null) {
            n.LIZ(Q39.LIZJ);
        }
        qyn2.requestLayout();
    }

    @QNL(LIZ = "tab-height-rpx")
    public final void setTabHeightRpx(float f) {
        this.LJIIIZ = f;
        C5156Qyn qyn = this.LIZIZ;
        if (qyn == null) {
            n.LIZ(Q39.LIZJ);
        }
        ViewGroup.LayoutParams layoutParams = qyn.getLayoutParams();
        if (layoutParams != null) {
            C5136QyT qyT = C5136QyT.LIZ;
            C4398QmZ qmZ = this.mContext;
            n.LIZ(qmZ, Q39.LIZJ);
            layoutParams.height = qyT.LIZIZ(qmZ, this.LJIIIZ);
        }
        C5156Qyn qyn2 = this.LIZIZ;
        if (qyn2 == null) {
            n.LIZ(Q39.LIZJ);
        }
        qyn2.requestLayout();
    }

    @QNL(LIZ = "background")
    public final void setBackground(String str) {
        M12.LIZ(str);
        LIZLLL();
        if (Build.VERSION.SDK_INT < 23) {
            C5156Qyn qyn = this.LIZIZ;
            if (qyn == null) {
                n.LIZ(Q39.LIZJ);
            }
            qyn.setBackgroundColor(C5136QyT.LIZ.LIZ(str));
            return;
        }
        C5156Qyn qyn2 = this.LIZIZ;
        if (qyn2 == null) {
            n.LIZ(Q39.LIZJ);
        }
        Drawable background = qyn2.getBackground();
        if (background != null) {
            Drawable drawable = ((LayerDrawable) background).getDrawable(0);
            if (drawable != null) {
                ((GradientDrawable) drawable).setColor(C5136QyT.LIZ.LIZ(str));
                return;
            }
            throw new 7xU("null cannot be cast to non-null type android.graphics.drawable.GradientDrawable");
        }
        throw new 7xU("null cannot be cast to non-null type android.graphics.drawable.LayerDrawable");
    }

    public void setBackgroundColor(int i) {
        LIZLLL();
        if (Build.VERSION.SDK_INT < 23) {
            C5156Qyn qyn = this.LIZIZ;
            if (qyn == null) {
                n.LIZ(Q39.LIZJ);
            }
            qyn.setBackgroundColor(i);
            return;
        }
        C5156Qyn qyn2 = this.LIZIZ;
        if (qyn2 == null) {
            n.LIZ(Q39.LIZJ);
        }
        Drawable background = qyn2.getBackground();
        if (background != null) {
            Drawable drawable = ((LayerDrawable) background).getDrawable(0);
            if (drawable != null) {
                ((GradientDrawable) drawable).setColor(i);
                return;
            }
            throw new 7xU("null cannot be cast to non-null type android.graphics.drawable.GradientDrawable");
        }
        throw new 7xU("null cannot be cast to non-null type android.graphics.drawable.LayerDrawable");
    }

    @QNL(LIZ = "border-height")
    public final void setBorderHeight(float f) {
        if (Build.VERSION.SDK_INT >= 23) {
            LIZLLL();
            C5156Qyn qyn = this.LIZIZ;
            if (qyn == null) {
                n.LIZ(Q39.LIZJ);
            }
            Drawable background = qyn.getBackground();
            if (background != null) {
                Drawable drawable = ((LayerDrawable) background).getDrawable(1);
                if (drawable != null) {
                    GradientDrawable gradientDrawable = (GradientDrawable) drawable;
                    int intrinsicWidth = gradientDrawable.getIntrinsicWidth();
                    C5136QyT qyT = C5136QyT.LIZ;
                    C4398QmZ qmZ = this.mContext;
                    n.LIZ(qmZ, Q39.LIZJ);
                    gradientDrawable.setSize(intrinsicWidth, qyT.LIZ(qmZ, f));
                    return;
                }
                throw new 7xU("null cannot be cast to non-null type android.graphics.drawable.GradientDrawable");
            }
            throw new 7xU("null cannot be cast to non-null type android.graphics.drawable.LayerDrawable");
        }
    }

    @QNL(LIZ = "border-color")
    public final void setBorderLineColor(String str) {
        M12.LIZ(str);
        if (Build.VERSION.SDK_INT >= 23) {
            LIZLLL();
            C5156Qyn qyn = this.LIZIZ;
            if (qyn == null) {
                n.LIZ(Q39.LIZJ);
            }
            Drawable background = qyn.getBackground();
            if (background != null) {
                Drawable drawable = ((LayerDrawable) background).getDrawable(1);
                if (drawable != null) {
                    ((GradientDrawable) drawable).setColor(C5136QyT.LIZ.LIZ(str));
                    return;
                }
                throw new 7xU("null cannot be cast to non-null type android.graphics.drawable.GradientDrawable");
            }
            throw new 7xU("null cannot be cast to non-null type android.graphics.drawable.LayerDrawable");
        }
    }

    @QNL(LIZ = "border-width")
    public final void setBorderWidth(float f) {
        if (Build.VERSION.SDK_INT >= 23) {
            LIZLLL();
            C5136QyT qyT = C5136QyT.LIZ;
            C4398QmZ qmZ = this.mContext;
            n.LIZ(qmZ, Q39.LIZJ);
            int LIZ2 = (int) (((float) qyT.LIZ((Context) qmZ)) * (f / 375.0f));
            C5156Qyn qyn = this.LIZIZ;
            if (qyn == null) {
                n.LIZ(Q39.LIZJ);
            }
            Drawable background = qyn.getBackground();
            if (background != null) {
                Drawable drawable = ((LayerDrawable) background).getDrawable(1);
                if (drawable != null) {
                    GradientDrawable gradientDrawable = (GradientDrawable) drawable;
                    gradientDrawable.setSize(LIZ2, gradientDrawable.getIntrinsicHeight());
                    return;
                }
                throw new 7xU("null cannot be cast to non-null type android.graphics.drawable.GradientDrawable");
            }
            throw new 7xU("null cannot be cast to non-null type android.graphics.drawable.LayerDrawable");
        }
    }

    @QNL(LIZ = "tab-indicator-height")
    public final void setTabIndicatorHeight(float f) {
        C5156Qyn qyn = this.LIZIZ;
        if (qyn == null) {
            n.LIZ(Q39.LIZJ);
        }
        Drawable tabSelectedIndicator = qyn.getTabSelectedIndicator();
        if (tabSelectedIndicator != null) {
            Drawable drawable = ((LayerDrawable) tabSelectedIndicator).getDrawable(0);
            if (drawable != null) {
                GradientDrawable gradientDrawable = (GradientDrawable) drawable;
                int intrinsicWidth = gradientDrawable.getIntrinsicWidth();
                C5136QyT qyT = C5136QyT.LIZ;
                C4398QmZ qmZ = this.mContext;
                n.LIZ(qmZ, Q39.LIZJ);
                gradientDrawable.setSize(intrinsicWidth, qyT.LIZ(qmZ, f));
                C5156Qyn qyn2 = this.LIZIZ;
                if (qyn2 == null) {
                    n.LIZ(Q39.LIZJ);
                }
                qyn2.requestLayout();
                return;
            }
            throw new 7xU("null cannot be cast to non-null type android.graphics.drawable.GradientDrawable");
        }
        throw new 7xU("null cannot be cast to non-null type android.graphics.drawable.LayerDrawable");
    }

    @QNL(LIZ = "tab-indicator-radius")
    public final void setTabIndicatorRadius(float f) {
        C5156Qyn qyn = this.LIZIZ;
        if (qyn == null) {
            n.LIZ(Q39.LIZJ);
        }
        Drawable tabSelectedIndicator = qyn.getTabSelectedIndicator();
        if (tabSelectedIndicator != null) {
            Drawable drawable = ((LayerDrawable) tabSelectedIndicator).getDrawable(0);
            if (drawable != null) {
                C5136QyT qyT = C5136QyT.LIZ;
                C4398QmZ qmZ = this.mContext;
                n.LIZ(qmZ, Q39.LIZJ);
                ((GradientDrawable) drawable).setCornerRadius((float) qyT.LIZ(qmZ, f));
                C5156Qyn qyn2 = this.LIZIZ;
                if (qyn2 == null) {
                    n.LIZ(Q39.LIZJ);
                }
                qyn2.requestLayout();
                return;
            }
            throw new 7xU("null cannot be cast to non-null type android.graphics.drawable.GradientDrawable");
        }
        throw new 7xU("null cannot be cast to non-null type android.graphics.drawable.LayerDrawable");
    }

    @QNL(LIZ = "tab-indicator-width")
    public final void setTabIndicatorWidth(float f) {
        C5156Qyn qyn = this.LIZIZ;
        if (qyn == null) {
            n.LIZ(Q39.LIZJ);
        }
        Drawable tabSelectedIndicator = qyn.getTabSelectedIndicator();
        if (tabSelectedIndicator != null) {
            Drawable drawable = ((LayerDrawable) tabSelectedIndicator).getDrawable(0);
            if (drawable != null) {
                GradientDrawable gradientDrawable = (GradientDrawable) drawable;
                C5136QyT qyT = C5136QyT.LIZ;
                C4398QmZ qmZ = this.mContext;
                n.LIZ(qmZ, Q39.LIZJ);
                gradientDrawable.setSize((int) (((float) qyT.LIZ((Context) qmZ)) * (f / 375.0f)), gradientDrawable.getIntrinsicHeight());
                C5156Qyn qyn2 = this.LIZIZ;
                if (qyn2 == null) {
                    n.LIZ(Q39.LIZJ);
                }
                qyn2.requestLayout();
                return;
            }
            throw new 7xU("null cannot be cast to non-null type android.graphics.drawable.GradientDrawable");
        }
        throw new 7xU("null cannot be cast to non-null type android.graphics.drawable.LayerDrawable");
    }

    @QNL(LIZ = "tab-padding-left")
    public final void setTabPaddingLeft(int i) {
        try {
            C5156Qyn qyn = this.LIZIZ;
            if (qyn == null) {
                n.LIZ(Q39.LIZJ);
            }
            Field declaredField = qyn.getClass().getDeclaredField("contentInsetStart");
            n.LIZ(declaredField, Q39.LIZJ);
            declaredField.setAccessible(true);
            C5156Qyn qyn2 = this.LIZIZ;
            if (qyn2 == null) {
                n.LIZ(Q39.LIZJ);
            }
            C5136QyT qyT = C5136QyT.LIZ;
            C4398QmZ qmZ = this.mContext;
            n.LIZ(qmZ, Q39.LIZJ);
            declaredField.set(qyn2, Integer.valueOf(qyT.LIZ(qmZ, (float) i)));
            C5156Qyn qyn3 = this.LIZIZ;
            if (qyn3 == null) {
                n.LIZ(Q39.LIZJ);
            }
            Method declaredMethod = qyn3.getClass().getDeclaredMethod("applyModeAndGravity", new Class[0]);
            n.LIZ(declaredMethod, Q39.LIZJ);
            declaredMethod.setAccessible(true);
            C5156Qyn qyn4 = this.LIZIZ;
            if (qyn4 == null) {
                n.LIZ(Q39.LIZJ);
            }
            2te.constructor-impl(declaredMethod.invoke(qyn4, new Object[0]));
        } catch (Throwable th) {
            2te.constructor-impl(2th.LIZ(th));
        }
    }

    @QNL(LIZ = "tab-padding-right")
    public final void setTabPaddingRight(int i) {
        try {
            C5156Qyn qyn = this.LIZIZ;
            if (qyn == null) {
                n.LIZ(Q39.LIZJ);
            }
            Field declaredField = qyn.getClass().getDeclaredField("slidingTabIndicator");
            n.LIZ(declaredField, Q39.LIZJ);
            declaredField.setAccessible(true);
            C5156Qyn qyn2 = this.LIZIZ;
            if (qyn2 == null) {
                n.LIZ(Q39.LIZJ);
            }
            Object obj = declaredField.get(qyn2);
            if (obj != null) {
                LinearLayout linearLayout = (LinearLayout) obj;
                int paddingStart = linearLayout.getPaddingStart();
                int top = linearLayout.getTop();
                C5136QyT qyT = C5136QyT.LIZ;
                C4398QmZ qmZ = this.mContext;
                n.LIZ(qmZ, Q39.LIZJ);
                t.LIZ(linearLayout, paddingStart, top, qyT.LIZ(qmZ, (float) i), linearLayout.getBottom());
                C5156Qyn qyn3 = this.LIZIZ;
                if (qyn3 == null) {
                    n.LIZ(Q39.LIZJ);
                }
                qyn3.requestLayout();
                2te.constructor-impl(2Pr.LIZ);
                return;
            }
            throw new 7xU("null cannot be cast to non-null type android.widget.LinearLayout");
        } catch (Throwable th) {
            2te.constructor-impl(2th.LIZ(th));
        }
    }

    @QNL(LIZ = "tab-layout-gravity")
    public final void setTablayoutGravity(String str) {
        Field declaredField;
        M12.LIZ(str);
        Locale locale = Locale.ROOT;
        n.LIZ(locale, Q39.LIZJ);
        String lowerCase = str.toLowerCase(locale);
        n.LIZ(lowerCase, Q39.LIZJ);
        int hashCode = lowerCase.hashCode();
        if (hashCode != -1364013995) {
            if (hashCode != 3143043) {
                if (hashCode == 3317767 && lowerCase.equals("left")) {
                    C5156Qyn qyn = this.LIZIZ;
                    if (qyn == null) {
                        n.LIZ(Q39.LIZJ);
                    }
                    ViewGroup.LayoutParams layoutParams = qyn.getLayoutParams();
                    if (layoutParams != null) {
                        layoutParams.width = -1;
                    }
                    C5156Qyn qyn2 = this.LIZIZ;
                    if (qyn2 == null) {
                        n.LIZ(Q39.LIZJ);
                    }
                    qyn2.requestLayout();
                }
            } else if (lowerCase.equals("fill")) {
                C5156Qyn qyn3 = this.LIZIZ;
                if (qyn3 == null) {
                    n.LIZ(Q39.LIZJ);
                }
                qyn3.setTabMode(1);
                C5156Qyn qyn4 = this.LIZIZ;
                if (qyn4 == null) {
                    n.LIZ(Q39.LIZJ);
                }
                ViewGroup.LayoutParams layoutParams2 = qyn4.getLayoutParams();
                if (layoutParams2 != null) {
                    layoutParams2.width = -1;
                }
                C5156Qyn qyn5 = this.LIZIZ;
                if (qyn5 == null) {
                    n.LIZ(Q39.LIZJ);
                }
                qyn5.setTabGravity(0);
                C5156Qyn qyn6 = this.LIZIZ;
                if (qyn6 == null) {
                    n.LIZ(Q39.LIZJ);
                }
                qyn6.requestLayout();
            }
        } else if (lowerCase.equals("center")) {
            C5156Qyn qyn7 = this.LIZIZ;
            if (qyn7 == null) {
                n.LIZ(Q39.LIZJ);
            }
            qyn7.setTabGravity(1);
            C5156Qyn qyn8 = this.LIZIZ;
            if (qyn8 == null) {
                n.LIZ(Q39.LIZJ);
            }
            ViewGroup.LayoutParams layoutParams3 = qyn8.getLayoutParams();
            if (layoutParams3 != null) {
                layoutParams3.width = -1;
            }
            try {
                C5156Qyn qyn9 = this.LIZIZ;
                if (qyn9 == null) {
                    n.LIZ(Q39.LIZJ);
                }
                Class<?> cls = qyn9.getClass();
                if (!(cls == null || (declaredField = cls.getDeclaredField("slidingTabIndicator")) == null)) {
                    declaredField.setAccessible(true);
                    C5156Qyn qyn10 = this.LIZIZ;
                    if (qyn10 == null) {
                        n.LIZ(Q39.LIZJ);
                    }
                    Object obj = declaredField.get(qyn10);
                    if (obj != null) {
                        LinearLayout linearLayout = (LinearLayout) obj;
                        linearLayout.setGravity(17);
                        linearLayout.getLayoutParams().width = -2;
                        2te.constructor-impl(2Pr.LIZ);
                        C5156Qyn qyn11 = this.LIZIZ;
                        if (qyn11 == null) {
                            n.LIZ(Q39.LIZJ);
                        }
                        qyn11.requestLayout();
                        return;
                    }
                }
                throw new 7xU("null cannot be cast to non-null type android.widget.LinearLayout");
            } catch (Throwable th) {
                2te.constructor-impl(2th.LIZ(th));
            }
        }
    }

    public void insertChild(LynxBaseUI lynxBaseUI, int i) {
        int i2;
        if ((lynxBaseUI instanceof LynxUI) && (lynxBaseUI instanceof LynxTabbarItem)) {
            LynxTabbarItem lynxTabbarItem = (LynxTabbarItem) lynxBaseUI;
            lynxTabbarItem.setParent(this);
            this.mChildren.add(i, lynxBaseUI);
            C3308QOb qOb = new C3308QOb(this.mContext);
            qOb.setOverflow(lynxTabbarItem.getOverflow());
            qOb.addView(((LynxUI) lynxBaseUI).mView);
            lynxTabbarItem.LIZJ = qOb;
            this.LJIIIIZZ.add(i, qOb);
            if (lynxTabbarItem.getProps().containsKey("tag")) {
                this.LJ.put(Integer.valueOf(i), String.valueOf(lynxTabbarItem.getProps().get("tag")));
            }
            if (lynxTabbarItem.LIZLLL) {
                i2 = i;
            } else {
                i2 = 0;
            }
            LIZ(i, i2);
            C5156Qyn qyn = this.LIZIZ;
            if (qyn == null) {
                n.LIZ(Q39.LIZJ);
            }
            M12.LIZ(qyn);
            lynxTabbarItem.LIZ = Integer.valueOf(i);
            lynxTabbarItem.LJ = qyn;
        }
    }

    @7tl
    public final void selectTab(ReadableMap readableMap, Callback callback) {
        M12.LIZ(readableMap);
        JavaOnlyMap javaOnlyMap = new JavaOnlyMap();
        javaOnlyMap.put("success", false);
        if (readableMap.hasKey("index")) {
            int i = readableMap.getInt("index");
            if (i >= 0) {
                C5156Qyn qyn = this.LIZIZ;
                if (qyn == null) {
                    n.LIZ(Q39.LIZJ);
                }
                if (i < qyn.getTabCount()) {
                    C5156Qyn qyn2 = this.LIZIZ;
                    if (qyn2 == null) {
                        n.LIZ(Q39.LIZJ);
                    }
                    C5159Qyq tabAt = qyn2.getTabAt(i);
                    if (tabAt != null) {
                        tabAt.LIZ();
                    }
                    javaOnlyMap.put("success", true);
                    if (callback != null) {
                        callback.invoke(new Object[]{0, javaOnlyMap});
                        return;
                    }
                    return;
                }
            }
            javaOnlyMap.put("msg", "index out of bounds");
            if (callback != null) {
                callback.invoke(new Object[]{0, javaOnlyMap});
                return;
            }
            return;
        }
        javaOnlyMap.put("msg", "no index key");
        if (callback != null) {
            callback.invoke(new Object[]{0, javaOnlyMap});
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:32:0x008b, code lost:
        if (r2 == null) goto L_0x008d;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:37:0x0098, code lost:
        if (r0 == null) goto L_0x009a;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void LIZ(int r9, int r10) {
        /*
            r8 = this;
            java.util.List<com.lynx.tasm.behavior.ui.LynxBaseUI> r0 = r8.mChildren
            int r5 = r0.size()
        L_0x0006:
            if (r9 >= r5) goto L_0x00dd
            java.util.List<com.lynx.tasm.behavior.ui.LynxBaseUI> r0 = r8.mChildren
            java.lang.Object r2 = r0.get(r9)
            com.lynx.tasm.behavior.ui.LynxBaseUI r2 = (com.lynx.tasm.behavior.ui.LynxBaseUI) r2
            X.2sG r4 = new X.2sG
            r4.<init>()
            X.Qyn r0 = r8.LIZIZ
            java.lang.String r7 = ""
            if (r0 != 0) goto L_0x001e
            kotlin.h.b.n.LIZ(r7)
        L_0x001e:
            X.Qyq r0 = r0.getTabAt(r9)
            r4.element = r0
            java.lang.Object r0 = r4.element
            if (r0 != 0) goto L_0x003f
            X.Qyn r0 = r8.LIZIZ
            if (r0 != 0) goto L_0x002f
            kotlin.h.b.n.LIZ(r7)
        L_0x002f:
            X.Qyq r1 = r0.newTab()
            X.Qyn r0 = r8.LIZIZ
            if (r0 != 0) goto L_0x003a
            kotlin.h.b.n.LIZ(r7)
        L_0x003a:
            r0.addTab(r1)
            r4.element = r1
        L_0x003f:
            boolean r0 = r2 instanceof com.bytedance.ies.xelement.viewpager.childitem.LynxTabbarItem
            if (r0 == 0) goto L_0x004b
            com.bytedance.ies.xelement.viewpager.childitem.LynxTabbarItem r2 = (com.bytedance.ies.xelement.viewpager.childitem.LynxTabbarItem) r2
            java.lang.Object r0 = r4.element
            X.Qyq r0 = (X.C5159Qyq) r0
            r2.LIZIZ = r0
        L_0x004b:
            if (r10 != r9) goto L_0x0056
            java.lang.Object r0 = r4.element
            X.Qyq r0 = (X.C5159Qyq) r0
            if (r0 == 0) goto L_0x0056
            r0.LIZ()
        L_0x0056:
            java.lang.Object r1 = r4.element
            X.Qyq r1 = (X.C5159Qyq) r1
            if (r1 == 0) goto L_0x0067
            java.util.ArrayList<X.QOb> r0 = r8.LJIIIIZZ
            java.lang.Object r0 = r0.get(r9)
            android.view.View r0 = (android.view.View) r0
            r1.LIZ((android.view.View) r0)
        L_0x0067:
            java.lang.Object r0 = r4.element
            X.Qyq r0 = (X.C5159Qyq) r0
            r6 = 0
            if (r0 == 0) goto L_0x0076
            X.Qyo r1 = r0.LJII
            if (r1 == 0) goto L_0x0076
            r0 = 0
            r1.setBackgroundColor(r0)
        L_0x0076:
            X.QyT r2 = X.C5136QyT.LIZ
            X.QmZ r1 = r8.mContext
            kotlin.h.b.n.LIZ(r1, r7)
            float r0 = r8.LJI
            int r3 = r2.LIZ(r1, r0)
            java.lang.Object r0 = r4.element
            X.Qyq r0 = (X.C5159Qyq) r0
            if (r0 == 0) goto L_0x00d3
            android.view.View r2 = r0.LJFF
            if (r2 != 0) goto L_0x0090
        L_0x008d:
            kotlin.h.b.n.LIZ()
        L_0x0090:
            java.lang.Object r0 = r4.element
            X.Qyq r0 = (X.C5159Qyq) r0
            if (r0 == 0) goto L_0x00d1
            android.view.View r0 = r0.LJFF
            if (r0 != 0) goto L_0x009d
        L_0x009a:
            kotlin.h.b.n.LIZ()
        L_0x009d:
            kotlin.h.b.n.LIZ(r0, r7)
            int r1 = r0.getPaddingTop()
            java.lang.Object r0 = r4.element
            X.Qyq r0 = (X.C5159Qyq) r0
            if (r0 == 0) goto L_0x00ae
            android.view.View r6 = r0.LJFF
            if (r6 != 0) goto L_0x00b1
        L_0x00ae:
            kotlin.h.b.n.LIZ()
        L_0x00b1:
            kotlin.h.b.n.LIZ(r6, r7)
            int r0 = r6.getPaddingBottom()
            androidx.core.g.t.LIZ(r2, r3, r1, r3, r0)
            java.lang.Object r0 = r4.element
            X.Qyq r0 = (X.C5159Qyq) r0
            if (r0 == 0) goto L_0x00d5
            X.Qyo r1 = r0.LJII
            if (r1 == 0) goto L_0x00d5
            X.QyV r0 = new X.QyV
            r0.<init>(r8, r4)
            r1.setOnClickListener(r0)
            int r9 = r9 + 1
            goto L_0x0006
        L_0x00d1:
            r0 = r6
            goto L_0x009a
        L_0x00d3:
            r2 = r6
            goto L_0x008d
        L_0x00d5:
            X.7xU r1 = new X.7xU
            java.lang.String r0 = "null cannot be cast to non-null type android.view.View"
            r1.<init>(r0)
            throw r1
        L_0x00dd:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.bytedance.ies.xelement.viewpager.LynxTabBarView.LIZ(int, int):void");
    }
}
