导航菜单

页面标题

页面副标题

爱心e站 v1.0.0 - EnvDrawText.java 源代码

正在查看: 爱心e站 v1.0.0 应用的 EnvDrawText.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package mapsdkvi.com.gdi.bgl.android.java;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.text.Layout;
import android.text.TextPaint;
import android.util.SparseArray;
import com.baidu.mapapi.common.SysOSUtil;
import lecho.lib.hellocharts.model.ColumnChartData;

public class EnvDrawText {
    private static final String a = EnvDrawText.class.getSimpleName();
    public static boolean bBmpChange = false;
    public static Bitmap bmp = null;
    public static int[] buffer = null;
    public static SparseArray<a> fontCache = null;

    public static synchronized int[] drawText(java.lang.String r19, int r20, int r21, int[] r22, int r23, int r24, int r25, int r26, int r27) {
        throw new UnsupportedOperationException("Method not decompiled: mapsdkvi.com.gdi.bgl.android.java.EnvDrawText.drawText(java.lang.String, int, int, int[], int, int, int, int, int):int[]");
    }

    public static Bitmap drawTextAlpha(String str, int i, int i2, int i3) {
        int desiredWidth;
        Bitmap bitmap = null;
        Canvas canvas = new Canvas();
        TextPaint textPaint = new TextPaint();
        if (canvas == null || textPaint == null) {
            return null;
        }
        String phoneType = SysOSUtil.getPhoneType();
        if (phoneType != null && phoneType.equals("vivo X3L")) {
            i2 = 0;
        }
        textPaint.reset();
        textPaint.setSubpixelText(false);
        textPaint.setAntiAlias(false);
        textPaint.setTextSize(i);
        switch (i2) {
            case 1:
                textPaint.setTypeface(Typeface.create(Typeface.DEFAULT, 1));
                break;
            case 2:
                textPaint.setTypeface(Typeface.create(Typeface.DEFAULT, 2));
                break;
            default:
                textPaint.setTypeface(Typeface.create(Typeface.DEFAULT, 0));
                break;
        }
        float f = (i3 * 1.3f) + 0.5f;
        int indexOf = str.indexOf(92, 0);
        if (indexOf == -1) {
            Paint.FontMetrics fontMetrics = textPaint.getFontMetrics();
            int desiredWidth2 = (int) (Layout.getDesiredWidth(str, 0, str.length(), textPaint) + f);
            int ceil = (int) Math.ceil(fontMetrics.descent - fontMetrics.ascent);
            if (desiredWidth2 > 0 && ceil > 0) {
                bitmap = Bitmap.createBitmap(desiredWidth2, ceil, Bitmap.Config.ALPHA_8);
                if (bitmap == null) {
                    return bitmap;
                }
                bitmap.eraseColor(0);
                canvas.setBitmap(bitmap);
            }
            textPaint.setStyle(Paint.Style.FILL);
            canvas.drawText(str, 0.5f * f, ColumnChartData.DEFAULT_BASE_VALUE - fontMetrics.ascent, textPaint);
            return bitmap;
        }
        int i4 = indexOf + 1;
        int i5 = 2;
        int desiredWidth3 = (int) (Layout.getDesiredWidth(str.substring(0, indexOf), textPaint) + 0.5d);
        while (true) {
            int indexOf2 = str.indexOf(92, i4);
            if (indexOf2 > 0) {
                int desiredWidth4 = (int) (Layout.getDesiredWidth(str.substring(i4, indexOf2), textPaint) + 0.5d);
                if (desiredWidth4 > desiredWidth3) {
                    desiredWidth3 = desiredWidth4;
                }
                i4 = indexOf2 + 1;
                i5++;
            } else {
                if (i4 != str.length() && (desiredWidth = (int) (Layout.getDesiredWidth(str.substring(i4, str.length()), textPaint) + 0.5d)) > desiredWidth3) {
                    desiredWidth3 = desiredWidth;
                }
                Paint.FontMetrics fontMetrics2 = textPaint.getFontMetrics();
                int i6 = desiredWidth3 + i3;
                int ceil2 = i5 * ((int) Math.ceil(fontMetrics2.descent - fontMetrics2.ascent));
                if (i6 > 0 && ceil2 > 0) {
                    bitmap = Bitmap.createBitmap(i6, ceil2, Bitmap.Config.ALPHA_8);
                    if (bitmap == null) {
                        return bitmap;
                    }
                    bitmap.eraseColor(0);
                    canvas.setBitmap(bitmap);
                }
                textPaint.setTextAlign(getTextAlignedType(3));
                float f2 = i6 - (0.5f * f);
                int i7 = 0;
                int i8 = 0;
                while (true) {
                    int indexOf3 = str.indexOf(92, i7);
                    if (indexOf3 <= 0) {
                        if (i7 == str.length()) {
                            return bitmap;
                        }
                        String substring = str.substring(i7, str.length());
                        textPaint.setStyle(Paint.Style.FILL);
                        if (canvas == null) {
                            return bitmap;
                        }
                        canvas.drawText(substring, f2, (i8 * r10) - fontMetrics2.ascent, textPaint);
                        return bitmap;
                    }
                    String substring2 = str.substring(i7, indexOf3);
                    i7 = indexOf3 + 1;
                    textPaint.setStyle(Paint.Style.FILL);
                    if (canvas != null) {
                        canvas.drawText(substring2, f2, (i8 * r10) - fontMetrics2.ascent, textPaint);
                    }
                    i8++;
                }
            }
        }
    }

    public static synchronized Bitmap drawTextExt(String str, int i, int i2, int[] iArr, int i3, int i4, int i5, int i6, int i7) {
        Bitmap bitmap;
        Bitmap bitmap2;
        int desiredWidth;
        synchronized (EnvDrawText.class) {
            int i8 = 0;
            int i9 = 0;
            Canvas canvas = new Canvas();
            TextPaint textPaint = new TextPaint();
            if (canvas == null || textPaint == null) {
                bitmap = null;
            } else {
                String phoneType = SysOSUtil.getPhoneType();
                if (phoneType != null && phoneType.equals("vivo X3L")) {
                    i2 = 0;
                }
                textPaint.reset();
                textPaint.setSubpixelText(true);
                textPaint.setAntiAlias(true);
                textPaint.setTextSize(i);
                textPaint.setShadowLayer(ColumnChartData.DEFAULT_BASE_VALUE, ColumnChartData.DEFAULT_BASE_VALUE, ColumnChartData.DEFAULT_BASE_VALUE, 0);
                switch (i2) {
                    case 1:
                        textPaint.setTypeface(Typeface.create(Typeface.DEFAULT, 1));
                        break;
                    case 2:
                        textPaint.setTypeface(Typeface.create(Typeface.DEFAULT, 2));
                        break;
                    default:
                        textPaint.setTypeface(Typeface.create(Typeface.DEFAULT, 0));
                        break;
                }
                if (i6 != 0) {
                    textPaint.setStrokeWidth(i6);
                    textPaint.setStrokeCap(Paint.Cap.ROUND);
                    textPaint.setStrokeJoin(Paint.Join.ROUND);
                    textPaint.setStyle(Paint.Style.STROKE);
                }
                int indexOf = str.indexOf(92, 0);
                if (indexOf == -1) {
                    Paint.FontMetrics fontMetrics = textPaint.getFontMetrics();
                    int desiredWidth2 = (int) (Layout.getDesiredWidth(str, 0, str.length(), textPaint) + 0.5d);
                    int ceil = (int) Math.ceil(fontMetrics.descent - fontMetrics.ascent);
                    iArr[0] = desiredWidth2;
                    iArr[1] = ceil;
                    if (iArr.length == 4) {
                        desiredWidth2 = (int) Math.pow(2.0d, (int) Math.ceil(Math.log(desiredWidth2) / Math.log(2.0d)));
                        ceil = (int) Math.pow(2.0d, (int) Math.ceil(Math.log(ceil) / Math.log(2.0d)));
                    }
                    if (0 != desiredWidth2 || 0 != ceil) {
                        i9 = ceil;
                        i8 = desiredWidth2;
                    }
                    if (iArr.length == 4) {
                        iArr[2] = i8;
                        iArr[3] = i9;
                    }
                    if (i8 <= 0 || i9 <= 0) {
                        bitmap = null;
                    } else {
                        bitmap = Bitmap.createBitmap(i8, i9, Bitmap.Config.ARGB_8888);
                        if (bitmap != null) {
                            canvas.setBitmap(bitmap);
                        }
                    }
                    if (((-16777216) & i5) == 0) {
                        canvas.drawColor(16777215);
                    } else {
                        canvas.drawColor(i5);
                    }
                    if (i6 != 0 && canvas != null) {
                        textPaint.setStrokeWidth(i6);
                        textPaint.setStrokeCap(Paint.Cap.ROUND);
                        textPaint.setStrokeJoin(Paint.Join.ROUND);
                        textPaint.setStyle(Paint.Style.STROKE);
                        textPaint.setColor(i4);
                        canvas.drawText(str, ColumnChartData.DEFAULT_BASE_VALUE, ColumnChartData.DEFAULT_BASE_VALUE - fontMetrics.ascent, textPaint);
                    }
                    textPaint.setStyle(Paint.Style.FILL);
                    textPaint.setColor(i3);
                    canvas.drawText(str, ColumnChartData.DEFAULT_BASE_VALUE, ColumnChartData.DEFAULT_BASE_VALUE - fontMetrics.ascent, textPaint);
                } else {
                    int i10 = indexOf + 1;
                    int desiredWidth3 = (int) (Layout.getDesiredWidth(str.substring(0, indexOf), textPaint) + 0.5d);
                    int i11 = i10;
                    int i12 = 2;
                    while (true) {
                        int indexOf2 = str.indexOf(92, i11);
                        if (indexOf2 > 0) {
                            int desiredWidth4 = (int) (Layout.getDesiredWidth(str.substring(i11, indexOf2), textPaint) + 0.5d);
                            if (desiredWidth4 <= desiredWidth3) {
                                desiredWidth4 = desiredWidth3;
                            }
                            i12++;
                            desiredWidth3 = desiredWidth4;
                            i11 = indexOf2 + 1;
                        } else {
                            if (i11 != str.length() && (desiredWidth = (int) (Layout.getDesiredWidth(str.substring(i11, str.length()), textPaint) + 0.5d)) > desiredWidth3) {
                                desiredWidth3 = desiredWidth;
                            }
                            Paint.FontMetrics fontMetrics2 = textPaint.getFontMetrics();
                            int ceil2 = ((int) Math.ceil(fontMetrics2.descent - fontMetrics2.ascent)) * i12;
                            iArr[0] = desiredWidth3;
                            iArr[1] = ceil2;
                            if (iArr.length == 4) {
                                desiredWidth3 = (int) Math.pow(2.0d, (int) Math.ceil(Math.log(desiredWidth3) / Math.log(2.0d)));
                                ceil2 = (int) Math.pow(2.0d, (int) Math.ceil(Math.log(ceil2) / Math.log(2.0d)));
                            }
                            if (0 == desiredWidth3 && 0 == ceil2) {
                                ceil2 = 0;
                                desiredWidth3 = 0;
                            }
                            if (iArr.length == 4) {
                                iArr[2] = desiredWidth3;
                                iArr[3] = ceil2;
                            }
                            if (desiredWidth3 <= 0 || ceil2 <= 0) {
                                bitmap2 = null;
                            } else {
                                bitmap = Bitmap.createBitmap(desiredWidth3, ceil2, Bitmap.Config.ARGB_8888);
                                if (bitmap != null) {
                                    canvas.setBitmap(bitmap);
                                    bitmap2 = bitmap;
                                }
                            }
                            if (((-16777216) & i5) == 0) {
                                canvas.drawColor(16777215);
                            } else {
                                canvas.drawColor(i5);
                            }
                            textPaint.setTextAlign(getTextAlignedType(i7));
                            int i13 = i7 == 1 ? 0 : i7 == 2 ? iArr[0] : iArr[0] / 2;
                            int i14 = 0;
                            int i15 = 0;
                            while (true) {
                                int indexOf3 = str.indexOf(92, i14);
                                if (indexOf3 > 0) {
                                    String substring = str.substring(i14, indexOf3);
                                    i14 = indexOf3 + 1;
                                    if (i6 != 0 && canvas != null) {
                                        textPaint.setStrokeWidth(i6);
                                        textPaint.setStrokeCap(Paint.Cap.ROUND);
                                        textPaint.setStrokeJoin(Paint.Join.ROUND);
                                        textPaint.setStyle(Paint.Style.STROKE);
                                        textPaint.setColor(i4);
                                        canvas.drawText(substring, i13, (i15 * r12) - fontMetrics2.ascent, textPaint);
                                    }
                                    textPaint.setStyle(Paint.Style.FILL);
                                    textPaint.setColor(i3);
                                    if (canvas != null) {
                                        canvas.drawText(substring, i13, (i15 * r12) - fontMetrics2.ascent, textPaint);
                                    }
                                    i15++;
                                } else {
                                    if (i14 != str.length()) {
                                        String substring2 = str.substring(i14, str.length());
                                        if (i6 != 0 && canvas != null) {
                                            textPaint.setStrokeWidth(i6);
                                            textPaint.setStrokeCap(Paint.Cap.ROUND);
                                            textPaint.setStrokeJoin(Paint.Join.ROUND);
                                            textPaint.setStyle(Paint.Style.STROKE);
                                            textPaint.setColor(i4);
                                            canvas.drawText(substring2, i13, (i15 * r12) - fontMetrics2.ascent, textPaint);
                                        }
                                        textPaint.setStyle(Paint.Style.FILL);
                                        textPaint.setColor(i3);
                                        if (canvas != null) {
                                            canvas.drawText(substring2, i13, (i15 * r12) - fontMetrics2.ascent, textPaint);
                                        }
                                    }
                                    bitmap = bitmap2;
                                }
                            }
                        }
                    }
                }
            }
        }
        return bitmap;
    }

    private static Paint.Align getTextAlignedType(int i) {
        return 1 == i ? Paint.Align.LEFT : 2 == i ? Paint.Align.RIGHT : Paint.Align.CENTER;
    }

    public static short[] getTextSize(String str, int i, int i2) {
        int length = str.length();
        if (length == 0) {
            return null;
        }
        TextPaint textPaint = new TextPaint();
        textPaint.setSubpixelText(true);
        textPaint.setAntiAlias(true);
        textPaint.setTextSize(i);
        switch (i2) {
            case 1:
                textPaint.setTypeface(Typeface.create(Typeface.DEFAULT, 1));
                break;
            case 2:
                textPaint.setTypeface(Typeface.create(Typeface.DEFAULT, 2));
                break;
            default:
                textPaint.setTypeface(Typeface.create(Typeface.DEFAULT, 0));
                break;
        }
        short[] sArr = new short[length];
        for (int i3 = 0; i3 < length; i3++) {
            sArr[i3] = (short) (Layout.getDesiredWidth(str, 0, i3 + 1, textPaint) + 0.5d);
        }
        return sArr;
    }

    public static float[] getTextSizeExt(String str, int i, int i2) {
        if (str.length() == 0) {
            return null;
        }
        Paint paint = new Paint();
        paint.setSubpixelText(true);
        paint.setAntiAlias(true);
        paint.setTextSize(i);
        switch (i2) {
            case 1:
                paint.setTypeface(Typeface.create(Typeface.DEFAULT, 1));
                break;
            case 2:
                paint.setTypeface(Typeface.create(Typeface.DEFAULT, 2));
                break;
            default:
                paint.setTypeface(Typeface.create(Typeface.DEFAULT, 0));
                break;
        }
        return new float[]{paint.measureText(str), paint.descent() - paint.ascent()};
    }

    public static synchronized void registFontCache(int i, Typeface typeface) {
        synchronized (EnvDrawText.class) {
            if (i != 0 && typeface != null) {
                if (fontCache == null) {
                    fontCache = new SparseArray<>();
                }
                a aVar = fontCache.get(i);
                if (aVar == null) {
                    a aVar2 = new a();
                    aVar2.a = typeface;
                    aVar2.b++;
                    fontCache.put(i, aVar2);
                } else {
                    aVar.b++;
                }
            }
        }
    }

    public static synchronized void removeFontCache(int i) {
        synchronized (EnvDrawText.class) {
            a aVar = fontCache.get(i);
            if (aVar != null) {
                aVar.b--;
                if (aVar.b == 0) {
                    fontCache.remove(i);
                }
            }
        }
    }
}