Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Peal committed Jan 4, 2018
1 parent 685a314 commit 9810b4f
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 28 deletions.
Binary file modified LottieSample/libs/happo.aar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public void run() {
}

private void runAnimation(final String name) {
Log.d("Happo", "runAnimation " + name);
LottieComposition composition = LottieComposition.Factory.fromFileSync(context, name);
if (composition.getBounds().width() > 4 * Resources.getSystem().getDisplayMetrics().widthPixels ||
composition.getBounds().height() > 4 * Resources.getSystem().getDisplayMetrics().heightPixels) {
Expand All @@ -114,6 +115,7 @@ private void drawComposition(LottieComposition composition, String name) {
}
});
view.setComposition(composition);
Log.d("Happo", "Snapshotting " + name);
for (float progress : PROGRESS) {
view.setProgress(progress);
recordSnapshot(view, 1080, "android", name, Integer.toString((int) (progress * 100)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.support.test.rule.GrantPermissionRule;
import android.support.test.runner.AndroidJUnit4;
import android.text.TextUtils;
import android.util.Log;

import com.airbnb.happo.HappoRunner;
import com.airbnb.lottie.samples.MainActivity;
Expand Down Expand Up @@ -41,6 +42,7 @@ public class LottieTest {
String branch = TextUtils.isEmpty(com.airbnb.lottie.samples.BuildConfig.TRAVIS_GIT_BRANCH) ?
com.airbnb.lottie.samples.BuildConfig.GIT_BRANCH :
com.airbnb.lottie.samples.BuildConfig.TRAVIS_GIT_BRANCH;
Log.d("Happo", "Happo S3 " + com.airbnb.lottie.samples.BuildConfig.S3AccessKey);
HappoRunner.runTests(
mainActivityRule.getActivity(),
new LottieSnapshotProvider(mainActivityRule.getActivity()),
Expand Down
1 change: 0 additions & 1 deletion LottieSample/src/main/assets/Arrow.json

This file was deleted.

1 change: 0 additions & 1 deletion LottieSample/src/main/assets/Gradient.json

This file was deleted.

1 change: 0 additions & 1 deletion LottieSample/src/main/assets/Shapes.json

This file was deleted.

1 change: 0 additions & 1 deletion LottieSample/src/main/assets/Square.json

This file was deleted.

2 changes: 1 addition & 1 deletion LottieSample/src/main/res/layout/fragment_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:lottie_fileName="Camera.json"
app:lottie_fileName="Logo/LogoSmall.json"
app:lottie_loop="true" />
</FrameLayout>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public static void setEndFrames(List<? extends Keyframe<?>> keyframes) {

// Used by PathKeyframe but it has to be parsed by KeyFrame because we use a JsonReader to
// deserialzie the data so we have to parse everything in order
protected PointF pathCp1 = null;
protected PointF pathCp2 = null;
public PointF pathCp1 = null;
public PointF pathCp2 = null;


public Keyframe(@SuppressWarnings("NullableProblems") LottieComposition composition,
Expand Down Expand Up @@ -228,7 +228,7 @@ private static <T> Keyframe<T> parseKeyframe(LottieComposition composition, Json
endValue = startValue;
// TODO: create a HoldInterpolator so progress changes don't invalidate.
interpolator = LINEAR_INTERPOLATOR;
} else if (cp1 != null) {
} else if (cp1 != null && cp2 != null) {
cp1.x = MiscUtils.clamp(cp1.x, -scale, scale);
cp1.y = MiscUtils.clamp(cp1.y, -MAX_CP_VALUE, MAX_CP_VALUE);
cp2.x = MiscUtils.clamp(cp2.x, -scale, scale);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.support.annotation.Nullable;
import android.util.JsonReader;
import android.util.JsonToken;
import android.view.animation.Interpolator;

import com.airbnb.lottie.LottieComposition;
import com.airbnb.lottie.animation.Keyframe;
Expand All @@ -17,18 +16,17 @@
public class PathKeyframe extends Keyframe<PointF> {
@Nullable private Path path;

private PathKeyframe(LottieComposition composition, @Nullable PointF startValue,
@Nullable PointF endValue, @Nullable Interpolator interpolator,
float startFrame, @Nullable Float endFrame) {
super(composition, startValue, endValue, interpolator, startFrame, endFrame);
private PathKeyframe(LottieComposition composition, Keyframe<PointF> keyframe) {
super(composition, keyframe.startValue, keyframe.endValue, keyframe.interpolator,
keyframe.startFrame, keyframe.endFrame);

// This must use equals(float, float) because PointF didn't have an equals(PathF) method
// until KitKat...
boolean equals = endValue != null && startValue != null &&
startValue.equals(endValue.x, endValue.y);
//noinspection ConstantConditions
if (endValue != null && !equals) {
path = Utils.createPath(startValue, endValue, pathCp1, pathCp2);
path = Utils.createPath(startValue, endValue, keyframe.pathCp1, keyframe.pathCp2);
}
}

Expand All @@ -42,9 +40,7 @@ public static PathKeyframe newInstance(JsonReader reader, LottieComposition comp
Keyframe<PointF> keyframe = Keyframe.Factory.newInstance(
reader, composition, Utils.dpScale(), valueFactory, animated);


return new PathKeyframe(composition, keyframe.startValue,
keyframe.endValue, keyframe.interpolator, keyframe.startFrame, keyframe.endFrame);
return new PathKeyframe(composition, keyframe);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public static AnimatableTextProperties newInstance(
while (reader.hasNext()) {
switch (reader.nextName()) {
case "a":
anim = parseAnimatableTextProperties(reader, composition);
break;
default:
reader.skipValue();
anim = parseAnimatableTextProperties(reader, composition);
break;
default:
reader.skipValue();
}
}
reader.endObject();
Expand Down Expand Up @@ -75,6 +75,7 @@ private static AnimatableTextProperties parseAnimatableTextProperties(
reader.skipValue();
}
}
reader.endObject();

return new AnimatableTextProperties(color, stroke, strokeWidth, tracking);
}
Expand Down
12 changes: 5 additions & 7 deletions lottie/src/test/java/com/airbnb/lottie/KeyPathTest.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package com.airbnb.lottie;

import android.app.Application;
import android.util.JsonReader;

import com.airbnb.lottie.model.KeyPath;

import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;

import java.io.IOException;
import java.io.StringReader;
import java.util.List;

import static junit.framework.Assert.assertEquals;
Expand All @@ -32,13 +31,12 @@ public class KeyPathTest {

@Before
public void setupDrawable() {
Application context = RuntimeEnvironment.application;
lottieDrawable = new LottieDrawable();
try {
LottieComposition composition = LottieComposition.Factory
.fromJsonSync(new (Fixtures.SQUARES));
.fromJsonSync(new JsonReader(new StringReader(Fixtures.SQUARES)));
lottieDrawable.setComposition(composition);
} catch (JSONException e) {
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
Expand Down

0 comments on commit 9810b4f

Please sign in to comment.