591 lines
27 KiB
Java
591 lines
27 KiB
Java
|
package com.airbnb.lottie.model.layer;
|
||
|
|
||
|
import android.graphics.Canvas;
|
||
|
import android.graphics.Matrix;
|
||
|
import android.graphics.Paint;
|
||
|
import android.graphics.Path;
|
||
|
import android.graphics.RectF;
|
||
|
import android.graphics.Typeface;
|
||
|
import com.airbnb.lottie.LottieComposition;
|
||
|
import com.airbnb.lottie.LottieDrawable;
|
||
|
import com.airbnb.lottie.LottieProperty;
|
||
|
import com.airbnb.lottie.animation.content.ContentGroup;
|
||
|
import com.airbnb.lottie.animation.keyframe.BaseKeyframeAnimation;
|
||
|
import com.airbnb.lottie.animation.keyframe.TextKeyframeAnimation;
|
||
|
import com.airbnb.lottie.animation.keyframe.ValueCallbackKeyframeAnimation;
|
||
|
import com.airbnb.lottie.model.DocumentData;
|
||
|
import com.airbnb.lottie.model.Font;
|
||
|
import com.airbnb.lottie.model.FontCharacter;
|
||
|
import com.airbnb.lottie.model.animatable.AnimatableTextProperties;
|
||
|
import com.airbnb.lottie.model.content.ShapeGroup;
|
||
|
import com.airbnb.lottie.utils.Utils;
|
||
|
import com.airbnb.lottie.value.LottieValueCallback;
|
||
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Arrays;
|
||
|
import java.util.HashMap;
|
||
|
import java.util.List;
|
||
|
import java.util.Map;
|
||
|
import o.C0667Ltg;
|
||
|
|
||
|
/* loaded from: classes.dex */
|
||
|
public class TextLayer extends BaseLayer {
|
||
|
private final C0667Ltg<String> codePointCache;
|
||
|
private BaseKeyframeAnimation<Integer, Integer> colorAnimation;
|
||
|
private BaseKeyframeAnimation<Integer, Integer> colorCallbackAnimation;
|
||
|
private final LottieComposition composition;
|
||
|
private final Map<FontCharacter, List<ContentGroup>> contentsForCharacter;
|
||
|
private final Paint fillPaint;
|
||
|
private final LottieDrawable lottieDrawable;
|
||
|
private final Matrix matrix;
|
||
|
private final RectF rectF;
|
||
|
private final StringBuilder stringBuilder;
|
||
|
private BaseKeyframeAnimation<Integer, Integer> strokeColorAnimation;
|
||
|
private BaseKeyframeAnimation<Integer, Integer> strokeColorCallbackAnimation;
|
||
|
private final Paint strokePaint;
|
||
|
private BaseKeyframeAnimation<Float, Float> strokeWidthAnimation;
|
||
|
private BaseKeyframeAnimation<Float, Float> strokeWidthCallbackAnimation;
|
||
|
private final TextKeyframeAnimation textAnimation;
|
||
|
private BaseKeyframeAnimation<Float, Float> textSizeCallbackAnimation;
|
||
|
private BaseKeyframeAnimation<Float, Float> trackingAnimation;
|
||
|
private BaseKeyframeAnimation<Float, Float> trackingCallbackAnimation;
|
||
|
private BaseKeyframeAnimation<Typeface, Typeface> typefaceCallbackAnimation;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public TextLayer(LottieDrawable lottieDrawable, Layer layer) {
|
||
|
super(lottieDrawable, layer);
|
||
|
this.stringBuilder = new StringBuilder(2);
|
||
|
this.rectF = new RectF();
|
||
|
this.matrix = new Matrix();
|
||
|
int i = 1;
|
||
|
this.fillPaint = new Paint(this, i) { // from class: com.airbnb.lottie.model.layer.TextLayer.1
|
||
|
final TextLayer this$0;
|
||
|
|
||
|
{
|
||
|
this.this$0 = this;
|
||
|
setStyle(Paint.Style.FILL);
|
||
|
}
|
||
|
};
|
||
|
this.strokePaint = new Paint(this, i) { // from class: com.airbnb.lottie.model.layer.TextLayer.2
|
||
|
final TextLayer this$0;
|
||
|
|
||
|
{
|
||
|
this.this$0 = this;
|
||
|
setStyle(Paint.Style.STROKE);
|
||
|
}
|
||
|
};
|
||
|
this.contentsForCharacter = new HashMap();
|
||
|
this.codePointCache = new C0667Ltg<>();
|
||
|
this.lottieDrawable = lottieDrawable;
|
||
|
this.composition = layer.getComposition();
|
||
|
TextKeyframeAnimation createAnimation = layer.getText().createAnimation();
|
||
|
this.textAnimation = createAnimation;
|
||
|
createAnimation.addUpdateListener(this);
|
||
|
addAnimation(createAnimation);
|
||
|
AnimatableTextProperties textProperties = layer.getTextProperties();
|
||
|
if (textProperties != null && textProperties.color != null) {
|
||
|
BaseKeyframeAnimation<Integer, Integer> createAnimation2 = textProperties.color.createAnimation();
|
||
|
this.colorAnimation = createAnimation2;
|
||
|
createAnimation2.addUpdateListener(this);
|
||
|
addAnimation(this.colorAnimation);
|
||
|
}
|
||
|
if (textProperties != null && textProperties.stroke != null) {
|
||
|
BaseKeyframeAnimation<Integer, Integer> createAnimation3 = textProperties.stroke.createAnimation();
|
||
|
this.strokeColorAnimation = createAnimation3;
|
||
|
createAnimation3.addUpdateListener(this);
|
||
|
addAnimation(this.strokeColorAnimation);
|
||
|
}
|
||
|
if (textProperties != null && textProperties.strokeWidth != null) {
|
||
|
BaseKeyframeAnimation<Float, Float> createAnimation4 = textProperties.strokeWidth.createAnimation();
|
||
|
this.strokeWidthAnimation = createAnimation4;
|
||
|
createAnimation4.addUpdateListener(this);
|
||
|
addAnimation(this.strokeWidthAnimation);
|
||
|
}
|
||
|
if (textProperties == null || textProperties.tracking == null) {
|
||
|
return;
|
||
|
}
|
||
|
BaseKeyframeAnimation<Float, Float> createAnimation5 = textProperties.tracking.createAnimation();
|
||
|
this.trackingAnimation = createAnimation5;
|
||
|
createAnimation5.addUpdateListener(this);
|
||
|
addAnimation(this.trackingAnimation);
|
||
|
}
|
||
|
|
||
|
@Override // com.airbnb.lottie.model.layer.BaseLayer, com.airbnb.lottie.animation.content.DrawingContent
|
||
|
public void getBounds(RectF rectF, Matrix matrix, boolean z) {
|
||
|
super.getBounds(rectF, matrix, z);
|
||
|
rectF.set(BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, this.composition.getBounds().width(), this.composition.getBounds().height());
|
||
|
}
|
||
|
|
||
|
@Override // com.airbnb.lottie.model.layer.BaseLayer
|
||
|
void drawLayer(Canvas canvas, Matrix matrix, int i) {
|
||
|
canvas.save();
|
||
|
if (!this.lottieDrawable.useTextGlyphs()) {
|
||
|
canvas.concat(matrix);
|
||
|
}
|
||
|
DocumentData value = this.textAnimation.getValue();
|
||
|
Font font = this.composition.getFonts().get(value.fontName);
|
||
|
if (font == null) {
|
||
|
canvas.restore();
|
||
|
return;
|
||
|
}
|
||
|
BaseKeyframeAnimation<Integer, Integer> baseKeyframeAnimation = this.colorCallbackAnimation;
|
||
|
if (baseKeyframeAnimation != null) {
|
||
|
this.fillPaint.setColor(baseKeyframeAnimation.getValue().intValue());
|
||
|
} else {
|
||
|
BaseKeyframeAnimation<Integer, Integer> baseKeyframeAnimation2 = this.colorAnimation;
|
||
|
if (baseKeyframeAnimation2 != null) {
|
||
|
this.fillPaint.setColor(baseKeyframeAnimation2.getValue().intValue());
|
||
|
} else {
|
||
|
this.fillPaint.setColor(value.color);
|
||
|
}
|
||
|
}
|
||
|
BaseKeyframeAnimation<Integer, Integer> baseKeyframeAnimation3 = this.strokeColorCallbackAnimation;
|
||
|
if (baseKeyframeAnimation3 != null) {
|
||
|
this.strokePaint.setColor(baseKeyframeAnimation3.getValue().intValue());
|
||
|
} else {
|
||
|
BaseKeyframeAnimation<Integer, Integer> baseKeyframeAnimation4 = this.strokeColorAnimation;
|
||
|
if (baseKeyframeAnimation4 != null) {
|
||
|
this.strokePaint.setColor(baseKeyframeAnimation4.getValue().intValue());
|
||
|
} else {
|
||
|
this.strokePaint.setColor(value.strokeColor);
|
||
|
}
|
||
|
}
|
||
|
int intValue = ((this.transform.getOpacity() == null ? 100 : this.transform.getOpacity().getValue().intValue()) * 255) / 100;
|
||
|
this.fillPaint.setAlpha(intValue);
|
||
|
this.strokePaint.setAlpha(intValue);
|
||
|
BaseKeyframeAnimation<Float, Float> baseKeyframeAnimation5 = this.strokeWidthCallbackAnimation;
|
||
|
if (baseKeyframeAnimation5 != null) {
|
||
|
this.strokePaint.setStrokeWidth(baseKeyframeAnimation5.getValue().floatValue());
|
||
|
} else {
|
||
|
BaseKeyframeAnimation<Float, Float> baseKeyframeAnimation6 = this.strokeWidthAnimation;
|
||
|
if (baseKeyframeAnimation6 != null) {
|
||
|
this.strokePaint.setStrokeWidth(baseKeyframeAnimation6.getValue().floatValue());
|
||
|
} else {
|
||
|
this.strokePaint.setStrokeWidth(value.strokeWidth * Utils.dpScale() * Utils.getScale(matrix));
|
||
|
}
|
||
|
}
|
||
|
if (this.lottieDrawable.useTextGlyphs()) {
|
||
|
drawTextGlyphs(value, matrix, font, canvas);
|
||
|
} else {
|
||
|
drawTextWithFont(value, font, canvas);
|
||
|
}
|
||
|
canvas.restore();
|
||
|
}
|
||
|
|
||
|
private void drawTextGlyphs(DocumentData documentData, Matrix matrix, Font font, Canvas canvas) {
|
||
|
float f;
|
||
|
BaseKeyframeAnimation<Float, Float> baseKeyframeAnimation = this.textSizeCallbackAnimation;
|
||
|
if (baseKeyframeAnimation != null) {
|
||
|
f = baseKeyframeAnimation.getValue().floatValue();
|
||
|
} else {
|
||
|
f = documentData.size;
|
||
|
}
|
||
|
float f2 = f / 100.0f;
|
||
|
float scale = Utils.getScale(matrix);
|
||
|
String str = documentData.text;
|
||
|
float dpScale = documentData.lineHeight * Utils.dpScale();
|
||
|
List<String> textLines = getTextLines(str);
|
||
|
int size = textLines.size();
|
||
|
for (int i = 0; i < size; i++) {
|
||
|
String str2 = textLines.get(i);
|
||
|
float textLineWidthForGlyphs = getTextLineWidthForGlyphs(str2, font, f2, scale);
|
||
|
canvas.save();
|
||
|
applyJustification(documentData.justification, canvas, textLineWidthForGlyphs);
|
||
|
canvas.translate(BitmapDescriptorFactory.HUE_RED, (i * dpScale) - (((size - 1) * dpScale) / 2.0f));
|
||
|
drawGlyphTextLine(str2, documentData, matrix, font, canvas, scale, f2);
|
||
|
canvas.restore();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void drawGlyphTextLine(String str, DocumentData documentData, Matrix matrix, Font font, Canvas canvas, float f, float f2) {
|
||
|
float floatValue;
|
||
|
for (int i = 0; i < str.length(); i++) {
|
||
|
FontCharacter e = this.composition.getCharacters().e(FontCharacter.hashFor(str.charAt(i), font.getFamily(), font.getStyle()));
|
||
|
if (e != null) {
|
||
|
drawCharacterAsGlyph(e, matrix, f2, documentData, canvas);
|
||
|
float width = (float) e.getWidth();
|
||
|
float dpScale = Utils.dpScale();
|
||
|
float f3 = documentData.tracking / 10.0f;
|
||
|
BaseKeyframeAnimation<Float, Float> baseKeyframeAnimation = this.trackingCallbackAnimation;
|
||
|
if (baseKeyframeAnimation != null) {
|
||
|
floatValue = baseKeyframeAnimation.getValue().floatValue();
|
||
|
} else {
|
||
|
BaseKeyframeAnimation<Float, Float> baseKeyframeAnimation2 = this.trackingAnimation;
|
||
|
if (baseKeyframeAnimation2 != null) {
|
||
|
floatValue = baseKeyframeAnimation2.getValue().floatValue();
|
||
|
}
|
||
|
canvas.translate((width * f2 * dpScale * f) + (f3 * f), BitmapDescriptorFactory.HUE_RED);
|
||
|
}
|
||
|
f3 += floatValue;
|
||
|
canvas.translate((width * f2 * dpScale * f) + (f3 * f), BitmapDescriptorFactory.HUE_RED);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Removed duplicated region for block: B:17:0x008e A[LOOP:0: B:16:0x008c->B:17:0x008e, LOOP_END] */
|
||
|
/*
|
||
|
Code decompiled incorrectly, please refer to instructions dump.
|
||
|
To view partially-correct add '--show-bad-code' argument
|
||
|
*/
|
||
|
private void drawTextWithFont(com.airbnb.lottie.model.DocumentData r9, com.airbnb.lottie.model.Font r10, android.graphics.Canvas r11) {
|
||
|
/*
|
||
|
r8 = this;
|
||
|
android.graphics.Typeface r10 = r8.getTypeface(r10)
|
||
|
if (r10 != 0) goto L7
|
||
|
return
|
||
|
L7:
|
||
|
java.lang.String r0 = r9.text
|
||
|
com.airbnb.lottie.LottieDrawable r1 = r8.lottieDrawable
|
||
|
com.airbnb.lottie.TextDelegate r1 = r1.getTextDelegate()
|
||
|
if (r1 == 0) goto L19
|
||
|
java.lang.String r2 = r8.getName()
|
||
|
java.lang.String r0 = r1.getTextInternal(r2, r0)
|
||
|
L19:
|
||
|
android.graphics.Paint r1 = r8.fillPaint
|
||
|
r1.setTypeface(r10)
|
||
|
com.airbnb.lottie.animation.keyframe.BaseKeyframeAnimation<java.lang.Float, java.lang.Float> r10 = r8.textSizeCallbackAnimation
|
||
|
if (r10 == 0) goto L2d
|
||
|
java.lang.Object r10 = r10.getValue()
|
||
|
java.lang.Float r10 = (java.lang.Float) r10
|
||
|
float r10 = r10.floatValue()
|
||
|
goto L2f
|
||
|
L2d:
|
||
|
float r10 = r9.size
|
||
|
L2f:
|
||
|
android.graphics.Paint r1 = r8.fillPaint
|
||
|
float r2 = com.airbnb.lottie.utils.Utils.dpScale()
|
||
|
float r2 = r2 * r10
|
||
|
r1.setTextSize(r2)
|
||
|
android.graphics.Paint r1 = r8.strokePaint
|
||
|
android.graphics.Paint r2 = r8.fillPaint
|
||
|
android.graphics.Typeface r2 = r2.getTypeface()
|
||
|
r1.setTypeface(r2)
|
||
|
android.graphics.Paint r1 = r8.strokePaint
|
||
|
android.graphics.Paint r2 = r8.fillPaint
|
||
|
float r2 = r2.getTextSize()
|
||
|
r1.setTextSize(r2)
|
||
|
float r1 = r9.lineHeight
|
||
|
float r2 = com.airbnb.lottie.utils.Utils.dpScale()
|
||
|
float r1 = r1 * r2
|
||
|
int r2 = r9.tracking
|
||
|
float r2 = (float) r2
|
||
|
r3 = 1092616192(0x41200000, float:10.0)
|
||
|
float r2 = r2 / r3
|
||
|
com.airbnb.lottie.animation.keyframe.BaseKeyframeAnimation<java.lang.Float, java.lang.Float> r3 = r8.trackingCallbackAnimation
|
||
|
if (r3 == 0) goto L6b
|
||
|
java.lang.Object r3 = r3.getValue()
|
||
|
java.lang.Float r3 = (java.lang.Float) r3
|
||
|
float r3 = r3.floatValue()
|
||
|
goto L79
|
||
|
L6b:
|
||
|
com.airbnb.lottie.animation.keyframe.BaseKeyframeAnimation<java.lang.Float, java.lang.Float> r3 = r8.trackingAnimation
|
||
|
if (r3 == 0) goto L7a
|
||
|
java.lang.Object r3 = r3.getValue()
|
||
|
java.lang.Float r3 = (java.lang.Float) r3
|
||
|
float r3 = r3.floatValue()
|
||
|
L79:
|
||
|
float r2 = r2 + r3
|
||
|
L7a:
|
||
|
float r3 = com.airbnb.lottie.utils.Utils.dpScale()
|
||
|
float r2 = r2 * r3
|
||
|
float r2 = r2 * r10
|
||
|
r10 = 1120403456(0x42c80000, float:100.0)
|
||
|
float r2 = r2 / r10
|
||
|
java.util.List r10 = r8.getTextLines(r0)
|
||
|
int r0 = r10.size()
|
||
|
r3 = 0
|
||
|
L8c:
|
||
|
if (r3 >= r0) goto Lc2
|
||
|
java.lang.Object r4 = r10.get(r3)
|
||
|
java.lang.String r4 = (java.lang.String) r4
|
||
|
android.graphics.Paint r5 = r8.strokePaint
|
||
|
float r5 = r5.measureText(r4)
|
||
|
int r6 = r4.length()
|
||
|
int r6 = r6 + (-1)
|
||
|
float r6 = (float) r6
|
||
|
r11.save()
|
||
|
com.airbnb.lottie.model.DocumentData$Justification r7 = r9.justification
|
||
|
float r6 = r6 * r2
|
||
|
float r5 = r5 + r6
|
||
|
r8.applyJustification(r7, r11, r5)
|
||
|
int r5 = r0 + (-1)
|
||
|
float r5 = (float) r5
|
||
|
float r5 = r5 * r1
|
||
|
r6 = 1073741824(0x40000000, float:2.0)
|
||
|
float r5 = r5 / r6
|
||
|
float r6 = (float) r3
|
||
|
float r6 = r6 * r1
|
||
|
float r6 = r6 - r5
|
||
|
r5 = 0
|
||
|
r11.translate(r5, r6)
|
||
|
r8.drawFontTextLine(r4, r9, r11, r2)
|
||
|
r11.restore()
|
||
|
int r3 = r3 + 1
|
||
|
goto L8c
|
||
|
Lc2:
|
||
|
return
|
||
|
*/
|
||
|
throw new UnsupportedOperationException("Method not decompiled: com.airbnb.lottie.model.layer.TextLayer.drawTextWithFont(com.airbnb.lottie.model.DocumentData, com.airbnb.lottie.model.Font, android.graphics.Canvas):void");
|
||
|
}
|
||
|
|
||
|
private Typeface getTypeface(Font font) {
|
||
|
Typeface value;
|
||
|
BaseKeyframeAnimation<Typeface, Typeface> baseKeyframeAnimation = this.typefaceCallbackAnimation;
|
||
|
if (baseKeyframeAnimation != null && (value = baseKeyframeAnimation.getValue()) != null) {
|
||
|
return value;
|
||
|
}
|
||
|
Typeface typeface = this.lottieDrawable.getTypeface(font.getFamily(), font.getStyle());
|
||
|
return typeface != null ? typeface : font.getTypeface();
|
||
|
}
|
||
|
|
||
|
private List<String> getTextLines(String str) {
|
||
|
return Arrays.asList(str.replaceAll("\r\n", "\r").replaceAll("\n", "\r").split("\r"));
|
||
|
}
|
||
|
|
||
|
private void drawFontTextLine(String str, DocumentData documentData, Canvas canvas, float f) {
|
||
|
int i = 0;
|
||
|
while (i < str.length()) {
|
||
|
String codePointToString = codePointToString(str, i);
|
||
|
i += codePointToString.length();
|
||
|
drawCharacterFromFont(codePointToString, documentData, canvas);
|
||
|
canvas.translate(this.fillPaint.measureText(codePointToString) + f, BitmapDescriptorFactory.HUE_RED);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private float getTextLineWidthForGlyphs(String str, Font font, float f, float f2) {
|
||
|
float f3 = BitmapDescriptorFactory.HUE_RED;
|
||
|
for (int i = 0; i < str.length(); i++) {
|
||
|
FontCharacter e = this.composition.getCharacters().e(FontCharacter.hashFor(str.charAt(i), font.getFamily(), font.getStyle()));
|
||
|
if (e != null) {
|
||
|
f3 = (float) (f3 + (e.getWidth() * f * Utils.dpScale() * f2));
|
||
|
}
|
||
|
}
|
||
|
return f3;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* renamed from: com.airbnb.lottie.model.layer.TextLayer$3, reason: invalid class name */
|
||
|
/* loaded from: classes.dex */
|
||
|
public static /* synthetic */ class AnonymousClass3 {
|
||
|
static final int[] $SwitchMap$com$airbnb$lottie$model$DocumentData$Justification;
|
||
|
|
||
|
static {
|
||
|
int[] iArr = new int[DocumentData.Justification.values().length];
|
||
|
$SwitchMap$com$airbnb$lottie$model$DocumentData$Justification = iArr;
|
||
|
try {
|
||
|
iArr[DocumentData.Justification.LEFT_ALIGN.ordinal()] = 1;
|
||
|
} catch (NoSuchFieldError unused) {
|
||
|
}
|
||
|
try {
|
||
|
$SwitchMap$com$airbnb$lottie$model$DocumentData$Justification[DocumentData.Justification.RIGHT_ALIGN.ordinal()] = 2;
|
||
|
} catch (NoSuchFieldError unused2) {
|
||
|
}
|
||
|
try {
|
||
|
$SwitchMap$com$airbnb$lottie$model$DocumentData$Justification[DocumentData.Justification.CENTER.ordinal()] = 3;
|
||
|
} catch (NoSuchFieldError unused3) {
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void applyJustification(DocumentData.Justification justification, Canvas canvas, float f) {
|
||
|
int i = AnonymousClass3.$SwitchMap$com$airbnb$lottie$model$DocumentData$Justification[justification.ordinal()];
|
||
|
if (i == 2) {
|
||
|
canvas.translate(-f, BitmapDescriptorFactory.HUE_RED);
|
||
|
} else if (i == 3) {
|
||
|
canvas.translate((-f) / 2.0f, BitmapDescriptorFactory.HUE_RED);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void drawCharacterAsGlyph(FontCharacter fontCharacter, Matrix matrix, float f, DocumentData documentData, Canvas canvas) {
|
||
|
List<ContentGroup> contentsForCharacter = getContentsForCharacter(fontCharacter);
|
||
|
for (int i = 0; i < contentsForCharacter.size(); i++) {
|
||
|
Path path = contentsForCharacter.get(i).getPath();
|
||
|
path.computeBounds(this.rectF, false);
|
||
|
this.matrix.set(matrix);
|
||
|
this.matrix.preTranslate(BitmapDescriptorFactory.HUE_RED, (-documentData.baselineShift) * Utils.dpScale());
|
||
|
this.matrix.preScale(f, f);
|
||
|
path.transform(this.matrix);
|
||
|
if (documentData.strokeOverFill) {
|
||
|
drawGlyph(path, this.fillPaint, canvas);
|
||
|
drawGlyph(path, this.strokePaint, canvas);
|
||
|
} else {
|
||
|
drawGlyph(path, this.strokePaint, canvas);
|
||
|
drawGlyph(path, this.fillPaint, canvas);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void drawGlyph(Path path, Paint paint, Canvas canvas) {
|
||
|
if (paint.getColor() == 0) {
|
||
|
return;
|
||
|
}
|
||
|
if (paint.getStyle() == Paint.Style.STROKE && paint.getStrokeWidth() == BitmapDescriptorFactory.HUE_RED) {
|
||
|
return;
|
||
|
}
|
||
|
canvas.drawPath(path, paint);
|
||
|
}
|
||
|
|
||
|
private void drawCharacterFromFont(String str, DocumentData documentData, Canvas canvas) {
|
||
|
if (documentData.strokeOverFill) {
|
||
|
drawCharacter(str, this.fillPaint, canvas);
|
||
|
drawCharacter(str, this.strokePaint, canvas);
|
||
|
} else {
|
||
|
drawCharacter(str, this.strokePaint, canvas);
|
||
|
drawCharacter(str, this.fillPaint, canvas);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void drawCharacter(String str, Paint paint, Canvas canvas) {
|
||
|
if (paint.getColor() == 0) {
|
||
|
return;
|
||
|
}
|
||
|
if (paint.getStyle() == Paint.Style.STROKE && paint.getStrokeWidth() == BitmapDescriptorFactory.HUE_RED) {
|
||
|
return;
|
||
|
}
|
||
|
canvas.drawText(str, 0, str.length(), BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, paint);
|
||
|
}
|
||
|
|
||
|
private List<ContentGroup> getContentsForCharacter(FontCharacter fontCharacter) {
|
||
|
if (this.contentsForCharacter.containsKey(fontCharacter)) {
|
||
|
return this.contentsForCharacter.get(fontCharacter);
|
||
|
}
|
||
|
List<ShapeGroup> shapes = fontCharacter.getShapes();
|
||
|
int size = shapes.size();
|
||
|
ArrayList arrayList = new ArrayList(size);
|
||
|
for (int i = 0; i < size; i++) {
|
||
|
arrayList.add(new ContentGroup(this.lottieDrawable, this, shapes.get(i)));
|
||
|
}
|
||
|
this.contentsForCharacter.put(fontCharacter, arrayList);
|
||
|
return arrayList;
|
||
|
}
|
||
|
|
||
|
private String codePointToString(String str, int i) {
|
||
|
int codePointAt = str.codePointAt(i);
|
||
|
int charCount = Character.charCount(codePointAt) + i;
|
||
|
while (charCount < str.length()) {
|
||
|
int codePointAt2 = str.codePointAt(charCount);
|
||
|
if (!isModifier(codePointAt2)) {
|
||
|
break;
|
||
|
}
|
||
|
charCount += Character.charCount(codePointAt2);
|
||
|
codePointAt = (codePointAt * 31) + codePointAt2;
|
||
|
}
|
||
|
long j = codePointAt;
|
||
|
if (!this.codePointCache.d(j)) {
|
||
|
this.stringBuilder.setLength(0);
|
||
|
while (i < charCount) {
|
||
|
int codePointAt3 = str.codePointAt(i);
|
||
|
this.stringBuilder.appendCodePoint(codePointAt3);
|
||
|
i += Character.charCount(codePointAt3);
|
||
|
}
|
||
|
String obj = this.stringBuilder.toString();
|
||
|
this.codePointCache.c(j, obj);
|
||
|
return obj;
|
||
|
}
|
||
|
return this.codePointCache.c(j);
|
||
|
}
|
||
|
|
||
|
private boolean isModifier(int i) {
|
||
|
return Character.getType(i) == 16 || Character.getType(i) == 27 || Character.getType(i) == 6 || Character.getType(i) == 28 || Character.getType(i) == 8 || Character.getType(i) == 19;
|
||
|
}
|
||
|
|
||
|
@Override // com.airbnb.lottie.model.layer.BaseLayer, com.airbnb.lottie.model.KeyPathElement
|
||
|
public <T> void addValueCallback(T t, LottieValueCallback<T> lottieValueCallback) {
|
||
|
super.addValueCallback(t, lottieValueCallback);
|
||
|
if (t == LottieProperty.COLOR) {
|
||
|
BaseKeyframeAnimation<Integer, Integer> baseKeyframeAnimation = this.colorCallbackAnimation;
|
||
|
if (baseKeyframeAnimation != null) {
|
||
|
removeAnimation(baseKeyframeAnimation);
|
||
|
}
|
||
|
if (lottieValueCallback == null) {
|
||
|
this.colorCallbackAnimation = null;
|
||
|
return;
|
||
|
}
|
||
|
ValueCallbackKeyframeAnimation valueCallbackKeyframeAnimation = new ValueCallbackKeyframeAnimation(lottieValueCallback);
|
||
|
this.colorCallbackAnimation = valueCallbackKeyframeAnimation;
|
||
|
valueCallbackKeyframeAnimation.addUpdateListener(this);
|
||
|
addAnimation(this.colorCallbackAnimation);
|
||
|
return;
|
||
|
}
|
||
|
if (t == LottieProperty.STROKE_COLOR) {
|
||
|
BaseKeyframeAnimation<Integer, Integer> baseKeyframeAnimation2 = this.strokeColorCallbackAnimation;
|
||
|
if (baseKeyframeAnimation2 != null) {
|
||
|
removeAnimation(baseKeyframeAnimation2);
|
||
|
}
|
||
|
if (lottieValueCallback == null) {
|
||
|
this.strokeColorCallbackAnimation = null;
|
||
|
return;
|
||
|
}
|
||
|
ValueCallbackKeyframeAnimation valueCallbackKeyframeAnimation2 = new ValueCallbackKeyframeAnimation(lottieValueCallback);
|
||
|
this.strokeColorCallbackAnimation = valueCallbackKeyframeAnimation2;
|
||
|
valueCallbackKeyframeAnimation2.addUpdateListener(this);
|
||
|
addAnimation(this.strokeColorCallbackAnimation);
|
||
|
return;
|
||
|
}
|
||
|
if (t == LottieProperty.STROKE_WIDTH) {
|
||
|
BaseKeyframeAnimation<Float, Float> baseKeyframeAnimation3 = this.strokeWidthCallbackAnimation;
|
||
|
if (baseKeyframeAnimation3 != null) {
|
||
|
removeAnimation(baseKeyframeAnimation3);
|
||
|
}
|
||
|
if (lottieValueCallback == null) {
|
||
|
this.strokeWidthCallbackAnimation = null;
|
||
|
return;
|
||
|
}
|
||
|
ValueCallbackKeyframeAnimation valueCallbackKeyframeAnimation3 = new ValueCallbackKeyframeAnimation(lottieValueCallback);
|
||
|
this.strokeWidthCallbackAnimation = valueCallbackKeyframeAnimation3;
|
||
|
valueCallbackKeyframeAnimation3.addUpdateListener(this);
|
||
|
addAnimation(this.strokeWidthCallbackAnimation);
|
||
|
return;
|
||
|
}
|
||
|
if (t == LottieProperty.TEXT_TRACKING) {
|
||
|
BaseKeyframeAnimation<Float, Float> baseKeyframeAnimation4 = this.trackingCallbackAnimation;
|
||
|
if (baseKeyframeAnimation4 != null) {
|
||
|
removeAnimation(baseKeyframeAnimation4);
|
||
|
}
|
||
|
if (lottieValueCallback == null) {
|
||
|
this.trackingCallbackAnimation = null;
|
||
|
return;
|
||
|
}
|
||
|
ValueCallbackKeyframeAnimation valueCallbackKeyframeAnimation4 = new ValueCallbackKeyframeAnimation(lottieValueCallback);
|
||
|
this.trackingCallbackAnimation = valueCallbackKeyframeAnimation4;
|
||
|
valueCallbackKeyframeAnimation4.addUpdateListener(this);
|
||
|
addAnimation(this.trackingCallbackAnimation);
|
||
|
return;
|
||
|
}
|
||
|
if (t == LottieProperty.TEXT_SIZE) {
|
||
|
BaseKeyframeAnimation<Float, Float> baseKeyframeAnimation5 = this.textSizeCallbackAnimation;
|
||
|
if (baseKeyframeAnimation5 != null) {
|
||
|
removeAnimation(baseKeyframeAnimation5);
|
||
|
}
|
||
|
if (lottieValueCallback == null) {
|
||
|
this.textSizeCallbackAnimation = null;
|
||
|
return;
|
||
|
}
|
||
|
ValueCallbackKeyframeAnimation valueCallbackKeyframeAnimation5 = new ValueCallbackKeyframeAnimation(lottieValueCallback);
|
||
|
this.textSizeCallbackAnimation = valueCallbackKeyframeAnimation5;
|
||
|
valueCallbackKeyframeAnimation5.addUpdateListener(this);
|
||
|
addAnimation(this.textSizeCallbackAnimation);
|
||
|
return;
|
||
|
}
|
||
|
if (t != LottieProperty.TYPEFACE) {
|
||
|
if (t == LottieProperty.TEXT) {
|
||
|
this.textAnimation.setStringValueCallback(lottieValueCallback);
|
||
|
return;
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
BaseKeyframeAnimation<Typeface, Typeface> baseKeyframeAnimation6 = this.typefaceCallbackAnimation;
|
||
|
if (baseKeyframeAnimation6 != null) {
|
||
|
removeAnimation(baseKeyframeAnimation6);
|
||
|
}
|
||
|
if (lottieValueCallback == null) {
|
||
|
this.typefaceCallbackAnimation = null;
|
||
|
return;
|
||
|
}
|
||
|
ValueCallbackKeyframeAnimation valueCallbackKeyframeAnimation6 = new ValueCallbackKeyframeAnimation(lottieValueCallback);
|
||
|
this.typefaceCallbackAnimation = valueCallbackKeyframeAnimation6;
|
||
|
valueCallbackKeyframeAnimation6.addUpdateListener(this);
|
||
|
addAnimation(this.typefaceCallbackAnimation);
|
||
|
}
|
||
|
}
|