what-the-bank/sources/com/scb/phone/view/custom/ScbRotateLayout.java

130 lines
5.1 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.scb.phone.view.custom;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import o.AQw;
import org.bouncycastle.crypto.tls.CipherSuite;
/* loaded from: classes5.dex */
public class ScbRotateLayout extends ViewGroup {
private final Matrix a;
private int b;
private final float[] c;
private boolean d;
private final RectF e;
private final float[] g;
private final Rect h;
private final RectF j;
public ScbRotateLayout(Context context) {
this(context, null);
}
public ScbRotateLayout(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public ScbRotateLayout(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet);
this.a = new Matrix();
this.h = new Rect();
this.e = new RectF();
this.j = new RectF();
this.g = new float[2];
this.c = new float[2];
this.d = true;
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, AQw.Sts.RotateLayout);
this.b = obtainStyledAttributes.getInt(0, 0);
obtainStyledAttributes.recycle();
setWillNotDraw(false);
}
public void setAngle(int i) {
if (this.b != i) {
this.b = i;
this.d = true;
requestLayout();
invalidate();
}
}
@Override // android.view.ViewGroup, android.view.View
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
int i5 = i3 - i;
int i6 = i4 - i2;
if (this.d || z) {
RectF rectF = this.e;
rectF.set(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, i5, i6);
RectF rectF2 = this.j;
this.a.setRotate(this.b, rectF.centerX(), rectF.centerY());
this.a.mapRect(rectF2, rectF);
rectF2.round(this.h);
this.d = false;
}
View childAt = getChildCount() > 0 ? getChildAt(0) : null;
if (childAt != null) {
int measuredWidth = (i5 - childAt.getMeasuredWidth()) / 2;
int measuredHeight = (i6 - childAt.getMeasuredHeight()) / 2;
childAt.layout(measuredWidth, measuredHeight, childAt.getMeasuredWidth() + measuredWidth, childAt.getMeasuredHeight() + measuredHeight);
}
}
@Override // android.view.ViewGroup, android.view.View
protected void dispatchDraw(Canvas canvas) {
canvas.save();
canvas.rotate(-this.b, getWidth() / 2.0f, getHeight() / 2.0f);
super.dispatchDraw(canvas);
canvas.restore();
}
@Override // android.view.ViewGroup, android.view.ViewParent
public ViewParent invalidateChildInParent(int[] iArr, Rect rect) {
invalidate();
return super.invalidateChildInParent(iArr, rect);
}
@Override // android.view.ViewGroup, android.view.View
public boolean dispatchTouchEvent(MotionEvent motionEvent) {
this.g[0] = motionEvent.getX();
this.g[1] = motionEvent.getY();
this.a.mapPoints(this.c, this.g);
float[] fArr = this.c;
motionEvent.setLocation(fArr[0], fArr[1]);
boolean dispatchTouchEvent = super.dispatchTouchEvent(motionEvent);
float[] fArr2 = this.g;
motionEvent.setLocation(fArr2[0], fArr2[1]);
return dispatchTouchEvent;
}
@Override // android.view.View
protected void onMeasure(int i, int i2) {
View childAt = getChildCount() > 0 ? getChildAt(0) : null;
if (childAt != null) {
if (Math.abs(this.b % CipherSuite.TLS_DHE_PSK_WITH_NULL_SHA256) == 90) {
measureChild(childAt, i2, i);
setMeasuredDimension(resolveSize(childAt.getMeasuredHeight(), i), resolveSize(childAt.getMeasuredWidth(), i2));
return;
} else if (Math.abs(this.b % CipherSuite.TLS_DHE_PSK_WITH_NULL_SHA256) == 0) {
measureChild(childAt, i, i2);
setMeasuredDimension(resolveSize(childAt.getMeasuredWidth(), i), resolveSize(childAt.getMeasuredHeight(), i2));
return;
} else {
measureChild(childAt, View.MeasureSpec.makeMeasureSpec(0, 0), View.MeasureSpec.makeMeasureSpec(0, 0));
setMeasuredDimension(resolveSize((int) Math.ceil((childAt.getMeasuredWidth() * Math.abs(Math.cos((this.b * 6.283185307179586d) / 360.0d))) + (childAt.getMeasuredHeight() * Math.abs(Math.sin((this.b * 6.283185307179586d) / 360.0d)))), i), resolveSize((int) Math.ceil((childAt.getMeasuredWidth() * Math.abs(Math.sin((this.b * 6.283185307179586d) / 360.0d))) + (childAt.getMeasuredHeight() * Math.abs(Math.cos((this.b * 6.283185307179586d) / 360.0d)))), i2));
return;
}
}
super.onMeasure(i, i2);
}
}