正在查看: 新暖心缘 v8.1.1 应用的 MagicTextView.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 新暖心缘 v8.1.1 应用的 MagicTextView.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.luanxingyuan.app.gift;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BlurMaskFilter;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.util.Pair;
import androidx.appcompat.widget.b0;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.WeakHashMap;
public class MagicTextView extends b0 {
private ArrayList<a> f8231a;
private ArrayList<a> f8232b;
private WeakHashMap<String, Pair<Canvas, Bitmap>> f8233c;
private Canvas f8234d;
private Bitmap f8235e;
private Drawable f8236f;
private float f8237g;
private Integer f8238h;
private Paint.Join f8239i;
private float f8240j;
private int[] f8241k;
private boolean f8242l;
public static class a {
float f8243a;
float f8244b;
float f8245c;
int f8246d;
public a(float f8, float f9, float f10, int i8) {
this.f8243a = f8;
this.f8244b = f9;
this.f8245c = f10;
this.f8246d = i8;
}
}
public MagicTextView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.f8242l = false;
i(attributeSet);
}
private void h() {
String format = String.format("%dx%d", Integer.valueOf(getWidth()), Integer.valueOf(getHeight()));
Pair<Canvas, Bitmap> pair = this.f8233c.get(format);
if (pair != null) {
this.f8234d = (Canvas) pair.first;
this.f8235e = (Bitmap) pair.second;
return;
}
this.f8234d = new Canvas();
Bitmap createBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
this.f8235e = createBitmap;
this.f8234d.setBitmap(createBitmap);
this.f8233c.put(format, new Pair<>(this.f8234d, this.f8235e));
}
public void e(float f8, float f9, float f10, int i8) {
if (f8 == 0.0f) {
f8 = 1.0E-4f;
}
this.f8232b.add(new a(f8, f9, f10, i8));
}
public void f(float f8, float f9, float f10, int i8) {
if (f8 == 0.0f) {
f8 = 1.0E-4f;
}
this.f8231a.add(new a(f8, f9, f10, i8));
}
public void g() {
this.f8241k = new int[]{getCompoundPaddingLeft(), getCompoundPaddingRight(), getCompoundPaddingTop(), getCompoundPaddingBottom()};
this.f8242l = true;
}
@Override
public int getCompoundPaddingBottom() {
return !this.f8242l ? super.getCompoundPaddingBottom() : this.f8241k[3];
}
@Override
public int getCompoundPaddingLeft() {
return !this.f8242l ? super.getCompoundPaddingLeft() : this.f8241k[0];
}
@Override
public int getCompoundPaddingRight() {
return !this.f8242l ? super.getCompoundPaddingRight() : this.f8241k[1];
}
@Override
public int getCompoundPaddingTop() {
return !this.f8242l ? super.getCompoundPaddingTop() : this.f8241k[2];
}
@Override
public Drawable getForeground() {
Drawable drawable = this.f8236f;
return drawable == null ? drawable : new ColorDrawable(getCurrentTextColor());
}
public void i(AttributeSet attributeSet) {
this.f8231a = new ArrayList<>();
this.f8232b = new ArrayList<>();
if (this.f8233c == null) {
this.f8233c = new WeakHashMap<>();
}
if (attributeSet != null) {
TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attributeSet, j6.a.f13883n0);
String string = obtainStyledAttributes.getString(13);
if (string != null) {
setTypeface(Typeface.createFromAsset(getContext().getAssets(), String.format("fonts/%s.ttf", string)));
}
if (obtainStyledAttributes.hasValue(0)) {
Drawable drawable = obtainStyledAttributes.getDrawable(0);
if (drawable != null) {
setForegroundDrawable(drawable);
} else {
setTextColor(obtainStyledAttributes.getColor(0, -16777216));
}
}
if (obtainStyledAttributes.hasValue(1)) {
e(obtainStyledAttributes.getFloat(4, 0.0f), obtainStyledAttributes.getFloat(2, 0.0f), obtainStyledAttributes.getFloat(3, 0.0f), obtainStyledAttributes.getColor(1, -16777216));
}
if (obtainStyledAttributes.hasValue(5)) {
f(obtainStyledAttributes.getFloat(8, 0.0f), obtainStyledAttributes.getFloat(6, 0.0f), obtainStyledAttributes.getFloat(7, 0.0f), obtainStyledAttributes.getColor(5, -16777216));
}
if (obtainStyledAttributes.hasValue(9)) {
float f8 = obtainStyledAttributes.getFloat(12, 1.0f);
int color = obtainStyledAttributes.getColor(9, -16777216);
float f9 = obtainStyledAttributes.getFloat(11, 10.0f);
int i8 = obtainStyledAttributes.getInt(10, 0);
if (i8 == 0) {
this.f8239i = Paint.Join.MITER;
} else if (i8 == 1) {
this.f8239i = Paint.Join.BEVEL;
} else if (i8 == 2) {
this.f8239i = Paint.Join.ROUND;
}
j(f8, color, this.f8239i, f9);
}
}
}
@Override
public void invalidate() {
if (this.f8242l) {
return;
}
super.invalidate();
}
public void j(float f8, int i8, Paint.Join join, float f9) {
this.f8237g = f8;
this.f8238h = Integer.valueOf(i8);
this.f8239i = join;
this.f8240j = f9;
}
public void k() {
this.f8242l = false;
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
g();
Drawable background = getBackground();
Drawable[] compoundDrawables = getCompoundDrawables();
int currentTextColor = getCurrentTextColor();
setCompoundDrawables(null, null, null, null);
Iterator<a> it = this.f8231a.iterator();
while (it.hasNext()) {
a next = it.next();
setShadowLayer(next.f8243a, next.f8244b, next.f8245c, next.f8246d);
super.onDraw(canvas);
}
setShadowLayer(0.0f, 0.0f, 0.0f, 0);
setTextColor(currentTextColor);
Drawable drawable = this.f8236f;
if (drawable != null && (drawable instanceof BitmapDrawable)) {
h();
super.onDraw(this.f8234d);
((BitmapDrawable) this.f8236f).getPaint().setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
this.f8236f.setBounds(canvas.getClipBounds());
this.f8236f.draw(this.f8234d);
canvas.drawBitmap(this.f8235e, 0.0f, 0.0f, (Paint) null);
this.f8234d.drawColor(0, PorterDuff.Mode.CLEAR);
}
if (this.f8238h != null) {
TextPaint paint = getPaint();
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeJoin(this.f8239i);
paint.setStrokeMiter(this.f8240j);
setTextColor(this.f8238h.intValue());
paint.setStrokeWidth(this.f8237g);
super.onDraw(canvas);
paint.setStyle(Paint.Style.FILL);
setTextColor(currentTextColor);
}
if (this.f8232b.size() > 0) {
h();
TextPaint paint2 = getPaint();
Iterator<a> it2 = this.f8232b.iterator();
while (it2.hasNext()) {
a next2 = it2.next();
setTextColor(next2.f8246d);
super.onDraw(this.f8234d);
setTextColor(-16777216);
paint2.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
paint2.setMaskFilter(new BlurMaskFilter(next2.f8243a, BlurMaskFilter.Blur.NORMAL));
this.f8234d.save();
this.f8234d.translate(next2.f8244b, next2.f8245c);
super.onDraw(this.f8234d);
this.f8234d.restore();
canvas.drawBitmap(this.f8235e, 0.0f, 0.0f, (Paint) null);
this.f8234d.drawColor(0, PorterDuff.Mode.CLEAR);
paint2.setXfermode(null);
paint2.setMaskFilter(null);
setTextColor(currentTextColor);
setShadowLayer(0.0f, 0.0f, 0.0f, 0);
}
}
if (compoundDrawables != null) {
setCompoundDrawablesWithIntrinsicBounds(compoundDrawables[0], compoundDrawables[1], compoundDrawables[2], compoundDrawables[3]);
}
setBackgroundDrawable(background);
setTextColor(currentTextColor);
k();
}
@Override
public void postInvalidate() {
if (this.f8242l) {
return;
}
super.postInvalidate();
}
@Override
public void requestLayout() {
if (this.f8242l) {
return;
}
super.requestLayout();
}
public void setForegroundDrawable(Drawable drawable) {
this.f8236f = drawable;
}
@Override
public void invalidate(Rect rect) {
if (this.f8242l) {
return;
}
super.invalidate(rect);
}
@Override
public void postInvalidate(int i8, int i9, int i10, int i11) {
if (this.f8242l) {
return;
}
super.postInvalidate(i8, i9, i10, i11);
}
@Override
public void invalidate(int i8, int i9, int i10, int i11) {
if (this.f8242l) {
return;
}
super.invalidate(i8, i9, i10, i11);
}
}