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.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.animation.OvershootInterpolator; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.TextView; import com.flyco.tablayout.listener.OnTabSelectListener; import com.nineoldandroids.animation.TypeEvaluator; import com.nineoldandroids.animation.ValueAnimator; import com.sensorsdata.analytics.android.sdk.SensorsDataAutoTrackHelper; import com.sensorsdata.analytics.android.sdk.SensorsDataInstrumented; import com.shizhuang.duapp.R; import java.util.ArrayList; import o5.i; public class SegmentTabLayout extends FrameLayout implements ValueAnimator.AnimatorUpdateListener { public float A; public float B; public int C; public int D; public boolean E; public boolean F; public int G; public int H; public float I; public ValueAnimator J; public OvershootInterpolator K; public float[] L; public boolean M; public OnTabSelectListener N; public a O; public a P; public Context b; /* renamed from: c reason: collision with root package name */ public String[] f4351c; public LinearLayout d; public int e; public int f; /* renamed from: g reason: collision with root package name */ public int f4352g; /* renamed from: h reason: collision with root package name */ public Rect f4353h; public GradientDrawable i; public GradientDrawable j; public Paint k; public float l; public boolean m; public float n; public int o; public float p; /* renamed from: q reason: collision with root package name */ public float f4354q; public float r; public float s; public float t; /* renamed from: u reason: collision with root package name */ public float f4355u; /* renamed from: v reason: collision with root package name */ public long f4356v; public boolean w; public boolean x; public int y; public float z; public class a { /* renamed from: a reason: collision with root package name */ public float f4357a; public float b; public a(SegmentTabLayout segmentTabLayout) { } } public class b implements TypeEvaluator<a> { public b() { } /* Return type fixed from 'java.lang.Object' to match base method */ /* JADX DEBUG: Method arguments types fixed to match base method, original types: [float, java.lang.Object, java.lang.Object] */ @Override // com.nineoldandroids.animation.TypeEvaluator public a evaluate(float f, a aVar, a aVar2) { a aVar3 = aVar; a aVar4 = aVar2; float f12 = aVar3.f4357a; float b2 = a1.a.b(aVar4.f4357a, f12, f, f12); float f13 = aVar3.b; float b5 = a1.a.b(aVar4.b, f13, f, f13); a aVar5 = new a(SegmentTabLayout.this); aVar5.f4357a = b2; aVar5.b = b5; return aVar5; } } public SegmentTabLayout(Context context) { this(context, null, 0); } public final void a() { View childAt = this.d.getChildAt(this.e); Rect rect = this.f4353h; rect.left = (int) ((float) childAt.getLeft()); rect.right = (int) ((float) childAt.getRight()); if (!this.w) { int i3 = this.e; if (i3 == 0) { float[] fArr = this.L; float f12 = this.f4354q; fArr[0] = f12; fArr[1] = f12; fArr[2] = 0.0f; fArr[3] = 0.0f; fArr[4] = 0.0f; fArr[5] = 0.0f; fArr[6] = f12; fArr[7] = f12; } else if (i3 == this.f4352g - 1) { float[] fArr2 = this.L; fArr2[0] = 0.0f; fArr2[1] = 0.0f; float f13 = this.f4354q; fArr2[2] = f13; fArr2[3] = f13; fArr2[4] = f13; fArr2[5] = f13; fArr2[6] = 0.0f; fArr2[7] = 0.0f; } else { float[] fArr3 = this.L; fArr3[0] = 0.0f; fArr3[1] = 0.0f; fArr3[2] = 0.0f; fArr3[3] = 0.0f; fArr3[4] = 0.0f; fArr3[5] = 0.0f; fArr3[6] = 0.0f; fArr3[7] = 0.0f; } } else { float[] fArr4 = this.L; float f14 = this.f4354q; fArr4[0] = f14; fArr4[1] = f14; fArr4[2] = f14; fArr4[3] = f14; fArr4[4] = f14; fArr4[5] = f14; fArr4[6] = f14; fArr4[7] = f14; } } public int b(float f12) { return (int) ((f12 * this.b.getResources().getDisplayMetrics().density) + 0.5f); } public int c(float f12) { return (int) ((f12 * this.b.getResources().getDisplayMetrics().scaledDensity) + 0.5f); } public final void d(int i3) { int i12 = 0; while (i12 < this.f4352g) { ((TextView) this.d.getChildAt(i12).findViewById(R.id.tv_tab_title)).setTextColor(i12 == i3 ? this.C : this.D); i12++; } } public final void e() { int i3 = 0; while (i3 < this.f4352g) { View childAt = this.d.getChildAt(i3); float f12 = this.l; childAt.setPadding((int) f12, 0, (int) f12, 0); TextView textView = (TextView) childAt.findViewById(R.id.tv_tab_title); textView.setTextColor(i3 == this.e ? this.C : this.D); textView.setTextSize(0, this.B); if (this.F) { textView.setText(textView.getText().toString().toUpperCase()); } if (this.E) { textView.getPaint().setFakeBoldText(this.E); } i3++; } } public int getCurrentTab() { return this.e; } public int getDividerColor() { return this.y; } public float getDividerPadding() { return this.A; } public float getDividerWidth() { return this.z; } public long getIndicatorAnimDuration() { return this.f4356v; } public int getIndicatorColor() { return this.o; } public float getIndicatorCornerRadius() { return this.f4354q; } public float getIndicatorHeight() { return this.p; } public float getIndicatorMarginBottom() { return this.f4355u; } public float getIndicatorMarginLeft() { return this.r; } public float getIndicatorMarginRight() { return this.t; } public float getIndicatorMarginTop() { return this.s; } public int getTabCount() { return this.f4352g; } public float getTabPadding() { return this.l; } public float getTabWidth() { return this.n; } public int getTextSelectColor() { return this.C; } public int getTextUnselectColor() { return this.D; } public float getTextsize() { return this.B; } @Override // com.nineoldandroids.animation.ValueAnimator.AnimatorUpdateListener public void onAnimationUpdate(ValueAnimator valueAnimator) { a aVar = (a) valueAnimator.m(); Rect rect = this.f4353h; rect.left = (int) aVar.f4357a; rect.right = (int) aVar.b; invalidate(); } public void onDraw(Canvas canvas) { super.onDraw(canvas); if (!isInEditMode() && this.f4352g > 0) { int height = getHeight(); int paddingLeft = getPaddingLeft(); if (this.p < i.f36333a) { this.p = (((float) height) - this.s) - this.f4355u; } float f12 = this.f4354q; if (f12 < i.f36333a || f12 > this.p / 2.0f) { this.f4354q = this.p / 2.0f; } this.j.setColor(this.G); this.j.setStroke((int) this.I, this.H); this.j.setCornerRadius(this.f4354q); this.j.setBounds(getPaddingLeft(), getPaddingTop(), getWidth() - getPaddingRight(), getHeight() - getPaddingBottom()); this.j.draw(canvas); if (!this.w) { float f13 = this.z; if (f13 > i.f36333a) { this.k.setStrokeWidth(f13); this.k.setColor(this.y); for (int i3 = 0; i3 < this.f4352g - 1; i3++) { View childAt = this.d.getChildAt(i3); canvas.drawLine((float) (childAt.getRight() + paddingLeft), this.A, (float) (childAt.getRight() + paddingLeft), ((float) height) - this.A, this.k); } } } if (!this.w) { a(); } else if (this.M) { this.M = false; a(); } this.i.setColor(this.o); GradientDrawable gradientDrawable = this.i; Rect rect = this.f4353h; int i12 = ((int) this.r) + paddingLeft + rect.left; float f14 = this.s; gradientDrawable.setBounds(i12, (int) f14, (int) (((float) (paddingLeft + rect.right)) - this.t), (int) (f14 + this.p)); this.i.setCornerRadii(this.L); this.i.draw(canvas); } } public void onRestoreInstanceState(Parcelable parcelable) { if (parcelable instanceof Bundle) { Bundle bundle = (Bundle) parcelable; this.e = bundle.getInt("mCurrentTab"); parcelable = bundle.getParcelable("instanceState"); if (this.e != 0 && this.d.getChildCount() > 0) { d(this.e); } } super.onRestoreInstanceState(parcelable); } public Parcelable onSaveInstanceState() { Bundle bundle = new Bundle(); bundle.putParcelable("instanceState", super.onSaveInstanceState()); bundle.putInt("mCurrentTab", this.e); return bundle; } public void setCurrentTab(int i3) { this.f = this.e; this.e = i3; d(i3); if (this.w) { View childAt = this.d.getChildAt(this.e); this.O.f4357a = (float) childAt.getLeft(); this.O.b = (float) childAt.getRight(); View childAt2 = this.d.getChildAt(this.f); this.P.f4357a = (float) childAt2.getLeft(); this.P.b = (float) childAt2.getRight(); a aVar = this.P; float f12 = aVar.f4357a; a aVar2 = this.O; if (f12 == aVar2.f4357a && aVar.b == aVar2.b) { invalidate(); return; } this.J.r(aVar, aVar2); if (this.x) { this.J.g(this.K); } if (this.f4356v < 0) { this.f4356v = this.x ? 500 : 250; } this.J.f(this.f4356v); this.J.h(); return; } invalidate(); } public void setDividerColor(int i3) { this.y = i3; invalidate(); } public void setDividerPadding(float f12) { this.A = (float) b(f12); invalidate(); } public void setDividerWidth(float f12) { this.z = (float) b(f12); invalidate(); } public void setIndicatorAnimDuration(long j12) { this.f4356v = j12; } public void setIndicatorAnimEnable(boolean z4) { this.w = z4; } public void setIndicatorBounceEnable(boolean z4) { this.x = z4; } public void setIndicatorColor(int i3) { this.o = i3; invalidate(); } public void setIndicatorCornerRadius(float f12) { this.f4354q = (float) b(f12); invalidate(); } public void setIndicatorHeight(float f12) { this.p = (float) b(f12); invalidate(); } public void setOnTabSelectListener(OnTabSelectListener onTabSelectListener) { this.N = onTabSelectListener; } public void setTabData(String[] strArr) { if (strArr == null || strArr.length == 0) { throw new IllegalStateException("Titles can not be NULL or EMPTY !"); } this.f4351c = strArr; this.d.removeAllViews(); this.f4352g = this.f4351c.length; for (int i3 = 0; i3 < this.f4352g; i3++) { View inflate = View.inflate(this.b, R.layout.layout_tab_segment, null); inflate.setTag(Integer.valueOf(i3)); ((TextView) inflate.findViewById(R.id.tv_tab_title)).setText(this.f4351c[i3]); inflate.setOnClickListener(new View.OnClickListener() { /* class com.flyco.tablayout.SegmentTabLayout.AnonymousClass1 */ @SensorsDataInstrumented public void onClick(View view) { int intValue = ((Integer) view.getTag()).intValue(); SegmentTabLayout segmentTabLayout = SegmentTabLayout.this; if (segmentTabLayout.e != intValue) { segmentTabLayout.setCurrentTab(intValue); OnTabSelectListener onTabSelectListener = SegmentTabLayout.this.N; if (onTabSelectListener != null) { onTabSelectListener.onTabSelect(intValue); } } else { OnTabSelectListener onTabSelectListener2 = segmentTabLayout.N; if (onTabSelectListener2 != null) { onTabSelectListener2.onTabReselect(intValue); } } SensorsDataAutoTrackHelper.trackViewOnClick(view); } }); LinearLayout.LayoutParams layoutParams = this.m ? new LinearLayout.LayoutParams(0, -1, 1.0f) : new LinearLayout.LayoutParams(-2, -1); if (this.n > i.f36333a) { layoutParams = new LinearLayout.LayoutParams((int) this.n, -1); } this.d.addView(inflate, i3, layoutParams); } e(); } public void setTabPadding(float f12) { this.l = (float) b(f12); e(); } public void setTabSpaceEqual(boolean z4) { this.m = z4; e(); } public void setTabWidth(float f12) { this.n = (float) b(f12); e(); } public void setTextAllCaps(boolean z4) { this.F = z4; e(); } public void setTextBold(boolean z4) { this.E = z4; e(); } public void setTextSelectColor(int i3) { this.C = i3; e(); } public void setTextUnselectColor(int i3) { this.D = i3; e(); } public void setTextsize(float f12) { this.B = (float) c(f12); e(); } public SegmentTabLayout(Context context, AttributeSet attributeSet) { this(context, attributeSet, 0); } public SegmentTabLayout(Context context, AttributeSet attributeSet, int i3) { super(context, attributeSet, i3); this.f4353h = new Rect(); this.i = new GradientDrawable(); this.j = new GradientDrawable(); this.k = new Paint(1); this.K = new OvershootInterpolator(0.8f); this.L = new float[8]; this.M = true; new Paint(1); new SparseArray(); this.O = new a(this); this.P = new a(this); setWillNotDraw(false); setClipChildren(false); setClipToPadding(false); this.b = context; LinearLayout linearLayout = new LinearLayout(context); this.d = linearLayout; addView(linearLayout); TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, new int[]{R.attr.tl_bar_color, R.attr.tl_bar_stroke_color, R.attr.tl_bar_stroke_width, R.attr.tl_divider_color, R.attr.tl_divider_padding, R.attr.tl_divider_width, R.attr.tl_indicator_anim_duration, R.attr.tl_indicator_anim_enable, R.attr.tl_indicator_bounce_enable, R.attr.tl_indicator_color, R.attr.tl_indicator_corner_radius, R.attr.tl_indicator_height, R.attr.tl_indicator_margin_bottom, R.attr.tl_indicator_margin_left, R.attr.tl_indicator_margin_right, R.attr.tl_indicator_margin_top, R.attr.tl_tab_padding, R.attr.tl_tab_space_equal, R.attr.tl_tab_width, R.attr.tl_textAllCaps, R.attr.tl_textBold, R.attr.tl_textSelectColor, R.attr.tl_textUnselectColor, R.attr.tl_textsize}); this.o = obtainStyledAttributes.getColor(9, Color.parseColor("#222831")); this.p = obtainStyledAttributes.getDimension(11, -1.0f); this.f4354q = obtainStyledAttributes.getDimension(10, -1.0f); float f12 = i.f36333a; this.r = obtainStyledAttributes.getDimension(13, (float) b(i.f36333a)); this.s = obtainStyledAttributes.getDimension(15, i.f36333a); this.t = obtainStyledAttributes.getDimension(14, (float) b(i.f36333a)); this.f4355u = obtainStyledAttributes.getDimension(12, i.f36333a); this.w = obtainStyledAttributes.getBoolean(7, false); this.x = obtainStyledAttributes.getBoolean(8, true); this.f4356v = (long) obtainStyledAttributes.getInt(6, -1); this.y = obtainStyledAttributes.getColor(3, this.o); this.z = obtainStyledAttributes.getDimension(5, (float) b(1.0f)); this.A = obtainStyledAttributes.getDimension(4, i.f36333a); this.B = obtainStyledAttributes.getDimension(23, (float) c(13.0f)); this.C = obtainStyledAttributes.getColor(21, Color.parseColor("#ffffff")); this.D = obtainStyledAttributes.getColor(22, this.o); this.E = obtainStyledAttributes.getBoolean(20, false); this.F = obtainStyledAttributes.getBoolean(19, false); this.m = obtainStyledAttributes.getBoolean(17, true); float dimension = obtainStyledAttributes.getDimension(18, (float) b(-1.0f)); this.n = dimension; if (!this.m && dimension <= i.f36333a) { f12 = 10.0f; } this.l = obtainStyledAttributes.getDimension(16, (float) b(f12)); this.G = obtainStyledAttributes.getColor(0, 0); this.H = obtainStyledAttributes.getColor(1, this.o); this.I = obtainStyledAttributes.getDimension(2, (float) b(1.0f)); obtainStyledAttributes.recycle(); String attributeValue = attributeSet.getAttributeValue("http://schemas.android.com/apk/res/android", "layout_height"); if (!attributeValue.equals("-1") && !attributeValue.equals("-2")) { TypedArray obtainStyledAttributes2 = context.obtainStyledAttributes(attributeSet, new int[]{16842997}); obtainStyledAttributes2.getDimensionPixelSize(0, -2); obtainStyledAttributes2.recycle(); } b bVar = new b(); Object[] objArr = {this.P, this.O}; ValueAnimator valueAnimator = new ValueAnimator(); valueAnimator.r(objArr); valueAnimator.p(bVar); this.J = valueAnimator; if (valueAnimator.o == null) { valueAnimator.o = new ArrayList<>(); } valueAnimator.o.add(this); } }