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.animation.OvershootInterpolator; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.flyco.tablayout.listener.CustomTabEntity; import com.flyco.tablayout.listener.OnTabSelectListener; import com.meituan.robust.PatchProxy; import com.meizu.cloud.pushsdk.constants.PushConstants; 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 com.shizhuang.duapp.common.aspect.ThirdSdkAspect; import java.util.ArrayList; import o5.i; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.runtime.reflect.Factory; public class CommonTabLayout extends FrameLayout implements ValueAnimator.AnimatorUpdateListener { private static /* synthetic */ JoinPoint.StaticPart ajc$tjp_0; public boolean A; public boolean B; public int C; public int D; public float E; public int F; public int G; public float H; public float I; public float J; public int K; public int L; public boolean M; public boolean N; public boolean O; public int P; public float Q; public float R; public float S; public ValueAnimator T; public OvershootInterpolator U; public boolean V; public OnTabSelectListener W; /* renamed from: a0 reason: collision with root package name */ public a f4343a0; public Context b; public a b0; /* renamed from: c reason: collision with root package name */ public ArrayList<CustomTabEntity> f4344c; public LinearLayout d; public int e; public int f; /* renamed from: g reason: collision with root package name */ public int f4345g; /* renamed from: h reason: collision with root package name */ public Rect f4346h; public GradientDrawable i; public Paint j; public Paint k; public Paint l; public Path m; public int n; public float o; public boolean p; /* renamed from: q reason: collision with root package name */ public float f4347q; public int r; public float s; public float t; /* renamed from: u reason: collision with root package name */ public float f4348u; /* renamed from: v reason: collision with root package name */ public float f4349v; public float w; public float x; public float y; public long z; public class a { /* renamed from: a reason: collision with root package name */ public float f4350a; public float b; public a(CommonTabLayout commonTabLayout) { } } 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.f4350a; float b2 = a1.a.b(aVar4.f4350a, f12, f, f12); float f13 = aVar3.b; float b5 = a1.a.b(aVar4.b, f13, f, f13); a aVar5 = new a(CommonTabLayout.this); aVar5.f4350a = b2; aVar5.b = b5; return aVar5; } } static { Factory factory = new Factory("CommonTabLayout.java", CommonTabLayout.class); ajc$tjp_0 = factory.makeSJP("method-execution", factory.makeMethodSig(PushConstants.PUSH_TYPE_UPLOAD_LOG, "calcOffset", "com.flyco.tablayout.CommonTabLayout", "", "", "", "void"), 318); } public CommonTabLayout(Context context) { this(context, null, 0); } public final void a() { View childAt = this.d.getChildAt(this.e); Rect rect = this.f4346h; rect.left = (int) ((float) childAt.getLeft()); rect.right = (int) ((float) childAt.getRight()); if (this.t >= i.f36333a) { float width = (float) childAt.getWidth(); float f12 = this.t; float a5 = h.a.a(width, f12, 2.0f, (float) childAt.getLeft()); Rect rect2 = this.f4346h; int i3 = (int) a5; rect2.left = i3; rect2.right = (int) (((float) i3) + f12); } } public int b(float f12) { return (int) ((f12 * this.b.getResources().getDisplayMetrics().density) + 0.5f); } public void c() { View view; this.d.removeAllViews(); this.f4345g = this.f4344c.size(); for (int i3 = 0; i3 < this.f4345g; i3++) { int i12 = this.P; if (i12 == 3) { view = View.inflate(this.b, R.layout.layout_tab_left, null); } else if (i12 == 5) { view = View.inflate(this.b, R.layout.layout_tab_right, null); } else if (i12 == 80) { view = View.inflate(this.b, R.layout.layout_tab_bottom, null); } else { view = View.inflate(this.b, R.layout.layout_tab_top, null); } view.setTag(Integer.valueOf(i3)); ((TextView) view.findViewById(R.id.tv_tab_title)).setText(this.f4344c.get(i3).getTabTitle()); ((ImageView) view.findViewById(R.id.iv_tab_icon)).setImageResource(this.f4344c.get(i3).getTabUnselectedIcon()); view.setOnClickListener(new View.OnClickListener() { /* class com.flyco.tablayout.CommonTabLayout.AnonymousClass1 */ @SensorsDataInstrumented public void onClick(View view) { int intValue = ((Integer) view.getTag()).intValue(); CommonTabLayout commonTabLayout = CommonTabLayout.this; if (commonTabLayout.e != intValue) { commonTabLayout.setCurrentTab(intValue); OnTabSelectListener onTabSelectListener = CommonTabLayout.this.W; if (onTabSelectListener != null) { onTabSelectListener.onTabSelect(intValue); } } else { OnTabSelectListener onTabSelectListener2 = commonTabLayout.W; if (onTabSelectListener2 != null) { onTabSelectListener2.onTabReselect(intValue); } } SensorsDataAutoTrackHelper.trackViewOnClick(view); } }); LinearLayout.LayoutParams layoutParams = this.p ? new LinearLayout.LayoutParams(0, -1, 1.0f) : new LinearLayout.LayoutParams(-2, -1); if (this.f4347q > i.f36333a) { layoutParams = new LinearLayout.LayoutParams((int) this.f4347q, -1); } this.d.addView(view, i3, layoutParams); } f(); } public int d(float f12) { return (int) ((f12 * this.b.getResources().getDisplayMetrics().scaledDensity) + 0.5f); } public final void e(int i3) { int i12 = 0; while (i12 < this.f4345g) { View childAt = this.d.getChildAt(i12); boolean z4 = i12 == i3; ((TextView) childAt.findViewById(R.id.tv_tab_title)).setTextColor(z4 ? this.K : this.L); ImageView imageView = (ImageView) childAt.findViewById(R.id.iv_tab_icon); CustomTabEntity customTabEntity = this.f4344c.get(i12); imageView.setImageResource(z4 ? customTabEntity.getTabSelectedIcon() : customTabEntity.getTabUnselectedIcon()); i12++; } } public final void f() { int i3 = 0; while (i3 < this.f4345g) { View childAt = this.d.getChildAt(i3); float f12 = this.o; childAt.setPadding((int) f12, 0, (int) f12, 0); TextView textView = (TextView) childAt.findViewById(R.id.tv_tab_title); textView.setTextColor(i3 == this.e ? this.K : this.L); textView.setTextSize(0, this.J); if (this.N) { textView.setText(textView.getText().toString().toUpperCase()); } if (this.M) { textView.getPaint().setFakeBoldText(this.M); } ImageView imageView = (ImageView) childAt.findViewById(R.id.iv_tab_icon); if (this.O) { imageView.setVisibility(0); CustomTabEntity customTabEntity = this.f4344c.get(i3); imageView.setImageResource(i3 == this.e ? customTabEntity.getTabSelectedIcon() : customTabEntity.getTabUnselectedIcon()); float f13 = this.Q; int i12 = -2; int i13 = f13 <= i.f36333a ? -2 : (int) f13; float f14 = this.R; if (f14 > i.f36333a) { i12 = (int) f14; } LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(i13, i12); int i14 = this.P; if (i14 == 3) { layoutParams.rightMargin = (int) this.S; } else if (i14 == 5) { layoutParams.leftMargin = (int) this.S; } else if (i14 == 80) { layoutParams.topMargin = (int) this.S; } else { layoutParams.bottomMargin = (int) this.S; } imageView.setLayoutParams(layoutParams); } else { imageView.setVisibility(8); } i3++; } } public int getCurrentTab() { return this.e; } public int getDividerColor() { return this.G; } public float getDividerPadding() { return this.I; } public float getDividerWidth() { return this.H; } public int getIconGravity() { return this.P; } public float getIconHeight() { return this.R; } public float getIconMargin() { return this.S; } public float getIconWidth() { return this.Q; } public long getIndicatorAnimDuration() { return this.z; } public int getIndicatorColor() { return this.r; } public float getIndicatorCornerRadius() { return this.f4348u; } public float getIndicatorHeight() { return this.s; } public float getIndicatorMarginBottom() { return this.y; } public float getIndicatorMarginLeft() { return this.f4349v; } public float getIndicatorMarginRight() { return this.x; } public float getIndicatorMarginTop() { return this.w; } public int getIndicatorStyle() { return this.n; } public float getIndicatorWidth() { return this.t; } public int getTabCount() { return this.f4345g; } public float getTabPadding() { return this.o; } public float getTabWidth() { return this.f4347q; } public int getTextSelectColor() { return this.K; } public int getTextUnselectColor() { return this.L; } public float getTextsize() { return this.J; } public int getUnderlineColor() { return this.D; } public float getUnderlineHeight() { return this.E; } @Override // com.nineoldandroids.animation.ValueAnimator.AnimatorUpdateListener public void onAnimationUpdate(ValueAnimator valueAnimator) { View childAt = this.d.getChildAt(this.e); a aVar = (a) valueAnimator.m(); Rect rect = this.f4346h; float f12 = aVar.f4350a; rect.left = (int) f12; rect.right = (int) aVar.b; if (this.t >= i.f36333a) { float f13 = this.t; float a5 = h.a.a((float) childAt.getWidth(), f13, 2.0f, f12); Rect rect2 = this.f4346h; int i3 = (int) a5; rect2.left = i3; rect2.right = (int) (((float) i3) + f13); } invalidate(); } public void onDraw(Canvas canvas) { super.onDraw(canvas); if (!isInEditMode() && this.f4345g > 0) { int height = getHeight(); int paddingLeft = getPaddingLeft(); float f12 = this.H; if (f12 > i.f36333a) { this.k.setStrokeWidth(f12); this.k.setColor(this.G); for (int i3 = 0; i3 < this.f4345g - 1; i3++) { View childAt = this.d.getChildAt(i3); canvas.drawLine((float) (childAt.getRight() + paddingLeft), this.I, (float) (childAt.getRight() + paddingLeft), ((float) height) - this.I, this.k); } } if (this.E > i.f36333a) { this.j.setColor(this.D); if (this.F == 80) { float f13 = (float) height; canvas.drawRect((float) paddingLeft, f13 - this.E, (float) (this.d.getWidth() + paddingLeft), f13, this.j); } else { canvas.drawRect((float) paddingLeft, i.f36333a, (float) (this.d.getWidth() + paddingLeft), this.E, this.j); } } if (!this.A) { a(); } else if (this.V) { this.V = false; a(); } int i12 = this.n; if (i12 == 1) { if (this.s > i.f36333a) { this.l.setColor(this.r); this.m.reset(); float f14 = (float) height; this.m.moveTo((float) (this.f4346h.left + paddingLeft), f14); Path path = this.m; Rect rect = this.f4346h; path.lineTo((float) ((rect.right / 2) + (rect.left / 2) + paddingLeft), f14 - this.s); this.m.lineTo((float) (paddingLeft + this.f4346h.right), f14); this.m.close(); canvas.drawPath(this.m, this.l); } } else if (i12 == 2) { if (this.s < i.f36333a) { this.s = (((float) height) - this.w) - this.y; } float f15 = this.s; if (f15 > i.f36333a) { float f16 = this.f4348u; if (f16 < i.f36333a || f16 > f15 / 2.0f) { this.f4348u = f15 / 2.0f; } this.i.setColor(this.r); GradientDrawable gradientDrawable = this.i; Rect rect2 = this.f4346h; int i13 = ((int) this.f4349v) + paddingLeft + rect2.left; float f17 = this.w; gradientDrawable.setBounds(i13, (int) f17, (int) (((float) (paddingLeft + rect2.right)) - this.x), (int) (f17 + this.s)); this.i.setCornerRadius(this.f4348u); this.i.draw(canvas); } } else if (this.s > i.f36333a) { this.i.setColor(this.r); if (this.C == 80) { GradientDrawable gradientDrawable2 = this.i; Rect rect3 = this.f4346h; float f18 = this.y; gradientDrawable2.setBounds(((int) this.f4349v) + paddingLeft + rect3.left, (height - ((int) this.s)) - ((int) f18), (paddingLeft + rect3.right) - ((int) this.x), height - ((int) f18)); } else { GradientDrawable gradientDrawable3 = this.i; Rect rect4 = this.f4346h; int i14 = ((int) this.f4349v) + paddingLeft + rect4.left; float f19 = this.w; gradientDrawable3.setBounds(i14, (int) f19, (paddingLeft + rect4.right) - ((int) this.x), ((int) this.s) + ((int) f19)); } this.i.setCornerRadius(this.f4348u); 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) { e(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; e(i3); if (this.A) { JoinPoint makeJP = Factory.makeJP(ajc$tjp_0, this, this); ThirdSdkAspect c5 = ThirdSdkAspect.c(); ProceedingJoinPoint linkClosureAndJoinPoint = new d5.a(new Object[]{this, makeJP}, 0).linkClosureAndJoinPoint(69648); if (!PatchProxy.proxy(new Object[]{linkClosureAndJoinPoint}, c5, ThirdSdkAspect.changeQuickRedirect, false, 584, new Class[]{ProceedingJoinPoint.class}, Void.TYPE).isSupported) { try { linkClosureAndJoinPoint.proceed(); } catch (Throwable th2) { fo.a.u("CommonTabLayout.calcOffset").bug(th2, "aopCommonTabLayoutCalcOffset", new Object[0]); } } } else { invalidate(); } } public void setDividerColor(int i3) { this.G = i3; invalidate(); } public void setDividerPadding(float f12) { this.I = (float) b(f12); invalidate(); } public void setDividerWidth(float f12) { this.H = (float) b(f12); invalidate(); } public void setIconGravity(int i3) { this.P = i3; c(); } public void setIconHeight(float f12) { this.R = (float) b(f12); f(); } public void setIconMargin(float f12) { this.S = (float) b(f12); f(); } public void setIconVisible(boolean z4) { this.O = z4; f(); } public void setIconWidth(float f12) { this.Q = (float) b(f12); f(); } public void setIndicatorAnimDuration(long j12) { this.z = j12; } public void setIndicatorAnimEnable(boolean z4) { this.A = z4; } public void setIndicatorBounceEnable(boolean z4) { this.B = z4; } public void setIndicatorColor(int i3) { this.r = i3; invalidate(); } public void setIndicatorCornerRadius(float f12) { this.f4348u = (float) b(f12); invalidate(); } public void setIndicatorGravity(int i3) { this.C = i3; invalidate(); } public void setIndicatorHeight(float f12) { this.s = (float) b(f12); invalidate(); } public void setIndicatorStyle(int i3) { this.n = i3; invalidate(); } public void setIndicatorWidth(float f12) { this.t = (float) b(f12); invalidate(); } public void setOnTabSelectListener(OnTabSelectListener onTabSelectListener) { this.W = onTabSelectListener; } public void setTabData(ArrayList<CustomTabEntity> arrayList) { if (arrayList == null || arrayList.size() == 0) { throw new IllegalStateException("TabEntitys can not be NULL or EMPTY !"); } this.f4344c.clear(); this.f4344c.addAll(arrayList); c(); } public void setTabPadding(float f12) { this.o = (float) b(f12); f(); } public void setTabSpaceEqual(boolean z4) { this.p = z4; f(); } public void setTabWidth(float f12) { this.f4347q = (float) b(f12); f(); } public void setTextAllCaps(boolean z4) { this.N = z4; f(); } public void setTextBold(boolean z4) { this.M = z4; f(); } public void setTextSelectColor(int i3) { this.K = i3; f(); } public void setTextUnselectColor(int i3) { this.L = i3; f(); } public void setTextsize(float f12) { this.J = (float) d(f12); f(); } public void setUnderlineColor(int i3) { this.D = i3; invalidate(); } public void setUnderlineGravity(int i3) { this.F = i3; invalidate(); } public void setUnderlineHeight(float f12) { this.E = (float) b(f12); invalidate(); } public CommonTabLayout(Context context, AttributeSet attributeSet) { this(context, attributeSet, 0); } public CommonTabLayout(Context context, AttributeSet attributeSet, int i3) { super(context, attributeSet, i3); float f12; this.f4344c = new ArrayList<>(); this.f4346h = new Rect(); this.i = new GradientDrawable(); this.j = new Paint(1); this.k = new Paint(1); this.l = new Paint(1); this.m = new Path(); this.n = 0; this.U = new OvershootInterpolator(1.5f); this.V = true; new Paint(1); new SparseArray(); this.f4343a0 = new a(this); this.b0 = 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_divider_color, R.attr.tl_divider_padding, R.attr.tl_divider_width, R.attr.tl_iconGravity, R.attr.tl_iconHeight, R.attr.tl_iconMargin, R.attr.tl_iconVisible, R.attr.tl_iconWidth, 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_gravity, 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_indicator_style, R.attr.tl_indicator_width, 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, R.attr.tl_underline_color, R.attr.tl_underline_gravity, R.attr.tl_underline_height}); int i12 = obtainStyledAttributes.getInt(19, 0); this.n = i12; this.r = obtainStyledAttributes.getColor(11, Color.parseColor(i12 == 2 ? "#4B6A87" : "#ffffff")); int i13 = this.n; if (i13 == 1) { f12 = 4.0f; } else { f12 = (float) (i13 == 2 ? -1 : 2); } this.s = obtainStyledAttributes.getDimension(14, (float) b(f12)); this.t = obtainStyledAttributes.getDimension(20, (float) b(this.n == 1 ? 10.0f : -1.0f)); this.f4348u = obtainStyledAttributes.getDimension(12, (float) b(this.n == 2 ? -1.0f : i.f36333a)); this.f4349v = obtainStyledAttributes.getDimension(16, (float) b(i.f36333a)); float f13 = 7.0f; this.w = obtainStyledAttributes.getDimension(18, (float) b(this.n == 2 ? 7.0f : i.f36333a)); this.x = obtainStyledAttributes.getDimension(17, (float) b(i.f36333a)); this.y = obtainStyledAttributes.getDimension(15, (float) b(this.n != 2 ? i.f36333a : f13)); this.A = obtainStyledAttributes.getBoolean(9, true); this.B = obtainStyledAttributes.getBoolean(10, true); this.z = (long) obtainStyledAttributes.getInt(8, -1); this.C = obtainStyledAttributes.getInt(13, 80); this.D = obtainStyledAttributes.getColor(29, Color.parseColor("#ffffff")); this.E = obtainStyledAttributes.getDimension(31, (float) b(i.f36333a)); this.F = obtainStyledAttributes.getInt(30, 80); this.G = obtainStyledAttributes.getColor(0, Color.parseColor("#ffffff")); this.H = obtainStyledAttributes.getDimension(2, (float) b(i.f36333a)); this.I = obtainStyledAttributes.getDimension(1, (float) b(12.0f)); this.J = obtainStyledAttributes.getDimension(28, (float) d(13.0f)); this.K = obtainStyledAttributes.getColor(26, Color.parseColor("#ffffff")); this.L = obtainStyledAttributes.getColor(27, Color.parseColor("#AAffffff")); this.M = obtainStyledAttributes.getBoolean(25, false); this.N = obtainStyledAttributes.getBoolean(24, false); this.O = obtainStyledAttributes.getBoolean(6, true); this.P = obtainStyledAttributes.getInt(3, 48); this.Q = obtainStyledAttributes.getDimension(7, (float) b(i.f36333a)); this.R = obtainStyledAttributes.getDimension(4, (float) b(i.f36333a)); this.S = obtainStyledAttributes.getDimension(5, (float) b(2.5f)); this.p = obtainStyledAttributes.getBoolean(22, true); float dimension = obtainStyledAttributes.getDimension(23, (float) b(-1.0f)); this.f4347q = dimension; this.o = obtainStyledAttributes.getDimension(21, (float) ((this.p || dimension > i.f36333a) ? b(i.f36333a) : b(10.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.b0, this.f4343a0}; ValueAnimator valueAnimator = new ValueAnimator(); valueAnimator.r(objArr); valueAnimator.p(bVar); this.T = valueAnimator; if (valueAnimator.o == null) { valueAnimator.o = new ArrayList<>(); } valueAnimator.o.add(this); } }