Match trailing carriage returns
diff --git a/lottie/src/main/java/com/airbnb/lottie/LottieComposition.java b/lottie/src/main/java/com/airbnb/lottie/LottieComposition.java
index 8ecc781..5edb57e 100644
--- a/lottie/src/main/java/com/airbnb/lottie/LottieComposition.java
+++ b/lottie/src/main/java/com/airbnb/lottie/LottieComposition.java
@@ -181,7 +181,7 @@
int size = markers.size();
for (int i = 0; i < markers.size(); i++) {
Marker marker = markers.get(i);
- if (markerName.equals(marker.name)) {
+ if (marker.matchesName(markerName)) {
return marker;
}
}
diff --git a/lottie/src/main/java/com/airbnb/lottie/model/Marker.java b/lottie/src/main/java/com/airbnb/lottie/model/Marker.java
index bab7413..f54d3af 100644
--- a/lottie/src/main/java/com/airbnb/lottie/model/Marker.java
+++ b/lottie/src/main/java/com/airbnb/lottie/model/Marker.java
@@ -1,8 +1,9 @@
package com.airbnb.lottie.model;
public class Marker {
+ private static String CARRIAGE_RETURN = "\r";
- public final String name;
+ private final String name;
public final float startFrame;
public final float durationFrames;
@@ -11,4 +12,17 @@
this.durationFrames = durationFrames;
this.startFrame = startFrame;
}
+
+ public boolean matchesName(String name) {
+ if (this.name.equalsIgnoreCase(name)) {
+ return true;
+ }
+
+ // It is easy for a designer to accidentally include an extra newline which will cause the name to not match what they would
+ // expect. This is a convenience to precent unneccesary confusion.
+ if (this.name.endsWith(CARRIAGE_RETURN) && this.name.substring(0, this.name.length() - 1).equalsIgnoreCase(name)) {
+ return true;
+ }
+ return false;
+ }
}
diff --git a/lottie/src/test/java/com/airbnb/lottie/model/MarkerTest.java b/lottie/src/test/java/com/airbnb/lottie/model/MarkerTest.java
new file mode 100644
index 0000000..e819107
--- /dev/null
+++ b/lottie/src/test/java/com/airbnb/lottie/model/MarkerTest.java
@@ -0,0 +1,14 @@
+package com.airbnb.lottie.model;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class MarkerTest {
+
+ @Test
+ public void testMarkerWithCarriageReturn() {
+ Marker marker = new Marker("Foo\r", 0f, 0f);
+ assertTrue(marker.matchesName("foo"));
+ }
+}
\ No newline at end of file