抖阴.apk(点击下载) / SlidingTabLayout.java


package com.flyco.tablayout;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.flyco.tablayout.widget.MsgView;
import com.slzhibo.library.utils.picker.ImageSet;
import java.util.ArrayList;
import java.util.Collections;

public class SlidingTabLayout extends HorizontalScrollView implements ViewPager.OnPageChangeListener {
    private static final int t1 = 0;
    private static final int u1 = 1;
    private static final int v1 = 2;
    private static final int w1 = 0;
    private static final int x1 = 1;
    private static final int y1 = 2;
    private ArrayList<String> B0;
    private LinearLayout C0;
    private int D0;
    private float E0;
    private int F0;
    private Rect G0;
    private Rect H0;
    private GradientDrawable I0;
    private Paint J0;
    private Paint K0;
    private Paint L0;
    private Path M0;
    private int N0;
    private float O0;
    private boolean P0;
    private float Q0;
    private int R0;
    private float S0;
    private float T0;
    private float U0;
    private float V0;
    private float W0;
    private float X0;
    private float Y0;
    private int Z0;
    private boolean a1;
    private int b1;
    private float c1;
    private int d1;
    private int e1;
    private float f1;
    private float g1;
    private float h1;
    private int i1;
    private int j1;
    private int k1;
    private boolean l1;
    private int m1;
    private int n1;
    private boolean o1;
    private float p1;
    private Paint q1;
    private SparseArray<Boolean> r1;
    private com.flyco.tablayout.b.b s1;
    private Context t;
    private ViewPager u;

    /* access modifiers changed from: package-private */
    public class a implements View.OnClickListener {
        a() {
        }

        public void onClick(View view) {
            int indexOfChild = SlidingTabLayout.this.C0.indexOfChild(view);
            if (indexOfChild == -1) {
                return;
            }
            if (SlidingTabLayout.this.u.getCurrentItem() != indexOfChild) {
                if (SlidingTabLayout.this.o1) {
                    SlidingTabLayout.this.u.setCurrentItem(indexOfChild, false);
                } else {
                    SlidingTabLayout.this.u.setCurrentItem(indexOfChild);
                }
                if (SlidingTabLayout.this.s1 != null) {
                    SlidingTabLayout.this.s1.b(indexOfChild);
                }
            } else if (SlidingTabLayout.this.s1 != null) {
                SlidingTabLayout.this.s1.a(indexOfChild);
            }
        }
    }

    class b extends FragmentStatePagerAdapter {
        private ArrayList<Fragment> a = new ArrayList<>();

        /* renamed from: b  reason: collision with root package name */
        private String[] f1029b;

        public b(FragmentManager fragmentManager, ArrayList<Fragment> arrayList, String[] strArr) {
            super(fragmentManager);
            this.a = arrayList;
            this.f1029b = strArr;
        }

        @Override // androidx.viewpager.widget.PagerAdapter, androidx.fragment.app.FragmentStatePagerAdapter
        public void destroyItem(ViewGroup viewGroup, int i, Object obj) {
        }

        @Override // androidx.viewpager.widget.PagerAdapter
        public int getCount() {
            return this.a.size();
        }

        @Override // androidx.fragment.app.FragmentStatePagerAdapter
        public Fragment getItem(int i) {
            return this.a.get(i);
        }

        @Override // androidx.viewpager.widget.PagerAdapter
        public int getItemPosition(Object obj) {
            return -2;
        }

        @Override // androidx.viewpager.widget.PagerAdapter
        public CharSequence getPageTitle(int i) {
            return this.f1029b[i];
        }
    }

    public SlidingTabLayout(Context context) {
        this(context, null, 0);
    }

    private void e() {
        if (this.F0 > 0) {
            int width = (int) (this.E0 * ((float) this.C0.getChildAt(this.D0).getWidth()));
            int left = this.C0.getChildAt(this.D0).getLeft() + width;
            if (this.D0 > 0 || width > 0) {
                int width2 = left - ((getWidth() / 2) - getPaddingLeft());
                d();
                Rect rect = this.H0;
                left = width2 + ((rect.right - rect.left) / 2);
            }
            if (left != this.m1) {
                this.m1 = left;
                scrollTo(left, 0);
            }
        }
    }

    private void f() {
        int i = 0;
        while (i < this.F0) {
            TextView textView = (TextView) this.C0.getChildAt(i).findViewById(R.id.tv_tab_title);
            if (textView != null) {
                textView.setTextColor(i == this.D0 ? this.i1 : this.j1);
                textView.setTextSize(0, this.h1);
                float f2 = this.O0;
                textView.setPadding((int) f2, 0, (int) f2, 0);
                if (this.l1) {
                    textView.setText(textView.getText().toString().toUpperCase());
                }
                int i2 = this.k1;
                if (i2 == 2) {
                    textView.getPaint().setFakeBoldText(true);
                } else if (i2 == 0) {
                    textView.getPaint().setFakeBoldText(false);
                }
            }
            i++;
        }
    }

    public int getCurrentTab() {
        return this.D0;
    }

    public int getDividerColor() {
        return this.e1;
    }

    public float getDividerPadding() {
        return this.g1;
    }

    public float getDividerWidth() {
        return this.f1;
    }

    public int getIndicatorColor() {
        return this.R0;
    }

    public float getIndicatorCornerRadius() {
        return this.U0;
    }

    public float getIndicatorHeight() {
        return this.S0;
    }

    public float getIndicatorMarginBottom() {
        return this.Y0;
    }

    public float getIndicatorMarginLeft() {
        return this.V0;
    }

    public float getIndicatorMarginRight() {
        return this.X0;
    }

    public float getIndicatorMarginTop() {
        return this.W0;
    }

    public int getIndicatorStyle() {
        return this.N0;
    }

    public float getIndicatorWidth() {
        return this.T0;
    }

    public int getTabCount() {
        return this.F0;
    }

    public float getTabPadding() {
        return this.O0;
    }

    public float getTabWidth() {
        return this.Q0;
    }

    public int getTextBold() {
        return this.k1;
    }

    public int getTextSelectColor() {
        return this.i1;
    }

    public int getTextUnselectColor() {
        return this.j1;
    }

    public float getTextsize() {
        return this.h1;
    }

    public int getUnderlineColor() {
        return this.b1;
    }

    public float getUnderlineHeight() {
        return this.c1;
    }

    /* access modifiers changed from: protected */
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (!isInEditMode() && this.F0 > 0) {
            int height = getHeight();
            int paddingLeft = getPaddingLeft();
            float f2 = this.f1;
            if (f2 > 0.0f) {
                this.K0.setStrokeWidth(f2);
                this.K0.setColor(this.e1);
                for (int i = 0; i < this.F0 - 1; i++) {
                    View childAt = this.C0.getChildAt(i);
                    canvas.drawLine((float) (childAt.getRight() + paddingLeft), this.g1, (float) (childAt.getRight() + paddingLeft), ((float) height) - this.g1, this.K0);
                }
            }
            if (this.c1 > 0.0f) {
                this.J0.setColor(this.b1);
                if (this.d1 == 80) {
                    float f3 = (float) height;
                    canvas.drawRect((float) paddingLeft, f3 - this.c1, (float) (this.C0.getWidth() + paddingLeft), f3, this.J0);
                } else {
                    canvas.drawRect((float) paddingLeft, 0.0f, (float) (this.C0.getWidth() + paddingLeft), this.c1, this.J0);
                }
            }
            d();
            int i2 = this.N0;
            if (i2 == 1) {
                if (this.S0 > 0.0f) {
                    this.L0.setColor(this.R0);
                    this.M0.reset();
                    float f4 = (float) height;
                    this.M0.moveTo((float) (this.G0.left + paddingLeft), f4);
                    Path path = this.M0;
                    Rect rect = this.G0;
                    path.lineTo((float) ((rect.left / 2) + paddingLeft + (rect.right / 2)), f4 - this.S0);
                    this.M0.lineTo((float) (paddingLeft + this.G0.right), f4);
                    this.M0.close();
                    canvas.drawPath(this.M0, this.L0);
                }
            } else if (i2 == 2) {
                if (this.S0 < 0.0f) {
                    this.S0 = (((float) height) - this.W0) - this.Y0;
                }
                float f5 = this.S0;
                if (f5 > 0.0f) {
                    float f6 = this.U0;
                    if (f6 < 0.0f || f6 > f5 / 2.0f) {
                        this.U0 = this.S0 / 2.0f;
                    }
                    this.I0.setColor(this.R0);
                    GradientDrawable gradientDrawable = this.I0;
                    Rect rect2 = this.G0;
                    int i3 = ((int) this.V0) + paddingLeft + rect2.left;
                    float f7 = this.W0;
                    gradientDrawable.setBounds(i3, (int) f7, (int) (((float) (paddingLeft + rect2.right)) - this.X0), (int) (f7 + this.S0));
                    this.I0.setCornerRadius(this.U0);
                    this.I0.draw(canvas);
                }
            } else if (this.S0 > 0.0f) {
                this.I0.setColor(this.R0);
                if (this.Z0 == 80) {
                    GradientDrawable gradientDrawable2 = this.I0;
                    Rect rect3 = this.G0;
                    float f8 = this.Y0;
                    gradientDrawable2.setBounds(((int) this.V0) + paddingLeft + rect3.left, (height - ((int) this.S0)) - ((int) f8), (paddingLeft + rect3.right) - ((int) this.X0), height - ((int) f8));
                } else {
                    GradientDrawable gradientDrawable3 = this.I0;
                    Rect rect4 = this.G0;
                    int i4 = ((int) this.V0) + paddingLeft + rect4.left;
                    float f9 = this.W0;
                    gradientDrawable3.setBounds(i4, (int) f9, (paddingLeft + rect4.right) - ((int) this.X0), ((int) this.S0) + ((int) f9));
                }
                this.I0.setCornerRadius(this.U0);
                this.I0.draw(canvas);
            }
        }
    }

    @Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
    public void onPageScrollStateChanged(int i) {
    }

    @Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
    public void onPageScrolled(int i, float f2, int i2) {
        this.D0 = i;
        this.E0 = f2;
        e();
        invalidate();
    }

    @Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
    public void onPageSelected(int i) {
        e(i);
    }

    /* access modifiers changed from: protected */
    public void onRestoreInstanceState(Parcelable parcelable) {
        if (parcelable instanceof Bundle) {
            Bundle bundle = (Bundle) parcelable;
            this.D0 = bundle.getInt("mCurrentTab");
            parcelable = bundle.getParcelable("instanceState");
            if (this.D0 != 0 && this.C0.getChildCount() > 0) {
                e(this.D0);
                e();
            }
        }
        super.onRestoreInstanceState(parcelable);
    }

    /* access modifiers changed from: protected */
    public Parcelable onSaveInstanceState() {
        Bundle bundle = new Bundle();
        bundle.putParcelable("instanceState", super.onSaveInstanceState());
        bundle.putInt("mCurrentTab", this.D0);
        return bundle;
    }

    public void setCurrentTab(int i) {
        this.D0 = i;
        this.u.setCurrentItem(i);
    }

    public void setDividerColor(int i) {
        this.e1 = i;
        invalidate();
    }

    public void setDividerPadding(float f2) {
        this.g1 = (float) a(f2);
        invalidate();
    }

    public void setDividerWidth(float f2) {
        this.f1 = (float) a(f2);
        invalidate();
    }

    public void setIndicatorColor(int i) {
        this.R0 = i;
        invalidate();
    }

    public void setIndicatorCornerRadius(float f2) {
        this.U0 = (float) a(f2);
        invalidate();
    }

    public void setIndicatorGravity(int i) {
        this.Z0 = i;
        invalidate();
    }

    public void setIndicatorHeight(float f2) {
        this.S0 = (float) a(f2);
        invalidate();
    }

    public void setIndicatorMargin(float f2, float f3, float f4, float f5) {
        this.V0 = (float) a(f2);
        this.W0 = (float) a(f3);
        this.X0 = (float) a(f4);
        this.Y0 = (float) a(f5);
        invalidate();
    }

    public void setIndicatorStyle(int i) {
        this.N0 = i;
        invalidate();
    }

    public void setIndicatorWidth(float f2) {
        this.T0 = (float) a(f2);
        invalidate();
    }

    public void setIndicatorWidthEqualTitle(boolean z) {
        this.a1 = z;
        invalidate();
    }

    public void setMsgMargin(int i, float f2, float f3) {
        float f4;
        int i2 = this.F0;
        if (i >= i2) {
            i = i2 - 1;
        }
        View childAt = this.C0.getChildAt(i);
        MsgView msgView = (MsgView) childAt.findViewById(R.id.rtv_msg_tip);
        if (msgView != null) {
            this.q1.setTextSize(this.h1);
            float measureText = this.q1.measureText(((TextView) childAt.findViewById(R.id.tv_tab_title)).getText().toString());
            float descent = this.q1.descent() - this.q1.ascent();
            ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) msgView.getLayoutParams();
            float f5 = this.Q0;
            if (f5 >= 0.0f) {
                f4 = f5 / 2.0f;
                measureText /= 2.0f;
            } else {
                f4 = this.O0;
            }
            marginLayoutParams.leftMargin = (int) (f4 + measureText + ((float) a(f2)));
            int i3 = this.n1;
            marginLayoutParams.topMargin = i3 > 0 ? (((int) (((float) i3) - descent)) / 2) - a(f3) : 0;
            msgView.setLayoutParams(marginLayoutParams);
        }
    }

    public void setOnTabSelectListener(com.flyco.tablayout.b.b bVar) {
        this.s1 = bVar;
    }

    public void setSnapOnTabClick(boolean z) {
        this.o1 = z;
    }

    public void setTabPadding(float f2) {
        this.O0 = (float) a(f2);
        f();
    }

    public void setTabSpaceEqual(boolean z) {
        this.P0 = z;
        f();
    }

    public void setTabWidth(float f2) {
        this.Q0 = (float) a(f2);
        f();
    }

    public void setTextAllCaps(boolean z) {
        this.l1 = z;
        f();
    }

    public void setTextBold(int i) {
        this.k1 = i;
        f();
    }

    public void setTextSelectColor(int i) {
        this.i1 = i;
        f();
    }

    public void setTextUnselectColor(int i) {
        this.j1 = i;
        f();
    }

    public void setTextsize(float f2) {
        this.h1 = (float) b(f2);
        f();
    }

    public void setUnderlineColor(int i) {
        this.b1 = i;
        invalidate();
    }

    public void setUnderlineGravity(int i) {
        this.d1 = i;
        invalidate();
    }

    public void setUnderlineHeight(float f2) {
        this.c1 = (float) a(f2);
        invalidate();
    }

    public void setViewPager(ViewPager viewPager) {
        if (viewPager == null || viewPager.getAdapter() == null) {
            throw new IllegalStateException("ViewPager or ViewPager adapter can not be NULL !");
        }
        this.u = viewPager;
        this.u.removeOnPageChangeListener(this);
        this.u.addOnPageChangeListener(this);
        c();
    }

    public SlidingTabLayout(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    private void a(Context context, AttributeSet attributeSet) {
        float f2;
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.SlidingTabLayout);
        this.N0 = obtainStyledAttributes.getInt(R.styleable.SlidingTabLayout_tl_indicator_style, 0);
        this.R0 = obtainStyledAttributes.getColor(R.styleable.SlidingTabLayout_tl_indicator_color, Color.parseColor(this.N0 == 2 ? "#4B6A87" : "#ffffff"));
        int i = R.styleable.SlidingTabLayout_tl_indicator_height;
        int i2 = this.N0;
        if (i2 == 1) {
            f2 = 4.0f;
        } else {
            f2 = (float) (i2 == 2 ? -1 : 2);
        }
        this.S0 = obtainStyledAttributes.getDimension(i, (float) a(f2));
        this.T0 = obtainStyledAttributes.getDimension(R.styleable.SlidingTabLayout_tl_indicator_width, (float) a(this.N0 == 1 ? 10.0f : -1.0f));
        this.U0 = obtainStyledAttributes.getDimension(R.styleable.SlidingTabLayout_tl_indicator_corner_radius, (float) a(this.N0 == 2 ? -1.0f : 0.0f));
        this.V0 = obtainStyledAttributes.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_left, (float) a(0.0f));
        float f3 = 7.0f;
        this.W0 = obtainStyledAttributes.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_top, (float) a(this.N0 == 2 ? 7.0f : 0.0f));
        this.X0 = obtainStyledAttributes.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_right, (float) a(0.0f));
        int i3 = R.styleable.SlidingTabLayout_tl_indicator_margin_bottom;
        if (this.N0 != 2) {
            f3 = 0.0f;
        }
        this.Y0 = obtainStyledAttributes.getDimension(i3, (float) a(f3));
        this.Z0 = obtainStyledAttributes.getInt(R.styleable.SlidingTabLayout_tl_indicator_gravity, 80);
        this.a1 = obtainStyledAttributes.getBoolean(R.styleable.SlidingTabLayout_tl_indicator_width_equal_title, false);
        this.b1 = obtainStyledAttributes.getColor(R.styleable.SlidingTabLayout_tl_underline_color, Color.parseColor("#ffffff"));
        this.c1 = obtainStyledAttributes.getDimension(R.styleable.SlidingTabLayout_tl_underline_height, (float) a(0.0f));
        this.d1 = obtainStyledAttributes.getInt(R.styleable.SlidingTabLayout_tl_underline_gravity, 80);
        this.e1 = obtainStyledAttributes.getColor(R.styleable.SlidingTabLayout_tl_divider_color, Color.parseColor("#ffffff"));
        this.f1 = obtainStyledAttributes.getDimension(R.styleable.SlidingTabLayout_tl_divider_width, (float) a(0.0f));
        this.g1 = obtainStyledAttributes.getDimension(R.styleable.SlidingTabLayout_tl_divider_padding, (float) a(12.0f));
        this.h1 = obtainStyledAttributes.getDimension(R.styleable.SlidingTabLayout_tl_textsize, (float) b(14.0f));
        this.i1 = obtainStyledAttributes.getColor(R.styleable.SlidingTabLayout_tl_textSelectColor, Color.parseColor("#ffffff"));
        this.j1 = obtainStyledAttributes.getColor(R.styleable.SlidingTabLayout_tl_textUnselectColor, Color.parseColor("#AAffffff"));
        this.k1 = obtainStyledAttributes.getInt(R.styleable.SlidingTabLayout_tl_textBold, 0);
        this.l1 = obtainStyledAttributes.getBoolean(R.styleable.SlidingTabLayout_tl_textAllCaps, false);
        this.P0 = obtainStyledAttributes.getBoolean(R.styleable.SlidingTabLayout_tl_tab_space_equal, false);
        this.Q0 = obtainStyledAttributes.getDimension(R.styleable.SlidingTabLayout_tl_tab_width, (float) a(-1.0f));
        this.O0 = obtainStyledAttributes.getDimension(R.styleable.SlidingTabLayout_tl_tab_padding, (float) ((this.P0 || this.Q0 > 0.0f) ? a(0.0f) : a(20.0f)));
        obtainStyledAttributes.recycle();
    }

    private void d() {
        View childAt = this.C0.getChildAt(this.D0);
        float left = (float) childAt.getLeft();
        float right = (float) childAt.getRight();
        if (this.N0 == 0 && this.a1) {
            this.q1.setTextSize(this.h1);
            this.p1 = ((right - left) - this.q1.measureText(((TextView) childAt.findViewById(R.id.tv_tab_title)).getText().toString())) / 2.0f;
        }
        int i = this.D0;
        if (i < this.F0 - 1) {
            View childAt2 = this.C0.getChildAt(i + 1);
            float left2 = (float) childAt2.getLeft();
            float right2 = (float) childAt2.getRight();
            float f2 = this.E0;
            left += (left2 - left) * f2;
            right += f2 * (right2 - right);
            if (this.N0 == 0 && this.a1) {
                this.q1.setTextSize(this.h1);
                float f3 = this.p1;
                this.p1 = f3 + (this.E0 * ((((right2 - left2) - this.q1.measureText(((TextView) childAt2.findViewById(R.id.tv_tab_title)).getText().toString())) / 2.0f) - f3));
            }
        }
        Rect rect = this.G0;
        int i2 = (int) left;
        rect.left = i2;
        int i3 = (int) right;
        rect.right = i3;
        if (this.N0 == 0 && this.a1) {
            float f4 = this.p1;
            rect.left = (int) ((left + f4) - 1.0f);
            rect.right = (int) ((right - f4) - 1.0f);
        }
        Rect rect2 = this.H0;
        rect2.left = i2;
        rect2.right = i3;
        if (this.T0 >= 0.0f) {
            float left3 = ((float) childAt.getLeft()) + ((((float) childAt.getWidth()) - this.T0) / 2.0f);
            int i4 = this.D0;
            if (i4 < this.F0 - 1) {
                left3 += this.E0 * ((float) ((childAt.getWidth() / 2) + (this.C0.getChildAt(i4 + 1).getWidth() / 2)));
            }
            Rect rect3 = this.G0;
            rect3.left = (int) left3;
            rect3.right = (int) (((float) rect3.left) + this.T0);
        }
    }

    public boolean b() {
        return this.l1;
    }

    public void c() {
        this.C0.removeAllViews();
        ArrayList<String> arrayList = this.B0;
        this.F0 = arrayList == null ? this.u.getAdapter().getCount() : arrayList.size();
        for (int i = 0; i < this.F0; i++) {
            View inflate = View.inflate(this.t, R.layout.layout_tab, null);
            ArrayList<String> arrayList2 = this.B0;
            a(i, (arrayList2 == null ? this.u.getAdapter().getPageTitle(i) : arrayList2.get(i)).toString(), inflate);
        }
        f();
    }

    public SlidingTabLayout(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.G0 = new Rect();
        this.H0 = new Rect();
        this.I0 = new GradientDrawable();
        this.J0 = new Paint(1);
        this.K0 = new Paint(1);
        this.L0 = new Paint(1);
        this.M0 = new Path();
        this.N0 = 0;
        this.q1 = new Paint(1);
        this.r1 = new SparseArray<>();
        setFillViewport(true);
        setWillNotDraw(false);
        setClipChildren(false);
        setClipToPadding(false);
        this.t = context;
        this.C0 = new LinearLayout(context);
        addView(this.C0);
        a(context, attributeSet);
        String attributeValue = attributeSet.getAttributeValue("http://schemas.android.com/apk/res/android", "layout_height");
        if (!attributeValue.equals(ImageSet.ID_ALL_MEDIA) && !attributeValue.equals("-2")) {
            TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, new int[]{16842997});
            this.n1 = obtainStyledAttributes.getDimensionPixelSize(0, -2);
            obtainStyledAttributes.recycle();
        }
    }

    public TextView b(int i) {
        return (TextView) this.C0.getChildAt(i).findViewById(R.id.tv_tab_title);
    }

    public void setCurrentTab(int i, boolean z) {
        this.D0 = i;
        this.u.setCurrentItem(i, z);
    }

    /* access modifiers changed from: protected */
    public int b(float f2) {
        return (int) ((f2 * this.t.getResources().getDisplayMetrics().scaledDensity) + 0.5f);
    }

    public void setViewPager(ViewPager viewPager, String[] strArr) {
        if (viewPager == null || viewPager.getAdapter() == null) {
            throw new IllegalStateException("ViewPager or ViewPager adapter can not be NULL !");
        } else if (strArr == null || strArr.length == 0) {
            throw new IllegalStateException("Titles can not be EMPTY !");
        } else if (strArr.length == viewPager.getAdapter().getCount()) {
            this.u = viewPager;
            this.B0 = new ArrayList<>();
            Collections.addAll(this.B0, strArr);
            this.u.removeOnPageChangeListener(this);
            this.u.addOnPageChangeListener(this);
            c();
        } else {
            throw new IllegalStateException("Titles length must be the same as the page count !");
        }
    }

    public void c(int i) {
        int i2 = this.F0;
        if (i >= i2) {
            i = i2 - 1;
        }
        MsgView msgView = (MsgView) this.C0.getChildAt(i).findViewById(R.id.rtv_msg_tip);
        if (msgView != null) {
            msgView.setVisibility(8);
        }
    }

    private void e(int i) {
        int i2 = 0;
        while (i2 < this.F0) {
            View childAt = this.C0.getChildAt(i2);
            boolean z = i2 == i;
            TextView textView = (TextView) childAt.findViewById(R.id.tv_tab_title);
            if (textView != null) {
                textView.setTextColor(z ? this.i1 : this.j1);
                if (this.k1 == 1) {
                    textView.getPaint().setFakeBoldText(z);
                }
            }
            i2++;
        }
    }

    public void setViewPager(ViewPager viewPager, String[] strArr, FragmentActivity fragmentActivity, ArrayList<Fragment> arrayList) {
        if (viewPager == null) {
            throw new IllegalStateException("ViewPager can not be NULL !");
        } else if (strArr == null || strArr.length == 0) {
            throw new IllegalStateException("Titles can not be EMPTY !");
        } else {
            this.u = viewPager;
            this.u.setAdapter(new b(fragmentActivity.getSupportFragmentManager(), arrayList, strArr));
            this.u.removeOnPageChangeListener(this);
            this.u.addOnPageChangeListener(this);
            c();
        }
    }

    public void a(String str) {
        View inflate = View.inflate(this.t, R.layout.layout_tab, null);
        ArrayList<String> arrayList = this.B0;
        if (arrayList != null) {
            arrayList.add(str);
        }
        ArrayList<String> arrayList2 = this.B0;
        a(this.F0, (arrayList2 == null ? this.u.getAdapter().getPageTitle(this.F0) : arrayList2.get(this.F0)).toString(), inflate);
        ArrayList<String> arrayList3 = this.B0;
        this.F0 = arrayList3 == null ? this.u.getAdapter().getCount() : arrayList3.size();
        f();
    }

    public void d(int i) {
        int i2 = this.F0;
        if (i >= i2) {
            i = i2 - 1;
        }
        a(i, 0);
    }

    private void a(int i, String str, View view) {
        TextView textView = (TextView) view.findViewById(R.id.tv_tab_title);
        if (!(textView == null || str == null)) {
            textView.setText(str);
        }
        view.setOnClickListener(new a());
        LinearLayout.LayoutParams layoutParams = this.P0 ? new LinearLayout.LayoutParams(0, -1, 1.0f) : new LinearLayout.LayoutParams(-2, -1);
        float f2 = this.Q0;
        if (f2 > 0.0f) {
            layoutParams = new LinearLayout.LayoutParams((int) f2, -1);
        }
        this.C0.addView(view, i, layoutParams);
    }

    public boolean a() {
        return this.P0;
    }

    public void a(int i, int i2) {
        int i3 = this.F0;
        if (i >= i3) {
            i = i3 - 1;
        }
        MsgView msgView = (MsgView) this.C0.getChildAt(i).findViewById(R.id.rtv_msg_tip);
        if (msgView != null) {
            com.flyco.tablayout.c.b.b(msgView, i2);
            if (this.r1.get(i) == null || !this.r1.get(i).booleanValue()) {
                setMsgMargin(i, 4.0f, 2.0f);
                this.r1.put(i, true);
            }
        }
    }

    public MsgView a(int i) {
        int i2 = this.F0;
        if (i >= i2) {
            i = i2 - 1;
        }
        return (MsgView) this.C0.getChildAt(i).findViewById(R.id.rtv_msg_tip);
    }

    /* access modifiers changed from: protected */
    public int a(float f2) {
        return (int) ((f2 * this.t.getResources().getDisplayMetrics().density) + 0.5f);
    }
}