Initial commit
This commit is contained in:
105
sources/com/ubt/jimu/widgets/screenAdaptive/XFrameLayout.java
Normal file
105
sources/com/ubt/jimu/widgets/screenAdaptive/XFrameLayout.java
Normal file
@@ -0,0 +1,105 @@
|
||||
package com.ubt.jimu.widgets.screenAdaptive;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class XFrameLayout extends FrameLayout {
|
||||
private Context a;
|
||||
private float b;
|
||||
private float c;
|
||||
private float d;
|
||||
private float e;
|
||||
|
||||
class AutoLayoutParams extends FrameLayout.LayoutParams {
|
||||
public AutoLayoutParams(XFrameLayout xFrameLayout, Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
}
|
||||
}
|
||||
|
||||
public XFrameLayout(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.a = context;
|
||||
a(context);
|
||||
}
|
||||
|
||||
private void a(Context context) {
|
||||
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
|
||||
float f = displayMetrics.density;
|
||||
int i = displayMetrics.densityDpi;
|
||||
this.b = displayMetrics.heightPixels;
|
||||
this.c = displayMetrics.widthPixels;
|
||||
float f2 = this.c;
|
||||
float f3 = this.b;
|
||||
if (f2 < f3) {
|
||||
this.c = f3;
|
||||
this.b = f2;
|
||||
}
|
||||
this.d = this.c / 1024.0f;
|
||||
this.e = this.b / 768.0f;
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup
|
||||
public void addView(View view, int i, ViewGroup.LayoutParams layoutParams) {
|
||||
if (view instanceof TextView) {
|
||||
TextView textView = (TextView) view;
|
||||
textView.setTextSize(0, textView.getTextSize() * this.e);
|
||||
}
|
||||
float paddingBottom = view.getPaddingBottom();
|
||||
float paddingTop = view.getPaddingTop();
|
||||
float paddingLeft = view.getPaddingLeft();
|
||||
float paddingRight = view.getPaddingRight();
|
||||
if (paddingBottom != 0.0f || paddingTop != 0.0f || paddingLeft != 0.0f || paddingRight != 0.0f) {
|
||||
view.setPadding((int) paddingLeft, (int) paddingTop, (int) paddingRight, (int) paddingBottom);
|
||||
}
|
||||
if (layoutParams instanceof FrameLayout.LayoutParams) {
|
||||
FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) layoutParams;
|
||||
float f = layoutParams2.width;
|
||||
float f2 = layoutParams2.height;
|
||||
float f3 = layoutParams2.topMargin;
|
||||
float f4 = layoutParams2.leftMargin;
|
||||
float f5 = layoutParams2.bottomMargin;
|
||||
float f6 = layoutParams2.rightMargin;
|
||||
if (f3 != 0.0f) {
|
||||
layoutParams2.topMargin = (int) ((f3 * this.e) + 0.5d);
|
||||
}
|
||||
if (f5 != 0.0f) {
|
||||
layoutParams2.bottomMargin = (int) ((f5 * this.e) + 0.5d);
|
||||
}
|
||||
if (f4 != 0.0f) {
|
||||
layoutParams2.leftMargin = (int) ((f4 * this.d) + 0.5d);
|
||||
}
|
||||
if (f6 != 0.0f) {
|
||||
layoutParams2.rightMargin = (int) ((f6 * this.d) + 0.5d);
|
||||
}
|
||||
int i2 = (int) ((this.e * f2) + 0.5d);
|
||||
if (f2 > 0.0f) {
|
||||
layoutParams2.height = i2;
|
||||
}
|
||||
if (f > 0.0f) {
|
||||
layoutParams2.width = (int) ((i2 * (f / f2)) + 0.5d);
|
||||
}
|
||||
}
|
||||
super.addView(view, i, layoutParams);
|
||||
}
|
||||
|
||||
@Override // android.widget.FrameLayout, android.view.View
|
||||
protected void onMeasure(int i, int i2) {
|
||||
if (getLayoutParams() instanceof FrameLayout.LayoutParams) {
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) getLayoutParams();
|
||||
int i3 = layoutParams.width;
|
||||
int i4 = layoutParams.height;
|
||||
}
|
||||
super.onMeasure(i, i2);
|
||||
}
|
||||
|
||||
@Override // android.widget.FrameLayout, android.view.ViewGroup
|
||||
public FrameLayout.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
|
||||
return new AutoLayoutParams(this, this.a, attributeSet);
|
||||
}
|
||||
}
|
106
sources/com/ubt/jimu/widgets/screenAdaptive/XLinearLayout.java
Normal file
106
sources/com/ubt/jimu/widgets/screenAdaptive/XLinearLayout.java
Normal file
@@ -0,0 +1,106 @@
|
||||
package com.ubt.jimu.widgets.screenAdaptive;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class XLinearLayout extends LinearLayout {
|
||||
private Context a;
|
||||
private float b;
|
||||
private float c;
|
||||
private float d;
|
||||
private float e;
|
||||
|
||||
class AutoLayoutParams extends LinearLayout.LayoutParams {
|
||||
public AutoLayoutParams(XLinearLayout xLinearLayout, Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
}
|
||||
}
|
||||
|
||||
public XLinearLayout(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.a = context;
|
||||
getScreenInfo();
|
||||
}
|
||||
|
||||
private void getScreenInfo() {
|
||||
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
|
||||
float f = displayMetrics.density;
|
||||
int i = displayMetrics.densityDpi;
|
||||
this.b = displayMetrics.heightPixels;
|
||||
this.c = displayMetrics.widthPixels;
|
||||
float f2 = this.c;
|
||||
float f3 = this.b;
|
||||
if (f2 < f3) {
|
||||
this.c = f3;
|
||||
this.b = f2;
|
||||
}
|
||||
this.d = this.c / 1024.0f;
|
||||
this.e = this.b / 768.0f;
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup
|
||||
public void addView(View view, int i, ViewGroup.LayoutParams layoutParams) {
|
||||
if (view instanceof TextView) {
|
||||
TextView textView = (TextView) view;
|
||||
textView.setTextSize(0, textView.getTextSize() * this.e);
|
||||
}
|
||||
float paddingBottom = view.getPaddingBottom();
|
||||
float paddingTop = view.getPaddingTop();
|
||||
float paddingLeft = view.getPaddingLeft();
|
||||
float paddingRight = view.getPaddingRight();
|
||||
if (paddingBottom != 0.0f || paddingTop != 0.0f || paddingLeft != 0.0f || paddingRight != 0.0f) {
|
||||
view.setPadding((int) paddingLeft, (int) paddingTop, (int) paddingRight, (int) paddingBottom);
|
||||
}
|
||||
LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) layoutParams;
|
||||
float f = layoutParams2.width;
|
||||
float f2 = layoutParams2.height;
|
||||
Log.e("xLinearLayout", "childWidth==" + f);
|
||||
float f3 = (float) layoutParams2.topMargin;
|
||||
float f4 = (float) layoutParams2.leftMargin;
|
||||
float f5 = (float) layoutParams2.bottomMargin;
|
||||
float f6 = layoutParams2.rightMargin;
|
||||
if (f3 != 0.0f) {
|
||||
layoutParams2.topMargin = (int) ((f3 * this.e) + 0.5d);
|
||||
}
|
||||
if (f5 != 0.0f) {
|
||||
layoutParams2.bottomMargin = (int) ((f5 * this.e) + 0.5d);
|
||||
}
|
||||
if (f4 != 0.0f) {
|
||||
layoutParams2.leftMargin = (int) ((f4 * this.d) + 0.5d);
|
||||
}
|
||||
if (f6 != 0.0f) {
|
||||
layoutParams2.rightMargin = (int) ((f6 * this.d) + 0.5d);
|
||||
}
|
||||
int i2 = (int) ((this.e * f2) + 0.5d);
|
||||
if (f2 > 0.0f) {
|
||||
layoutParams2.height = i2;
|
||||
}
|
||||
if (f > 0.0f) {
|
||||
layoutParams2.width = (int) ((i2 * (f / f2)) + 0.5d);
|
||||
}
|
||||
super.addView(view, i, layoutParams);
|
||||
}
|
||||
|
||||
@Override // android.widget.LinearLayout, android.view.View
|
||||
protected void onMeasure(int i, int i2) {
|
||||
if (getLayoutParams() instanceof FrameLayout.LayoutParams) {
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) getLayoutParams();
|
||||
int i3 = layoutParams.width;
|
||||
int i4 = layoutParams.height;
|
||||
}
|
||||
super.onMeasure(i, i2);
|
||||
}
|
||||
|
||||
@Override // android.widget.LinearLayout, android.view.ViewGroup
|
||||
public LinearLayout.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
|
||||
return new AutoLayoutParams(this, this.a, attributeSet);
|
||||
}
|
||||
}
|
146
sources/com/ubt/jimu/widgets/screenAdaptive/XRelativeLayout.java
Normal file
146
sources/com/ubt/jimu/widgets/screenAdaptive/XRelativeLayout.java
Normal file
@@ -0,0 +1,146 @@
|
||||
package com.ubt.jimu.widgets.screenAdaptive;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class XRelativeLayout extends RelativeLayout {
|
||||
private Context a;
|
||||
private float b;
|
||||
private int c;
|
||||
private float d;
|
||||
private float e;
|
||||
private float f;
|
||||
private float g;
|
||||
protected boolean h;
|
||||
|
||||
class AutoLayoutParams extends RelativeLayout.LayoutParams {
|
||||
public AutoLayoutParams(XRelativeLayout xRelativeLayout, Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
}
|
||||
}
|
||||
|
||||
public XRelativeLayout(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.h = false;
|
||||
this.a = context;
|
||||
a(context);
|
||||
}
|
||||
|
||||
private void a(Context context) {
|
||||
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
|
||||
this.b = displayMetrics.density;
|
||||
this.c = displayMetrics.densityDpi;
|
||||
this.d = displayMetrics.heightPixels;
|
||||
this.e = displayMetrics.widthPixels;
|
||||
float f = this.e;
|
||||
float f2 = this.d;
|
||||
if (f < f2) {
|
||||
this.e = f2;
|
||||
this.d = f;
|
||||
}
|
||||
this.f = this.e / 1024.0f;
|
||||
this.g = this.d / 768.0f;
|
||||
LogUtils.c("Density is " + this.b + " densityDpi is " + this.c + " height: " + this.d + " width: " + this.e);
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup
|
||||
public void addView(View view, int i, ViewGroup.LayoutParams layoutParams) {
|
||||
if (view instanceof TextView) {
|
||||
TextView textView = (TextView) view;
|
||||
textView.setTextSize(0, textView.getTextSize() * this.g);
|
||||
}
|
||||
int paddingBottom = view.getPaddingBottom();
|
||||
int paddingTop = view.getPaddingTop();
|
||||
int paddingLeft = view.getPaddingLeft();
|
||||
int paddingRight = view.getPaddingRight();
|
||||
if (paddingBottom != 0 || paddingTop != 0 || paddingLeft != 0 || paddingRight != 0) {
|
||||
view.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
|
||||
}
|
||||
if (layoutParams instanceof RelativeLayout.LayoutParams) {
|
||||
RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) layoutParams;
|
||||
float f = layoutParams2.width;
|
||||
float f2 = layoutParams2.height;
|
||||
int i2 = layoutParams2.topMargin;
|
||||
int i3 = layoutParams2.leftMargin;
|
||||
int i4 = layoutParams2.bottomMargin;
|
||||
int i5 = layoutParams2.rightMargin;
|
||||
if (i2 != 0) {
|
||||
layoutParams2.topMargin = (int) ((i2 * this.g) + 0.5d);
|
||||
}
|
||||
if (i4 != 0) {
|
||||
layoutParams2.bottomMargin = (int) ((i4 * this.g) + 0.5d);
|
||||
}
|
||||
if (i3 != 0) {
|
||||
layoutParams2.leftMargin = (int) ((i3 * this.f) + 0.5d);
|
||||
}
|
||||
if (i5 != 0) {
|
||||
layoutParams2.rightMargin = (int) ((i5 * this.f) + 0.5d);
|
||||
}
|
||||
int i6 = (int) ((this.g * f2) + 0.5d);
|
||||
if (f2 > 0.0f) {
|
||||
layoutParams2.height = i6;
|
||||
}
|
||||
float f3 = f / f2;
|
||||
int i7 = (int) ((i6 * f3) + 0.5d);
|
||||
if (f > 0.0f) {
|
||||
layoutParams2.width = i7;
|
||||
}
|
||||
Log.e("XRelativeLayout Test", "childWidth=" + f + "--childHeight" + f2 + "--adapterHeight=" + i6 + "--adapterWidth=" + i7 + "aspectRatio=" + f3 + "--heightRatio=" + this.g + "---widthRatio=" + this.f);
|
||||
}
|
||||
super.addView(view, i, layoutParams);
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup, android.view.View
|
||||
public boolean dispatchTouchEvent(MotionEvent motionEvent) {
|
||||
boolean z = this.h;
|
||||
return z ? z : super.dispatchTouchEvent(motionEvent);
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup
|
||||
public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
|
||||
LogUtils.d("isIntercept==" + this.h + "ev==" + getId());
|
||||
boolean z = this.h;
|
||||
return z ? z : super.onInterceptTouchEvent(motionEvent);
|
||||
}
|
||||
|
||||
@Override // android.widget.RelativeLayout, 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);
|
||||
LogUtils.d("l==" + i + "t==" + i2 + "r==" + i3 + "b==" + i4);
|
||||
}
|
||||
|
||||
@Override // android.widget.RelativeLayout, android.view.View
|
||||
protected void onMeasure(int i, int i2) {
|
||||
if (getLayoutParams() instanceof FrameLayout.LayoutParams) {
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) getLayoutParams();
|
||||
int i3 = layoutParams.width;
|
||||
int i4 = layoutParams.height;
|
||||
}
|
||||
super.onMeasure(i, i2);
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public boolean onTouchEvent(MotionEvent motionEvent) {
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
|
||||
public void setIntercept(boolean z) {
|
||||
LogUtils.d("setIntercept==" + z);
|
||||
this.h = z;
|
||||
}
|
||||
|
||||
@Override // android.widget.RelativeLayout, android.view.ViewGroup
|
||||
public RelativeLayout.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
|
||||
return new AutoLayoutParams(this, this.a, attributeSet);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user