Skip to content

Commit

Permalink
Moving to using keyPathName as string to reduce allocations and be mo…
Browse files Browse the repository at this point in the history
…re consistent with iOS
  • Loading branch information
greggiacovelli committed Oct 22, 2021
1 parent a9bcd9b commit c5ea9b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lottie/src/main/java/com/airbnb/lottie/TextDelegate.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c5ea9b4

Please sign in to comment.