Skip to content

Commit

Permalink
Merge pull request #1 from airbnb/cleanup
Browse files Browse the repository at this point in the history
Set interpolators in some missing places
  • Loading branch information
gpeal authored Oct 7, 2016
2 parents 94dea1c + ad73595 commit b676708
Show file tree
Hide file tree
Showing 77 changed files with 299 additions and 403 deletions.
Binary file modified LotteSample/screenshots/Alarm 10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified LotteSample/screenshots/Alarm 15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified LotteSample/screenshots/Alarm 20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LotteSample/screenshots/BusinessTravel01 0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LotteSample/screenshots/BusinessTravel01 10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LotteSample/screenshots/BusinessTravel01 100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LotteSample/screenshots/BusinessTravel01 15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LotteSample/screenshots/BusinessTravel01 25.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LotteSample/screenshots/BusinessTravel01 30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LotteSample/screenshots/BusinessTravel01 40.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LotteSample/screenshots/BusinessTravel01 5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LotteSample/screenshots/BusinessTravel01 50.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LotteSample/screenshots/BusinessTravel01 60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LotteSample/screenshots/BusinessTravel01 70.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LotteSample/screenshots/BusinessTravel01 80.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LotteSample/screenshots/BusinessTravel01 90.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed LotteSample/screenshots/BusinessTravel01_Still 0.png
Binary file not shown.
Binary file removed LotteSample/screenshots/BusinessTravel02_Still 0.png
Binary file not shown.
Binary file added LotteSample/screenshots/BusinessTravel03 0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LotteSample/screenshots/BusinessTravel03 10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LotteSample/screenshots/BusinessTravel03 15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LotteSample/screenshots/BusinessTravel03 20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LotteSample/screenshots/BusinessTravel03 25.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LotteSample/screenshots/BusinessTravel03 30.png
Binary file added LotteSample/screenshots/BusinessTravel03 40.png
Binary file added LotteSample/screenshots/BusinessTravel03 5.png
Binary file added LotteSample/screenshots/BusinessTravel03 50.png
Binary file added LotteSample/screenshots/BusinessTravel03 60.png
Binary file modified LotteSample/screenshots/CheckSwitch 15.png
Binary file modified LotteSample/screenshots/CheckSwitch 20.png
Binary file modified LotteSample/screenshots/CheckSwitch 60.png
Binary file modified LotteSample/screenshots/CheckSwitch 70.png
Binary file modified LotteSample/screenshots/Diamond 2 15.png
Binary file modified LotteSample/screenshots/Diamond 2 20.png
Binary file modified LotteSample/screenshots/Lightbulb 10.png
Binary file modified LotteSample/screenshots/Lightbulb 15.png
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ public LotteTest() {
@Test
public void testHosts() {
TestRobot.testStaticFile(getActivity(), "Hosts Still.json");
TestRobot.testStaticFile(getActivity(), "BusinessTravel01_Still.json");
TestRobot.testStaticFile(getActivity(), "BusinessTravel02_Still.json");
TestRobot.testStaticFile(getActivity(), "BusinessTravel03_Still.json");
TestRobot.testAnimatedFile(getActivity(), "BusinessTravel01.json");
TestRobot.testAnimatedFile(getActivity(), "BusinessTravel03.json");
TestRobot.testAnimatedFile(getActivity(), "LightBulb.json");
TestRobot.testAnimatedFile(getActivity(), "Diamond 2.json");
TestRobot.testAnimatedFile(getActivity(), "CheckSwitch.json");
Expand Down
1 change: 1 addition & 0 deletions LotteSample/src/main/assets/BusinessTravel01.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion LotteSample/src/main/assets/BusinessTravel01_Still.json

This file was deleted.

1 change: 1 addition & 0 deletions LotteSample/src/main/assets/BusinessTravel02.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion LotteSample/src/main/assets/BusinessTravel02_Still.json

This file was deleted.

1 change: 1 addition & 0 deletions LotteSample/src/main/assets/BusinessTravel03.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion LotteSample/src/main/assets/BusinessTravel03_Still.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public abstract class BaseLotteAnimatableValue<T> implements LotteAnimatableValu
protected final Observable<T> observable = new Observable<>();
final List<T> keyValues = new ArrayList<>();
protected final List<Float> keyTimes = new ArrayList<>();
final List<Interpolator> timingFunctions = new ArrayList<>();
final List<Interpolator> interpolators = new ArrayList<>();
long delay;
protected long duration;

Expand Down Expand Up @@ -88,7 +88,7 @@ private void buildAnimationForKeyframes(JSONArray keyframes) {

if (outValue != null) {
keyValues.add(outValue);
timingFunctions.add(new LinearInterpolator());
interpolators.add(new LinearInterpolator());
outValue = null;
}

Expand All @@ -101,8 +101,8 @@ private void buildAnimationForKeyframes(JSONArray keyframes) {
observable.setValue(initialValue);
}
keyValues.add(startValue);
if (!timingFunctions.isEmpty()) {
timingFunctions.add(new LinearInterpolator());
if (!interpolators.isEmpty()) {
interpolators.add(new LinearInterpolator());
}
}
addStartValue = false;
Expand Down Expand Up @@ -132,7 +132,7 @@ private void buildAnimationForKeyframes(JSONArray keyframes) {
} else {
timingFunction = new LinearInterpolator();
}
timingFunctions.add(timingFunction);
interpolators.add(timingFunction);
}

keyTimes.add(timePercentage);
Expand Down Expand Up @@ -162,5 +162,5 @@ public Observable<T> getObservable() {

protected abstract T valueFromObject(Object array) throws JSONException;

public abstract LotteKeyframeAnimation animationForKeyPath(@LotteAnimatableProperty.AnimatableProperty int property);
public abstract LotteKeyframeAnimation animationForKeyPath();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.graphics.Color;

import com.airbnb.lotte.animation.LotteAnimatableProperty.AnimatableProperty;
import com.airbnb.lotte.utils.LotteColorKeyframeAnimation;
import com.airbnb.lotte.utils.LotteKeyframeAnimation;

Expand Down Expand Up @@ -40,17 +39,16 @@ protected Integer valueFromObject(Object object) throws JSONException {


@Override
public LotteKeyframeAnimation animationForKeyPath(@AnimatableProperty int property) {
public LotteKeyframeAnimation animationForKeyPath() {
if (!hasAnimation()) {
return null;
}
LotteKeyframeAnimation animation = new LotteColorKeyframeAnimation(property, duration, compDuration, keyTimes, keyValues);
LotteColorKeyframeAnimation animation = new LotteColorKeyframeAnimation(duration, compDuration, keyTimes, keyValues, interpolators);
animation.setStartDelay(delay);
animation.setInterpolators(timingFunctions);
animation.addUpdateListener(new LotteKeyframeAnimation.AnimationListener() {
animation.addUpdateListener(new LotteKeyframeAnimation.AnimationListener<Integer>() {
@Override
public void onValueChanged(Object progress) {
observable.setValue((Integer) progress);
public void onValueChanged(Integer progress) {
observable.setValue(progress);
}
});
return animation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ protected Float valueFromObject(Object object) throws JSONException {
}

@Override
public LotteKeyframeAnimation animationForKeyPath(@LotteAnimatableProperty.AnimatableProperty int property) {
LotteKeyframeAnimation<Float> animation = new LotteNumberKeyframeAnimation<>(property, duration, compDuration, keyTimes, Float.class, keyValues);
public LotteKeyframeAnimation animationForKeyPath() {
LotteKeyframeAnimation<Float> animation = new LotteNumberKeyframeAnimation<>(duration, compDuration, keyTimes, Float.class, keyValues, interpolators);
animation.setStartDelay(delay);
animation.addUpdateListener(new LotteKeyframeAnimation.AnimationListener<Float>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ protected Integer valueFromObject(Object object) throws JSONException {
}

@Override
public LotteKeyframeAnimation animationForKeyPath(@LotteAnimatableProperty.AnimatableProperty int property) {
LotteKeyframeAnimation<Integer> animation = new LotteNumberKeyframeAnimation<>(property, duration, compDuration, keyTimes, Integer.class, keyValues);
public LotteKeyframeAnimation animationForKeyPath() {
LotteKeyframeAnimation<Integer> animation = new LotteNumberKeyframeAnimation<>(duration, compDuration, keyTimes, Integer.class, keyValues, interpolators);
animation.setStartDelay(delay);
animation.addUpdateListener(new LotteKeyframeAnimation.AnimationListener<Integer>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;

import com.airbnb.lotte.animation.LotteAnimatableProperty.AnimatableProperty;
import com.airbnb.lotte.model.RemapInterface;
import com.airbnb.lotte.utils.JsonUtils;
import com.airbnb.lotte.utils.LotteKeyframeAnimation;
Expand All @@ -32,7 +31,7 @@ public class LotteAnimatableNumberValue implements LotteAnimatableValue<Number>

private final List<Float> valueKeyframes = new ArrayList<>();
private final List<Float> keyTimes = new ArrayList<>();
private final List<Interpolator> timingFunctions = new ArrayList<>();
private final List<Interpolator> interpolators = new ArrayList<>();
private long delay;
private long duration;
private long startFrame;
Expand Down Expand Up @@ -96,7 +95,7 @@ private void buildAnimationForKeyframes(JSONArray keyframes) {

if (outValue != null) {
valueKeyframes.add(outValue);
timingFunctions.add(new LinearInterpolator());
interpolators.add(new LinearInterpolator());
outValue = null;
}

Expand All @@ -108,8 +107,8 @@ private void buildAnimationForKeyframes(JSONArray keyframes) {
observable.setValue(initialValue);
}
valueKeyframes.add(startValue);
if (!timingFunctions.isEmpty()) {
timingFunctions.add(new LinearInterpolator());
if (!interpolators.isEmpty()) {
interpolators.add(new LinearInterpolator());
}
}
addStartValue = false;
Expand Down Expand Up @@ -139,7 +138,7 @@ private void buildAnimationForKeyframes(JSONArray keyframes) {
} else {
timingFunction = new LinearInterpolator();
}
timingFunctions.add(timingFunction);
interpolators.add(timingFunction);
}

keyTimes.add(timePercentage);
Expand All @@ -160,9 +159,9 @@ private Float numberValueFromObject(Object valueObject) throws JSONException {
if (valueObject instanceof Float) {
return (Float) valueObject;
} else if (valueObject instanceof JSONArray && ((JSONArray) valueObject).get(0) instanceof Double) {
return new Float(((JSONArray) valueObject).getDouble(0));
return (float) ((JSONArray) valueObject).getDouble(0);
} else if (valueObject instanceof JSONArray && ((JSONArray) valueObject).get(0) instanceof Integer) {
return new Float(((JSONArray) valueObject).getInt(0));
return (float) ((JSONArray) valueObject).getInt(0);
}
return null;
}
Expand Down Expand Up @@ -197,13 +196,13 @@ public float getInitialValue() {


@Override
public LotteKeyframeAnimation animationForKeyPath(@AnimatableProperty int property) {
LotteKeyframeAnimation<Float> animation = new LotteNumberKeyframeAnimation<>(property, duration, compDuration, keyTimes, Float.class, valueKeyframes);
public LotteKeyframeAnimation animationForKeyPath() {
LotteNumberKeyframeAnimation<Float> animation = new LotteNumberKeyframeAnimation<>(duration, compDuration, keyTimes, Float.class, valueKeyframes, interpolators);
animation.setStartDelay(delay);
animation.addUpdateListener(new LotteKeyframeAnimation.AnimationListener() {
animation.addUpdateListener(new LotteKeyframeAnimation.AnimationListener<Float>() {
@Override
public void onValueChanged(Object progress) {
observable.setValue((Number) progress);
public void onValueChanged(Float progress) {
observable.setValue(progress);
}
});
return animation;
Expand All @@ -221,9 +220,6 @@ public Observable<Number> getObservable() {

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("LotteAnimatableNumberValue{");
sb.append("initialValue=").append(initialValue);
sb.append('}');
return sb.toString();
return "LotteAnimatableNumberValue{" + "initialValue=" + initialValue + '}';
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.airbnb.lotte.animation;

import android.graphics.PointF;
import android.graphics.Rect;
import android.support.v4.view.animation.PathInterpolatorCompat;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;

import com.airbnb.lotte.animation.LotteAnimatableProperty.AnimatableProperty;
import com.airbnb.lotte.utils.LotteKeyframeAnimation;
import com.airbnb.lotte.utils.LottePathKeyframeAnimation;
import com.airbnb.lotte.utils.LottePointKeyframeAnimation;
Expand Down Expand Up @@ -38,6 +36,7 @@ public class LotteAnimatablePointValue implements LotteAnimatableValue<PointF> {
private long durationFrames;
private int frameRate;

@SuppressWarnings("EmptyCatchBlock")
public LotteAnimatablePointValue(JSONObject pointValues, int frameRate, long compDuration) {
this.compDuration = compDuration;
usePathAnimation = true;
Expand Down Expand Up @@ -141,9 +140,8 @@ private void buildAnimationForKeyframes(JSONArray keyframes) {
PointF vertex = pointFromValueArray(keyframe.getJSONArray("e"));
pointKeyframes.add(vertex);
if (cp1 != null && cp2 != null) {
PointF inVertex = startPoint;
animationPath.cubicTo(
inVertex.x + cp1.x, inVertex.y + cp1.y,
startPoint.x + cp1.x, startPoint.y + cp1.y,
vertex.x + cp2.x, vertex.y + cp2.y,
vertex.x, vertex.y);
} else {
Expand Down Expand Up @@ -195,7 +193,7 @@ private PointF pointFromValueObject(JSONObject value) {

PointF point = new PointF();
if (x instanceof JSONArray) {
point.x = new Float(((JSONArray) x).getDouble(0));
point.x = (float) ((JSONArray) x).getDouble(0);
} else {
if (x instanceof Integer) {
point.x = (Integer) x;
Expand All @@ -205,7 +203,7 @@ private PointF pointFromValueObject(JSONObject value) {
}

if (y instanceof JSONArray) {
point.y = new Float(((JSONArray) y).getDouble(0));
point.y = (float) ((JSONArray) y).getDouble(0);
} else {
if (y instanceof Integer) {
point.y = (Integer) y;
Expand All @@ -220,23 +218,6 @@ private PointF pointFromValueObject(JSONObject value) {
}
}


public void remapPointsFromBounds(Rect fromBounds, Rect toBounds) {
// TODO: this is broken. Maybe not necessary.
// if (pointKeyframes.isEmpty()) {
// initialPoint = new PointF(
// MiscUtils.remapValue(initialPoint.x, fromBounds.left, fromBounds.width(), toBounds.left, toBounds.width()),
// MiscUtils.remapValue(initialPoint.y, fromBounds.top, fromBounds.height(), toBounds.top, toBounds.height()));
// } else {
// for (PointF point : pointKeyframes) {
// point.set(
// MiscUtils.remapValue(point.x, fromBounds.left, fromBounds.width(), toBounds.left, toBounds.width()),
// MiscUtils.remapValue(point.y, fromBounds.top, fromBounds.height(), toBounds.top, toBounds.height()));
//
// }
// }
}

public void setUsePathAnimation(boolean usePathAnimation) {
this.usePathAnimation = usePathAnimation;
}
Expand All @@ -251,24 +232,24 @@ public PointF getInitialPoint() {
}

@Override
public LotteKeyframeAnimation animationForKeyPath(@AnimatableProperty int property) {
public LotteKeyframeAnimation animationForKeyPath() {
if (!hasAnimation()) {
return null;
}

LotteKeyframeAnimation animation;
LotteKeyframeAnimation<PointF> animation;
if (!animationPath.isEmpty() && usePathAnimation) {
animation = new LottePathKeyframeAnimation(property, duration, compDuration, keyTimes, animationPath);
animation = new LottePathKeyframeAnimation(duration, compDuration, keyTimes, animationPath, interpolators);
} else {
animation = new LottePointKeyframeAnimation(property, duration, compDuration, keyTimes, pointKeyframes);
animation = new LottePointKeyframeAnimation(duration, compDuration, keyTimes, pointKeyframes, interpolators);
}
animation.setStartDelay(delay);
animation.addUpdateListener(new LotteKeyframeAnimation.AnimationListener<PointF>() {
@Override
public void onValueChanged(PointF progress) {
observable.setValue(progress);
}
});
animation.setStartDelay(delay);
return animation;
}

Expand All @@ -279,9 +260,6 @@ public boolean hasAnimation() {

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("LotteAnimatablePointValue{");
sb.append("initialPoint=").append(initialPoint);
sb.append('}');
return sb.toString();
return "LotteAnimatablePointValue{" + "initialPoint=" + initialPoint + '}';
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;

import com.airbnb.lotte.animation.LotteAnimatableProperty.AnimatableProperty;
import com.airbnb.lotte.utils.JsonUtils;
import com.airbnb.lotte.utils.LotteKeyframeAnimation;
import com.airbnb.lotte.utils.LotteTransform3D;
Expand Down Expand Up @@ -157,9 +156,8 @@ public LotteTransform3D getInitialScale() {
}

@Override
public LotteKeyframeAnimation animationForKeyPath(@AnimatableProperty int property) {
LotteKeyframeAnimation animation = new LotteTransformKeyframeAnimation(property, duration, compDuration, keyTimes, scaleKeyframes);
animation.setInterpolators(interpolators);
public LotteKeyframeAnimation animationForKeyPath() {
LotteKeyframeAnimation animation = new LotteTransformKeyframeAnimation(duration, compDuration, keyTimes, scaleKeyframes, interpolators);
animation.setStartDelay(delay);
animation.addUpdateListener(new LotteKeyframeAnimation.AnimationListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,12 @@ private PointF vertexAtIndex(int idx, JSONArray points) {
}

@Override
public LotteKeyframeAnimation animationForKeyPath(@LotteAnimatableProperty.AnimatableProperty int property) {
LotteShapeKeyframeAnimation animation = new LotteShapeKeyframeAnimation(property, duration, compDuration, keyTimes, shapeKeyframes);
animation.setInterpolators(interpolators);
animation.addUpdateListener(new LotteKeyframeAnimation.AnimationListener() {
public LotteKeyframeAnimation animationForKeyPath() {
LotteShapeKeyframeAnimation animation = new LotteShapeKeyframeAnimation(duration, compDuration, keyTimes, shapeKeyframes, interpolators);
animation.addUpdateListener(new LotteKeyframeAnimation.AnimationListener<Path>() {
@Override
public void onValueChanged(Object progress) {
observable.setValue((Path) progress);
public void onValueChanged(Path progress) {
observable.setValue(progress);
}
});
return animation;
Expand Down
Loading

0 comments on commit b676708

Please sign in to comment.