Skip to content

Commit

Permalink
Handle cases in which the Lottie file only has a single color (#1985)
Browse files Browse the repository at this point in the history
Fixes #1967
  • Loading branch information
gpeal authored Jan 10, 2022
1 parent adf993f commit b1b58d2
Show file tree
Hide file tree
Showing 2 changed files with 3,523 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ public GradientColor parse(JsonReader reader, float scale)
while (reader.hasNext()) {
array.add((float) reader.nextDouble());
}
if (array.size() == 4 && array.get(0) == 1f) {
// If a gradient color only contains one color at position 1, add a second stop with the same
// color at position 0. Android's LinearGradient shader requires at least two colors.
// https://github.com/airbnb/lottie-android/issues/1967
array.set(0, 0f);
array.add(1f);
array.add(array.get(1));
array.add(array.get(2));
array.add(array.get(3));
colorPoints = 2;
}
if (isArray) {
reader.endArray();
}
Expand Down
Loading

0 comments on commit b1b58d2

Please sign in to comment.