Removed some unused code (#1942)
diff --git a/lottie/src/main/java/com/airbnb/lottie/LottieComposition.java b/lottie/src/main/java/com/airbnb/lottie/LottieComposition.java
index cc78abf..a5a2a8f 100644
--- a/lottie/src/main/java/com/airbnb/lottie/LottieComposition.java
+++ b/lottie/src/main/java/com/airbnb/lottie/LottieComposition.java
@@ -4,6 +4,7 @@
import android.content.res.Resources;
import android.graphics.Rect;
+import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RawRes;
import androidx.annotation.RestrictTo;
@@ -217,7 +218,9 @@
}
- @Override public String toString() {
+ @NonNull
+ @Override
+ public String toString() {
final StringBuilder sb = new StringBuilder("LottieComposition:\n");
for (Layer layer : layers) {
sb.append(layer.toString("\t"));
@@ -334,6 +337,7 @@
@WorkerThread
@Deprecated
public static LottieComposition fromJsonSync(@SuppressWarnings("unused") Resources res, JSONObject json) {
+ //noinspection deprecation
return LottieCompositionFactory.fromJsonSync(json, null).getValue();
}
@@ -378,4 +382,4 @@
}
}
}
-}
+}
\ No newline at end of file
diff --git a/lottie/src/main/java/com/airbnb/lottie/model/FontCharacter.java b/lottie/src/main/java/com/airbnb/lottie/model/FontCharacter.java
index 00ab42a..d394d7f 100644
--- a/lottie/src/main/java/com/airbnb/lottie/model/FontCharacter.java
+++ b/lottie/src/main/java/com/airbnb/lottie/model/FontCharacter.java
@@ -40,18 +40,10 @@
return shapes;
}
- double getSize() {
- return size;
- }
-
public double getWidth() {
return width;
}
- String getStyle() {
- return style;
- }
-
@Override public int hashCode() {
return hashFor(character, fontFamily, style);
}
diff --git a/lottie/src/main/java/com/airbnb/lottie/model/animatable/AnimatableFloatValue.java b/lottie/src/main/java/com/airbnb/lottie/model/animatable/AnimatableFloatValue.java
index a73da37..c2975da 100644
--- a/lottie/src/main/java/com/airbnb/lottie/model/animatable/AnimatableFloatValue.java
+++ b/lottie/src/main/java/com/airbnb/lottie/model/animatable/AnimatableFloatValue.java
@@ -8,10 +8,6 @@
public class AnimatableFloatValue extends BaseAnimatableValue<Float, Float> {
- AnimatableFloatValue() {
- super(0f);
- }
-
public AnimatableFloatValue(List<Keyframe<Float>> keyframes) {
super(keyframes);
}
diff --git a/lottie/src/main/java/com/airbnb/lottie/model/animatable/AnimatableIntegerValue.java b/lottie/src/main/java/com/airbnb/lottie/model/animatable/AnimatableIntegerValue.java
index 494e766..54fb03b 100644
--- a/lottie/src/main/java/com/airbnb/lottie/model/animatable/AnimatableIntegerValue.java
+++ b/lottie/src/main/java/com/airbnb/lottie/model/animatable/AnimatableIntegerValue.java
@@ -8,10 +8,6 @@
public class AnimatableIntegerValue extends BaseAnimatableValue<Integer, Integer> {
- public AnimatableIntegerValue() {
- super(100);
- }
-
public AnimatableIntegerValue(List<Keyframe<Integer>> keyframes) {
super(keyframes);
}
diff --git a/lottie/src/main/java/com/airbnb/lottie/model/animatable/AnimatablePathValue.java b/lottie/src/main/java/com/airbnb/lottie/model/animatable/AnimatablePathValue.java
index bf8dddd..67a0132 100644
--- a/lottie/src/main/java/com/airbnb/lottie/model/animatable/AnimatablePathValue.java
+++ b/lottie/src/main/java/com/airbnb/lottie/model/animatable/AnimatablePathValue.java
@@ -7,19 +7,11 @@
import com.airbnb.lottie.animation.keyframe.PointKeyframeAnimation;
import com.airbnb.lottie.value.Keyframe;
-import java.util.Collections;
import java.util.List;
public class AnimatablePathValue implements AnimatableValue<PointF, PointF> {
private final List<Keyframe<PointF>> keyframes;
- /**
- * Create a default static animatable path.
- */
- public AnimatablePathValue() {
- keyframes = Collections.singletonList(new Keyframe<>(new PointF(0, 0)));
- }
-
public AnimatablePathValue(List<Keyframe<PointF>> keyframes) {
this.keyframes = keyframes;
}
diff --git a/lottie/src/main/java/com/airbnb/lottie/model/animatable/AnimatableScaleValue.java b/lottie/src/main/java/com/airbnb/lottie/model/animatable/AnimatableScaleValue.java
index c168e5e..5bd57b0 100644
--- a/lottie/src/main/java/com/airbnb/lottie/model/animatable/AnimatableScaleValue.java
+++ b/lottie/src/main/java/com/airbnb/lottie/model/animatable/AnimatableScaleValue.java
@@ -9,10 +9,6 @@
public class AnimatableScaleValue extends BaseAnimatableValue<ScaleXY, ScaleXY> {
- AnimatableScaleValue() {
- this(new ScaleXY(1f, 1f));
- }
-
public AnimatableScaleValue(ScaleXY value) {
super(value);
}
diff --git a/lottie/src/main/java/com/airbnb/lottie/model/content/GradientFill.java b/lottie/src/main/java/com/airbnb/lottie/model/content/GradientFill.java
index fde5123..87ecf3a 100644
--- a/lottie/src/main/java/com/airbnb/lottie/model/content/GradientFill.java
+++ b/lottie/src/main/java/com/airbnb/lottie/model/content/GradientFill.java
@@ -71,14 +71,6 @@
return endPoint;
}
- @Nullable AnimatableFloatValue getHighlightLength() {
- return highlightLength;
- }
-
- @Nullable AnimatableFloatValue getHighlightAngle() {
- return highlightAngle;
- }
-
public boolean isHidden() {
return hidden;
}
diff --git a/lottie/src/main/java/com/airbnb/lottie/network/DefaultLottieFetchResult.java b/lottie/src/main/java/com/airbnb/lottie/network/DefaultLottieFetchResult.java
index 06dac3a..3024962 100644
--- a/lottie/src/main/java/com/airbnb/lottie/network/DefaultLottieFetchResult.java
+++ b/lottie/src/main/java/com/airbnb/lottie/network/DefaultLottieFetchResult.java
@@ -59,8 +59,6 @@
while ((line = r.readLine()) != null) {
error.append(line).append('\n');
}
- } catch (Exception e) {
- throw e;
} finally {
try {
r.close();
diff --git a/lottie/src/main/java/com/airbnb/lottie/network/FileExtension.java b/lottie/src/main/java/com/airbnb/lottie/network/FileExtension.java
index 72a1a5f..fb442d6 100644
--- a/lottie/src/main/java/com/airbnb/lottie/network/FileExtension.java
+++ b/lottie/src/main/java/com/airbnb/lottie/network/FileExtension.java
@@ -23,14 +23,4 @@
return extension;
}
- public static FileExtension forFile(String filename) {
- for (FileExtension e : values()) {
- if (filename.endsWith(e.extension)) {
- return e;
- }
- }
- // Default to Json.
- Logger.warning("Unable to find correct extension for " + filename);
- return JSON;
- }
}
diff --git a/lottie/src/main/java/com/airbnb/lottie/parser/LottieCompositionParser.java b/lottie/src/main/java/com/airbnb/lottie/parser/LottieCompositionParser.java
deleted file mode 100644
index ecc64bc..0000000
--- a/lottie/src/main/java/com/airbnb/lottie/parser/LottieCompositionParser.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package com.airbnb.lottie.parser;
-
-import android.graphics.Rect;
-
-import androidx.collection.LongSparseArray;
-import androidx.collection.SparseArrayCompat;
-
-import com.airbnb.lottie.LottieComposition;
-import com.airbnb.lottie.LottieImageAsset;
-import com.airbnb.lottie.model.Font;
-import com.airbnb.lottie.model.FontCharacter;
-import com.airbnb.lottie.model.Marker;
-import com.airbnb.lottie.model.layer.Layer;
-import com.airbnb.lottie.parser.moshi.JsonReader;
-import com.airbnb.lottie.utils.Logger;
-import com.airbnb.lottie.utils.Utils;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-
-public class LottieCompositionParser {
- static JsonReader.Options NAMES = JsonReader.Options.of(
- "w",
- "h",
- "ip",
- "op",
- "fr",
- "v",
- "layers",
- "assets",
- "fonts",
- "chars",
- "markers");
-
- public static LottieComposition parse(JsonReader reader) throws IOException {
- float scale = Utils.dpScale();
- float startFrame = 0f;
- float endFrame = 0f;
- float frameRate = 0f;
- final LongSparseArray<Layer> layerMap = new LongSparseArray<>();
- final List<Layer> layers = new ArrayList<>();
- int width = 0;
- int height = 0;
- Map<String, List<Layer>> precomps = new HashMap<>();
- Map<String, LottieImageAsset> images = new HashMap<>();
- Map<String, Font> fonts = new HashMap<>();
- List<Marker> markers = new ArrayList<>();
- SparseArrayCompat<FontCharacter> characters = new SparseArrayCompat<>();
-
- LottieComposition composition = new LottieComposition();
- reader.beginObject();
- while (reader.hasNext()) {
- switch (reader.selectName(NAMES)) {
- case 0:
- width = reader.nextInt();
- break;
- case 1:
- height = reader.nextInt();
- break;
- case 2:
- startFrame = (float) reader.nextDouble();
- break;
- case 3:
- endFrame = (float) reader.nextDouble() - 0.01f;
- break;
- case 4:
- frameRate = (float) reader.nextDouble();
- break;
- case 5:
- String version = reader.nextString();
- String[] versions = version.split("\\.");
- int majorVersion = Integer.parseInt(versions[0]);
- int minorVersion = Integer.parseInt(versions[1]);
- int patchVersion = Integer.parseInt(versions[2]);
- if (!Utils.isAtLeastVersion(majorVersion, minorVersion, patchVersion,
- 4, 4, 0)) {
- composition.addWarning("Lottie only supports bodymovin >= 4.4.0");
- }
- break;
- case 6:
- parseLayers(reader, composition, layers, layerMap);
- default:
- reader.skipValue();
-
- }
- }
- int scaledWidth = (int) (width * scale);
- int scaledHeight = (int) (height * scale);
- Rect bounds = new Rect(0, 0, scaledWidth, scaledHeight);
-
- composition.init(bounds, startFrame, endFrame, frameRate, layers, layerMap, precomps,
- images, characters, fonts, markers);
-
- return composition;
- }
-
- private static void parseLayers(JsonReader reader, LottieComposition composition,
- List<Layer> layers, LongSparseArray<Layer> layerMap) throws IOException {
- int imageCount = 0;
- reader.beginArray();
- while (reader.hasNext()) {
- Layer layer = LayerParser.parse(reader, composition);
- if (layer.getLayerType() == Layer.LayerType.IMAGE) {
- imageCount++;
- }
- layers.add(layer);
- layerMap.put(layer.getId(), layer);
-
- if (imageCount > 4) {
- Logger.warning("You have " + imageCount + " images. Lottie should primarily be " +
- "used with shapes. If you are using Adobe Illustrator, convert the Illustrator layers" +
- " to shape layers.");
- }
- }
- reader.endArray();
- }
-}
diff --git a/lottie/src/main/java/com/airbnb/lottie/utils/Utils.java b/lottie/src/main/java/com/airbnb/lottie/utils/Utils.java
index cdf0cc2..7022e02 100644
--- a/lottie/src/main/java/com/airbnb/lottie/utils/Utils.java
+++ b/lottie/src/main/java/com/airbnb/lottie/utils/Utils.java
@@ -309,6 +309,7 @@
/**
* For testing purposes only. DO NOT USE IN PRODUCTION.
*/
+ @SuppressWarnings("unused")
public static Bitmap renderPath(Path path) {
RectF bounds = new RectF();
path.computeBounds(bounds, false);
diff --git a/lottie/src/test/java/com/airbnb/lottie/LottieCompositionFactoryTest.java b/lottie/src/test/java/com/airbnb/lottie/LottieCompositionFactoryTest.java
index 7474cac..3470d53 100644
--- a/lottie/src/test/java/com/airbnb/lottie/LottieCompositionFactoryTest.java
+++ b/lottie/src/test/java/com/airbnb/lottie/LottieCompositionFactoryTest.java
@@ -13,14 +13,12 @@
import java.io.InputStream;
import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNotSame;
import static junit.framework.Assert.assertNull;
import static okio.Okio.buffer;
import static okio.Okio.source;
import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
@SuppressWarnings("ReferenceEquality")
public class LottieCompositionFactoryTest extends BaseTest {
@@ -120,7 +118,6 @@
JsonReader reader = JsonReader.of(buffer(source(getNeverCompletingInputStream())));
LottieCompositionFactory.setMaxCacheSize(1);
LottieResult<LottieComposition> taskFoo1 = LottieCompositionFactory.fromJsonReaderSync(reader, "foo");
- LottieResult<LottieComposition> taskBar = LottieCompositionFactory.fromJsonReaderSync(reader, "bar");
LottieResult<LottieComposition> taskFoo2 = LottieCompositionFactory.fromJsonReaderSync(reader, "foo");
assertNotSame(taskFoo1, taskFoo2);
}
diff --git a/lottie/src/test/java/com/airbnb/lottie/LottieTaskTest.java b/lottie/src/test/java/com/airbnb/lottie/LottieTaskTest.java
index 4dbb4ea..f7f2e1a 100644
--- a/lottie/src/test/java/com/airbnb/lottie/LottieTaskTest.java
+++ b/lottie/src/test/java/com/airbnb/lottie/LottieTaskTest.java
@@ -25,11 +25,7 @@
@Test
public void testListener() {
- LottieTask<Integer> task = new LottieTask<>(new Callable<LottieResult<Integer>>() {
- @Override public LottieResult<Integer> call() {
- return new LottieResult<>(5);
- }
- }, true)
+ new LottieTask<>(() -> new LottieResult<>(5), true)
.addListener(successListener)
.addFailureListener(failureListener);
verify(successListener, times(1)).onResult(5);
@@ -39,10 +35,8 @@
@Test
public void testException() {
final IllegalStateException exception = new IllegalStateException("foo");
- LottieTask<Integer> task = new LottieTask<>(new Callable<LottieResult<Integer>>() {
- @Override public LottieResult<Integer> call() {
- throw exception;
- }
+ new LottieTask<>((Callable<LottieResult<Integer>>) () -> {
+ throw exception;
}, true)
.addListener(successListener)
.addFailureListener(failureListener);
diff --git a/snapshot-tests/src/androidTest/java/com/airbnb/lottie/snapshots/utils/HappoSnapshotter.kt b/snapshot-tests/src/androidTest/java/com/airbnb/lottie/snapshots/utils/HappoSnapshotter.kt
index 3f5fdc3..872abd5 100644
--- a/snapshot-tests/src/androidTest/java/com/airbnb/lottie/snapshots/utils/HappoSnapshotter.kt
+++ b/snapshot-tests/src/androidTest/java/com/airbnb/lottie/snapshots/utils/HappoSnapshotter.kt
@@ -102,10 +102,14 @@
val json = JsonObject()
val snaps = JsonArray()
json.add("snaps", snaps)
- snapshots.forEach {
- snaps.add(it.toJson())
+ snapshots.forEach { s ->
+ snaps.add(s.toJson())
}
- reportNames.forEach { upload(it, json) }
+ Log.d(L.TAG, "Finished creating snapshot report")
+ reportNames.forEach { reportName ->
+ Log.d(L.TAG, "Uploading $reportName")
+ upload(reportName, json)
+ }
}
private suspend fun upload(reportName: String, json: JsonElement) {