what-the-bank/sources/o/C10314eAj.java

76 lines
2.8 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package o;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.text.style.ImageSpan;
import java.lang.ref.WeakReference;
/* renamed from: o.eAj, reason: case insensitive filesystem */
/* loaded from: classes5.dex */
public final class C10314eAj extends ImageSpan {
private WeakReference<Drawable> a;
private int b;
private int d;
public C10314eAj(Drawable drawable) {
this(drawable, 0);
}
public C10314eAj(Drawable drawable, int i) {
super(drawable);
this.b = 0;
this.a = new WeakReference<>(drawable);
this.d = i;
}
@Override // android.text.style.DynamicDrawableSpan, android.text.style.ReplacementSpan
public final int getSize(Paint paint, CharSequence charSequence, int i, int i2, Paint.FontMetricsInt fontMetricsInt) {
Drawable aod_ = aod_();
if (aod_ == null) {
return 0;
}
Paint.FontMetricsInt fontMetricsInt2 = paint.getFontMetricsInt();
Rect bounds = aod_.getBounds();
if (fontMetricsInt != null) {
if (bounds.bottom - (fontMetricsInt2.descent - fontMetricsInt2.ascent) >= 0) {
this.b = bounds.bottom - (fontMetricsInt2.descent - fontMetricsInt2.ascent);
}
fontMetricsInt.descent = (this.b / 2) + fontMetricsInt2.descent;
fontMetricsInt.bottom = fontMetricsInt2.descent;
fontMetricsInt.ascent = fontMetricsInt2.descent - bounds.bottom;
fontMetricsInt.top = fontMetricsInt2.ascent;
}
return bounds.right + this.d;
}
@Override // android.text.style.DynamicDrawableSpan, android.text.style.ReplacementSpan
public final void draw(Canvas canvas, CharSequence charSequence, int i, int i2, float f, int i3, int i4, int i5, Paint paint) {
Drawable aod_ = aod_();
canvas.save();
int intrinsicHeight = aod_.getIntrinsicHeight();
int height = canvas.getHeight();
int i6 = paint.getFontMetricsInt().ascent;
int i7 = paint.getFontMetricsInt().descent;
if (intrinsicHeight > height) {
aod_.setBounds(0, 0, (int) (aod_.getIntrinsicWidth() * (height / intrinsicHeight)), height);
intrinsicHeight = height;
}
canvas.translate(f, (i5 - aod_.getBounds().bottom) + (((intrinsicHeight - i7) + i6) / 2));
aod_.draw(canvas);
canvas.restore();
}
private Drawable aod_() {
WeakReference<Drawable> weakReference = this.a;
Drawable drawable = weakReference != null ? weakReference.get() : null;
if (drawable != null) {
return drawable;
}
Drawable drawable2 = getDrawable();
this.a = new WeakReference<>(drawable2);
return drawable2;
}
}