jimu-decompiled/sources/com/ubtech/view/widget/UViewFlipper.java
2025-05-13 19:24:51 +02:00

147 lines
4.9 KiB
Java

package com.ubtech.view.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.ViewFlipper;
import com.ubtech.R$styleable;
import com.ubtech.utils.DensityUtils;
/* loaded from: classes2.dex */
public class UViewFlipper extends ViewFlipper {
private int a;
private float b;
public static class LayoutParams extends FrameLayout.LayoutParams {
private float a;
private float b;
private float c;
private float d;
private float e;
private float f;
public LayoutParams(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R$styleable.u_layout, 0, 0);
this.a = obtainStyledAttributes.getFloat(R$styleable.u_layout_height_percent, 0.0f);
this.b = obtainStyledAttributes.getFloat(R$styleable.u_layout_width_percent, 0.0f);
this.c = obtainStyledAttributes.getFloat(R$styleable.u_layout_margin_left_percent, 0.0f);
this.d = obtainStyledAttributes.getFloat(R$styleable.u_layout_margin_top_percent, 0.0f);
this.e = obtainStyledAttributes.getFloat(R$styleable.u_layout_margin_right_percent, 0.0f);
this.f = obtainStyledAttributes.getFloat(R$styleable.u_layout_margin_bottom_percent, 0.0f);
obtainStyledAttributes.recycle();
}
public float a() {
return this.f;
}
public float b() {
return this.a;
}
public float c() {
return this.c;
}
public float d() {
return this.e;
}
public float e() {
return this.d;
}
public float f() {
return this.b;
}
}
public UViewFlipper(Context context) {
this(context, null);
}
private void a(Context context, AttributeSet attributeSet) {
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
this.a = Math.min(displayMetrics.widthPixels, displayMetrics.heightPixels);
this.b = this.a / (DensityUtils.a(context, 720) * 1.0f);
}
@Override // android.widget.ViewAnimator, android.view.ViewGroup
public void addView(View view, int i, ViewGroup.LayoutParams layoutParams) {
super.addView(view, i, layoutParams);
if (view instanceof TextView) {
TextView textView = (TextView) view;
textView.setTextSize(0, textView.getTextSize() * this.b);
}
}
@Override // android.widget.FrameLayout, android.view.ViewGroup, android.view.View
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
super.onLayout(z, i, i2, i3, i4);
}
@Override // android.widget.FrameLayout, android.view.View
protected void onMeasure(int i, int i2) {
float f;
float f2;
float f3;
float f4;
float f5;
float f6;
for (int i3 = 0; i3 < getChildCount(); i3++) {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) getChildAt(i3).getLayoutParams();
if (layoutParams instanceof LayoutParams) {
LayoutParams layoutParams2 = (LayoutParams) layoutParams;
f2 = layoutParams2.f();
f3 = layoutParams2.b();
f4 = layoutParams2.c();
f5 = layoutParams2.e();
f6 = layoutParams2.d();
f = layoutParams2.a();
} else {
f = 0.0f;
f2 = 0.0f;
f3 = 0.0f;
f4 = 0.0f;
f5 = 0.0f;
f6 = 0.0f;
}
if (f3 != 0.0f) {
layoutParams.height = (int) Math.ceil(this.a * f3);
}
if (f2 != 0.0f) {
layoutParams.width = (int) Math.ceil(layoutParams.height * f2);
}
if (f4 != 0.0f) {
layoutParams.leftMargin = (int) Math.ceil(this.a * f4);
}
if (f5 != 0.0f) {
layoutParams.topMargin = (int) Math.ceil(this.a * f5);
}
if (f6 != 0.0f) {
layoutParams.rightMargin = (int) Math.ceil(this.a * f6);
}
if (f != 0.0f) {
layoutParams.bottomMargin = (int) Math.ceil(this.a * f);
}
}
super.onMeasure(i, i2);
}
public UViewFlipper(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
a(context, attributeSet);
}
@Override // android.widget.FrameLayout, android.view.ViewGroup
public FrameLayout.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
return new LayoutParams(getContext(), attributeSet);
}
}