248 lines
9.8 KiB
Java
248 lines
9.8 KiB
Java
package androidx.appcompat.widget;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.Rect;
|
|
import android.util.AttributeSet;
|
|
import android.util.DisplayMetrics;
|
|
import android.util.TypedValue;
|
|
import android.view.View;
|
|
import android.widget.FrameLayout;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RestrictTo;
|
|
import androidx.constraintlayout.solver.widgets.analyzer.BasicMeasure;
|
|
import androidx.core.view.ViewCompat;
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY})
|
|
public class ContentFrameLayout extends FrameLayout {
|
|
private OnAttachListener mAttachListener;
|
|
private final Rect mDecorPadding;
|
|
private TypedValue mFixedHeightMajor;
|
|
private TypedValue mFixedHeightMinor;
|
|
private TypedValue mFixedWidthMajor;
|
|
private TypedValue mFixedWidthMinor;
|
|
private TypedValue mMinWidthMajor;
|
|
private TypedValue mMinWidthMinor;
|
|
|
|
public interface OnAttachListener {
|
|
void onAttachedFromWindow();
|
|
|
|
void onDetachedFromWindow();
|
|
}
|
|
|
|
public ContentFrameLayout(@NonNull Context context) {
|
|
this(context, null);
|
|
}
|
|
|
|
public ContentFrameLayout(@NonNull Context context, @Nullable AttributeSet attributeSet) {
|
|
this(context, attributeSet, 0);
|
|
}
|
|
|
|
public ContentFrameLayout(@NonNull Context context, @Nullable AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
this.mDecorPadding = new Rect();
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public void dispatchFitSystemWindows(Rect rect) {
|
|
fitSystemWindows(rect);
|
|
}
|
|
|
|
public TypedValue getFixedHeightMajor() {
|
|
if (this.mFixedHeightMajor == null) {
|
|
this.mFixedHeightMajor = new TypedValue();
|
|
}
|
|
return this.mFixedHeightMajor;
|
|
}
|
|
|
|
public TypedValue getFixedHeightMinor() {
|
|
if (this.mFixedHeightMinor == null) {
|
|
this.mFixedHeightMinor = new TypedValue();
|
|
}
|
|
return this.mFixedHeightMinor;
|
|
}
|
|
|
|
public TypedValue getFixedWidthMajor() {
|
|
if (this.mFixedWidthMajor == null) {
|
|
this.mFixedWidthMajor = new TypedValue();
|
|
}
|
|
return this.mFixedWidthMajor;
|
|
}
|
|
|
|
public TypedValue getFixedWidthMinor() {
|
|
if (this.mFixedWidthMinor == null) {
|
|
this.mFixedWidthMinor = new TypedValue();
|
|
}
|
|
return this.mFixedWidthMinor;
|
|
}
|
|
|
|
public TypedValue getMinWidthMajor() {
|
|
if (this.mMinWidthMajor == null) {
|
|
this.mMinWidthMajor = new TypedValue();
|
|
}
|
|
return this.mMinWidthMajor;
|
|
}
|
|
|
|
public TypedValue getMinWidthMinor() {
|
|
if (this.mMinWidthMinor == null) {
|
|
this.mMinWidthMinor = new TypedValue();
|
|
}
|
|
return this.mMinWidthMinor;
|
|
}
|
|
|
|
@Override // android.view.View, android.view.ViewGroup
|
|
public void onAttachedToWindow() {
|
|
super.onAttachedToWindow();
|
|
OnAttachListener onAttachListener = this.mAttachListener;
|
|
if (onAttachListener != null) {
|
|
onAttachListener.onAttachedFromWindow();
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View, android.view.ViewGroup
|
|
public void onDetachedFromWindow() {
|
|
super.onDetachedFromWindow();
|
|
OnAttachListener onAttachListener = this.mAttachListener;
|
|
if (onAttachListener != null) {
|
|
onAttachListener.onDetachedFromWindow();
|
|
}
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:19:0x004a */
|
|
/* JADX WARNING: Removed duplicated region for block: B:22:0x0063 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:35:0x0086 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:40:0x00ab */
|
|
/* JADX WARNING: Removed duplicated region for block: B:41:0x00ae */
|
|
/* JADX WARNING: Removed duplicated region for block: B:46:0x00b8 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:48:0x00be */
|
|
/* JADX WARNING: Removed duplicated region for block: B:52:0x00cc */
|
|
/* JADX WARNING: Removed duplicated region for block: B:54:0x00d6 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:57:0x00de */
|
|
/* JADX WARNING: Removed duplicated region for block: B:59:? A[RETURN, SYNTHETIC] */
|
|
@Override // android.widget.FrameLayout, android.view.View
|
|
public void onMeasure(int i, int i2) {
|
|
boolean z2;
|
|
int measuredWidth;
|
|
int i3;
|
|
int i4;
|
|
float fraction;
|
|
int i5;
|
|
int i6;
|
|
float fraction2;
|
|
int i7;
|
|
int i8;
|
|
float fraction3;
|
|
DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
|
|
boolean z3 = true;
|
|
boolean z4 = displayMetrics.widthPixels < displayMetrics.heightPixels;
|
|
int mode = View.MeasureSpec.getMode(i);
|
|
int mode2 = View.MeasureSpec.getMode(i2);
|
|
if (mode == Integer.MIN_VALUE) {
|
|
TypedValue typedValue = z4 ? this.mFixedWidthMinor : this.mFixedWidthMajor;
|
|
if (!(typedValue == null || (i7 = typedValue.type) == 0)) {
|
|
if (i7 == 5) {
|
|
fraction3 = typedValue.getDimension(displayMetrics);
|
|
} else if (i7 == 6) {
|
|
int i9 = displayMetrics.widthPixels;
|
|
fraction3 = typedValue.getFraction((float) i9, (float) i9);
|
|
} else {
|
|
i8 = 0;
|
|
if (i8 > 0) {
|
|
Rect rect = this.mDecorPadding;
|
|
i = View.MeasureSpec.makeMeasureSpec(Math.min(i8 - (rect.left + rect.right), View.MeasureSpec.getSize(i)), BasicMeasure.EXACTLY);
|
|
z2 = true;
|
|
if (mode2 == Integer.MIN_VALUE) {
|
|
TypedValue typedValue2 = z4 ? this.mFixedHeightMajor : this.mFixedHeightMinor;
|
|
if (!(typedValue2 == null || (i5 = typedValue2.type) == 0)) {
|
|
if (i5 == 5) {
|
|
fraction2 = typedValue2.getDimension(displayMetrics);
|
|
} else if (i5 == 6) {
|
|
int i10 = displayMetrics.heightPixels;
|
|
fraction2 = typedValue2.getFraction((float) i10, (float) i10);
|
|
} else {
|
|
i6 = 0;
|
|
if (i6 > 0) {
|
|
Rect rect2 = this.mDecorPadding;
|
|
i2 = View.MeasureSpec.makeMeasureSpec(Math.min(i6 - (rect2.top + rect2.bottom), View.MeasureSpec.getSize(i2)), BasicMeasure.EXACTLY);
|
|
}
|
|
}
|
|
i6 = (int) fraction2;
|
|
if (i6 > 0) {
|
|
}
|
|
}
|
|
}
|
|
super.onMeasure(i, i2);
|
|
measuredWidth = getMeasuredWidth();
|
|
int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(measuredWidth, BasicMeasure.EXACTLY);
|
|
if (!z2 && mode == Integer.MIN_VALUE) {
|
|
TypedValue typedValue3 = !z4 ? this.mMinWidthMinor : this.mMinWidthMajor;
|
|
if (!(typedValue3 == null || (i3 = typedValue3.type) == 0)) {
|
|
if (i3 != 5) {
|
|
fraction = typedValue3.getDimension(displayMetrics);
|
|
} else if (i3 == 6) {
|
|
int i11 = displayMetrics.widthPixels;
|
|
fraction = typedValue3.getFraction((float) i11, (float) i11);
|
|
} else {
|
|
i4 = 0;
|
|
if (i4 > 0) {
|
|
Rect rect3 = this.mDecorPadding;
|
|
i4 -= rect3.left + rect3.right;
|
|
}
|
|
if (measuredWidth < i4) {
|
|
makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(i4, BasicMeasure.EXACTLY);
|
|
if (z3) {
|
|
super.onMeasure(makeMeasureSpec, i2);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
i4 = (int) fraction;
|
|
if (i4 > 0) {
|
|
}
|
|
if (measuredWidth < i4) {
|
|
}
|
|
}
|
|
}
|
|
z3 = false;
|
|
if (z3) {
|
|
}
|
|
}
|
|
}
|
|
i8 = (int) fraction3;
|
|
if (i8 > 0) {
|
|
}
|
|
}
|
|
}
|
|
z2 = false;
|
|
if (mode2 == Integer.MIN_VALUE) {
|
|
}
|
|
super.onMeasure(i, i2);
|
|
measuredWidth = getMeasuredWidth();
|
|
int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(measuredWidth, BasicMeasure.EXACTLY);
|
|
if (!z4) {
|
|
}
|
|
if (i3 != 5) {
|
|
}
|
|
i4 = (int) fraction;
|
|
if (i4 > 0) {
|
|
}
|
|
if (measuredWidth < i4) {
|
|
}
|
|
z3 = false;
|
|
if (z3) {
|
|
}
|
|
}
|
|
|
|
public void setAttachListener(OnAttachListener onAttachListener) {
|
|
this.mAttachListener = onAttachListener;
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public void setDecorPadding(int i, int i2, int i3, int i4) {
|
|
this.mDecorPadding.set(i, i2, i3, i4);
|
|
if (ViewCompat.isLaidOut(this)) {
|
|
requestLayout();
|
|
}
|
|
}
|
|
}
|