From c5ea9b43723e6154e81cc4a641d3f3ad5130dca2 Mon Sep 17 00:00:00 2001 From: Greg Giacovelli Date: Fri, 22 Oct 2021 09:08:55 -0700 Subject: [PATCH] Moving to using keyPathName as string to reduce allocations and be more consistent with iOS --- lottie/src/main/java/com/airbnb/lottie/TextDelegate.java | 8 ++++---- .../java/com/airbnb/lottie/model/layer/TextLayer.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lottie/src/main/java/com/airbnb/lottie/TextDelegate.java b/lottie/src/main/java/com/airbnb/lottie/TextDelegate.java index 31d80c08d6..91a663ca97 100644 --- a/lottie/src/main/java/com/airbnb/lottie/TextDelegate.java +++ b/lottie/src/main/java/com/airbnb/lottie/TextDelegate.java @@ -47,11 +47,11 @@ public TextDelegate(@SuppressWarnings("NullableProblems") LottieDrawable drawabl /** * Override this to replace the animation text with something dynamic. This can be used for * translations or custom data. - * @param path the name of the layer with text + * @param keyPathName the name of the layer with text * @param input the string at the layer with text * @return a String to use for the specific data, by default this is the same as getText(input) */ - public String getText(KeyPath path, String input) { + public String getText(String keyPathName, String input) { return getText(input); } @@ -96,11 +96,11 @@ public void invalidateAllText() { } @RestrictTo(RestrictTo.Scope.LIBRARY) - public final String getTextInternal(KeyPath path, String input) { + public final String getTextInternal(String keyPathName, String input) { if (cacheText && stringMap.containsKey(input)) { return stringMap.get(input); } - String text = getText(path, input); + String text = getText(keyPathName, input); if (cacheText) { stringMap.put(input, text); } diff --git a/lottie/src/main/java/com/airbnb/lottie/model/layer/TextLayer.java b/lottie/src/main/java/com/airbnb/lottie/model/layer/TextLayer.java index 5b959ecad2..d67e9cb1d9 100644 --- a/lottie/src/main/java/com/airbnb/lottie/model/layer/TextLayer.java +++ b/lottie/src/main/java/com/airbnb/lottie/model/layer/TextLayer.java @@ -246,7 +246,7 @@ private void drawTextWithFont( String text = documentData.text; TextDelegate textDelegate = lottieDrawable.getTextDelegate(); if (textDelegate != null) { - text = textDelegate.getTextInternal(new KeyPath(getName()), text); + text = textDelegate.getTextInternal(getName(), text); } fillPaint.setTypeface(typeface); float textSize;