what-the-bank/sources/com/google/android/material/internal/FlowLayout.java

179 lines
6.5 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.android.material.internal;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import androidx.core.view.ViewCompat;
import o.C17052tZT;
import o.CYM;
/* loaded from: classes2.dex */
public class FlowLayout extends ViewGroup {
private boolean a;
private int b;
private int d;
private int e;
public FlowLayout(Context context) {
this(context, null);
}
public FlowLayout(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public FlowLayout(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.a = false;
TypedArray obtainStyledAttributes = context.getTheme().obtainStyledAttributes(attributeSet, C17052tZT.jNh.FlowLayout, 0, 0);
this.d = obtainStyledAttributes.getDimensionPixelSize(C17052tZT.jNh.FlowLayout_lineSpacing, 0);
this.b = obtainStyledAttributes.getDimensionPixelSize(C17052tZT.jNh.FlowLayout_itemSpacing, 0);
obtainStyledAttributes.recycle();
}
@Override // android.view.View
protected void onMeasure(int i, int i2) {
int i3;
int i4;
int i5;
int i6;
int size = View.MeasureSpec.getSize(i);
int mode = View.MeasureSpec.getMode(i);
int size2 = View.MeasureSpec.getSize(i2);
int mode2 = View.MeasureSpec.getMode(i2);
int i7 = (mode == Integer.MIN_VALUE || mode == 1073741824) ? size : Integer.MAX_VALUE;
int paddingLeft = getPaddingLeft();
int paddingTop = getPaddingTop();
int paddingRight = getPaddingRight();
int i8 = paddingTop;
int i9 = 0;
for (int i10 = 0; i10 < getChildCount(); i10++) {
View childAt = getChildAt(i10);
if (childAt.getVisibility() != 8) {
measureChild(childAt, i, i2);
ViewGroup.LayoutParams layoutParams = childAt.getLayoutParams();
if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
i4 = marginLayoutParams.leftMargin;
i5 = marginLayoutParams.rightMargin;
} else {
i4 = 0;
i5 = 0;
}
int i11 = paddingLeft;
if (paddingLeft + i4 + childAt.getMeasuredWidth() <= i7 - paddingRight || a()) {
i6 = i11;
} else {
i6 = getPaddingLeft();
i8 = this.d + paddingTop;
}
int measuredWidth = i6 + i4 + childAt.getMeasuredWidth();
int measuredHeight = childAt.getMeasuredHeight();
if (measuredWidth > i9) {
i9 = measuredWidth;
}
paddingLeft = i6 + i4 + i5 + childAt.getMeasuredWidth() + this.b;
if (i10 == getChildCount() - 1) {
i9 += i5;
}
paddingTop = measuredHeight + i8;
}
}
int paddingRight2 = getPaddingRight();
int paddingBottom = getPaddingBottom();
int i12 = i9 + paddingRight2;
if (mode != Integer.MIN_VALUE) {
i3 = 1073741824;
if (mode != 1073741824) {
size = i12;
}
} else {
i3 = 1073741824;
size = Math.min(i12, size);
}
int i13 = paddingTop + paddingBottom;
if (mode2 == Integer.MIN_VALUE) {
size2 = Math.min(i13, size2);
} else if (mode2 != i3) {
size2 = i13;
}
setMeasuredDimension(size, size2);
}
@Override // android.view.ViewGroup, android.view.View
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
int i5;
int i6;
if (getChildCount() == 0) {
this.e = 0;
return;
}
this.e = 1;
boolean z2 = ViewCompat.m(this) == 1;
int paddingRight = z2 ? getPaddingRight() : getPaddingLeft();
int paddingLeft = z2 ? getPaddingLeft() : getPaddingRight();
int paddingTop = getPaddingTop();
int i7 = (i3 - i) - paddingLeft;
int i8 = paddingRight;
int i9 = paddingTop;
for (int i10 = 0; i10 < getChildCount(); i10++) {
View childAt = getChildAt(i10);
if (childAt.getVisibility() == 8) {
childAt.setTag(C17052tZT.ZqN.row_index_key, -1);
} else {
ViewGroup.LayoutParams layoutParams = childAt.getLayoutParams();
if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
i6 = CYM.ry_(marginLayoutParams);
i5 = CYM.rx_(marginLayoutParams);
} else {
i5 = 0;
i6 = 0;
}
int measuredWidth = childAt.getMeasuredWidth();
if (!this.a && i8 + i6 + measuredWidth > i7) {
paddingTop = this.d + i9;
this.e++;
i8 = paddingRight;
}
childAt.setTag(C17052tZT.ZqN.row_index_key, Integer.valueOf(this.e - 1));
int i11 = i8 + i6;
int measuredWidth2 = childAt.getMeasuredWidth() + i11;
int measuredHeight = childAt.getMeasuredHeight() + paddingTop;
if (z2) {
childAt.layout(i7 - measuredWidth2, paddingTop, (i7 - i8) - i6, measuredHeight);
} else {
childAt.layout(i11, paddingTop, measuredWidth2, measuredHeight);
}
i8 += i6 + i5 + childAt.getMeasuredWidth() + this.b;
i9 = measuredHeight;
}
}
}
public void setSingleLine(boolean z) {
this.a = z;
}
/* JADX INFO: Access modifiers changed from: protected */
public final void d(int i) {
this.d = i;
}
/* JADX INFO: Access modifiers changed from: protected */
public final void e(int i) {
this.b = i;
}
public boolean a() {
return this.a;
}
/* JADX INFO: Access modifiers changed from: protected */
public final int e() {
return this.e;
}
}