Skip to content

Commit

Permalink
More IntelliJ inspection cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gpeal authored Oct 7, 2016
1 parent b676708 commit 2ca576a
Show file tree
Hide file tree
Showing 38 changed files with 125 additions and 356 deletions.
4 changes: 2 additions & 2 deletions lotte/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'

android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
buildToolsVersion "24.0.3"

defaultConfig {
minSdkVersion 16
Expand All @@ -26,7 +26,7 @@ dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
testCompile "org.robolectric:robolectric:3.1.2"
}

This file was deleted.

2 changes: 1 addition & 1 deletion lotte/src/main/java/com/airbnb/lotte/L.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.airbnb.lotte;

public class L {
public static boolean DBG = false;
public static final boolean DBG = false;
}
8 changes: 2 additions & 6 deletions lotte/src/main/java/com/airbnb/lotte/LotteAnimationView.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private JSONObject setAnimationSync(InputStream file) {
}
}

public void setJson(JSONObject json) {
private void setJson(JSONObject json) {
// TODO: cancel these if the iew gets detached.
new AsyncTask<JSONObject, Void, LotteComposition>() {

Expand All @@ -189,7 +189,7 @@ private void setJsonSync(JSONObject json) {
setComposition(composition);
}

public void setComposition(@NonNull LotteComposition composition) {
private void setComposition(@NonNull LotteComposition composition) {
this.composition = composition;
rootAnimatableLayer.setCompDuration(composition.getDuration());
rootAnimatableLayer.setBounds(0, 0, composition.getBounds().width(), composition.getBounds().height());
Expand Down Expand Up @@ -279,10 +279,6 @@ public void setProgress(@FloatRange(from=0f, to=1f) float progress) {
rootAnimatableLayer.setProgress(progress);
}

public int getFrameRate() {
return composition != null ? composition.getFrameRate() : 60;
}

public long getDuration() {
return composition != null ? composition.getDuration() : 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@

public abstract class BaseLotteAnimatableValue<T> implements LotteAnimatableValue<T> {

protected final Observable<T> observable = new Observable<>();
final Observable<T> observable = new Observable<>();
final List<T> keyValues = new ArrayList<>();
protected final List<Float> keyTimes = new ArrayList<>();
final List<Float> keyTimes = new ArrayList<>();
final List<Interpolator> interpolators = new ArrayList<>();
long delay;
protected long duration;
long duration;
final long compDuration;

private long startFrame;
private long durationFrames;
protected int frameRate;
protected final long compDuration;
private final int frameRate;

T initialValue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.ArrayList;
import java.util.List;

@SuppressWarnings({"FieldCanBeLocal", "unused"})
public class LotteAnimatableNumberValue implements LotteAnimatableValue<Number> {

private final Observable<Number> observable = new Observable<>();
Expand Down Expand Up @@ -182,11 +181,6 @@ public float remap(float inValue) {
observable.setValue(remapInterface.remap((float) observable.getValue()));
}

public void remapWith(RemapInterface remapInterface) {
this.remapInterface = remapInterface;
observable.setValue(remapInterface.remap((float) observable.getValue()));
}

public float getInitialValue() {
if (remapInterface != null) {
return remapInterface.remap(initialValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
import java.util.List;

public class LotteAnimatablePointValue implements LotteAnimatableValue<PointF> {
private static final String TAG = LotteAnimatablePointValue.class.getSimpleName();

private final Observable<PointF> observable = new Observable<>();
private final List<PointF> pointKeyframes = new ArrayList<>();
private final List<Float> keyTimes = new ArrayList<>();
private final List<Interpolator> interpolators = new ArrayList<>();
private final long compDuration;
private final int frameRate;

private boolean usePathAnimation = true;
private PointF initialPoint;
Expand All @@ -34,7 +34,6 @@ public class LotteAnimatablePointValue implements LotteAnimatableValue<PointF> {
private long duration;
private long startFrame;
private long durationFrames;
private int frameRate;

@SuppressWarnings("EmptyCatchBlock")
public LotteAnimatablePointValue(JSONObject pointValues, int frameRate, long compDuration) {
Expand Down Expand Up @@ -238,7 +237,7 @@ public LotteKeyframeAnimation animationForKeyPath() {
}

LotteKeyframeAnimation<PointF> animation;
if (!animationPath.isEmpty() && usePathAnimation) {
if (animationPath.hasSegments() && usePathAnimation) {
animation = new LottePathKeyframeAnimation(duration, compDuration, keyTimes, animationPath, interpolators);
} else {
animation = new LottePointKeyframeAnimation(duration, compDuration, keyTimes, pointKeyframes, interpolators);
Expand All @@ -255,7 +254,7 @@ public void onValueChanged(PointF progress) {

@Override
public boolean hasAnimation() {
return !animationPath.isEmpty() || !pointKeyframes.isEmpty();
return animationPath.hasSegments() || !pointKeyframes.isEmpty();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,19 @@
import java.util.ArrayList;
import java.util.List;

@SuppressWarnings({"EmptyCatchBlock", "unused"})
@SuppressWarnings({"EmptyCatchBlock"})
public class LotteAnimatableScaleValue implements LotteAnimatableValue<LotteTransform3D> {
private static final String TAG = LotteAnimatableScaleValue.class.getSimpleName();

private final Observable<LotteTransform3D> observable = new Observable<>();
private LotteTransform3D initialScale;
private final List<LotteTransform3D> scaleKeyframes = new ArrayList<>();
private final List<Float> keyTimes = new ArrayList<>();
private final List<Interpolator> interpolators = new ArrayList<>();
private final int frameRate;
private final long compDuration;

private long delay;
private long duration;
private int startFrame;
private int durationFrames;
private int frameRate;
private final long compDuration;


public LotteAnimatableScaleValue(JSONObject scaleValues, int frameRate, long compDuration) {
Expand All @@ -48,7 +45,7 @@ public LotteAnimatableScaleValue(JSONObject scaleValues, int frameRate, long com
buildAnimationForKeyframes((JSONArray) value);
} else {
// Single value, no animation.
initialScale = xformForValueArray((JSONArray) value);
initialScale = transformForValueArray((JSONArray) value);
observable.setValue(initialScale);
}

Expand All @@ -62,14 +59,14 @@ public LotteAnimatableScaleValue(JSONObject scaleValues, int frameRate, long com

private void buildAnimationForKeyframes(JSONArray keyframes) {
try {
startFrame = keyframes.getJSONObject(0).getInt("t");
int startFrame = keyframes.getJSONObject(0).getInt("t");
int endFrame = keyframes.getJSONObject(keyframes.length() - 1).getInt("t");

if (endFrame <= startFrame) {
throw new IllegalArgumentException("End frame must be after start frame " + endFrame + " vs " + startFrame);
}

durationFrames = endFrame - startFrame;
int durationFrames = endFrame - startFrame;

duration = (long) (durationFrames / (float) frameRate * 1000);
delay = (long) (startFrame / (float) frameRate * 1000);
Expand All @@ -92,7 +89,7 @@ private void buildAnimationForKeyframes(JSONArray keyframes) {
LotteTransform3D startValue = null;
if (addStartValue) {
if (keyframe.has("s")) {
startValue = xformForValueArray(keyframe.getJSONArray("s"));
startValue = transformForValueArray(keyframe.getJSONArray("s"));
if (i == 0) {
initialScale = startValue;
observable.setValue(initialScale);
Expand All @@ -112,7 +109,7 @@ private void buildAnimationForKeyframes(JSONArray keyframes) {
}

if (keyframe.has("e")) {
LotteTransform3D endValue = xformForValueArray(keyframe.getJSONArray("e"));
LotteTransform3D endValue = transformForValueArray(keyframe.getJSONArray("e"));
scaleKeyframes.add(endValue);

Interpolator interpolator;
Expand Down Expand Up @@ -140,7 +137,7 @@ private void buildAnimationForKeyframes(JSONArray keyframes) {
}
}

private LotteTransform3D xformForValueArray(JSONArray value) {
private LotteTransform3D transformForValueArray(JSONArray value) {
try {
if (value.length() >= 2) {
return new LotteTransform3D().scale((float) value.getDouble(0) / 100f, (float) value.getDouble(1) / 100f);
Expand All @@ -157,12 +154,12 @@ public LotteTransform3D getInitialScale() {

@Override
public LotteKeyframeAnimation animationForKeyPath() {
LotteKeyframeAnimation animation = new LotteTransformKeyframeAnimation(duration, compDuration, keyTimes, scaleKeyframes, interpolators);
LotteTransformKeyframeAnimation animation = new LotteTransformKeyframeAnimation(duration, compDuration, keyTimes, scaleKeyframes, interpolators);
animation.setStartDelay(delay);
animation.addUpdateListener(new LotteKeyframeAnimation.AnimationListener() {
animation.addUpdateListener(new LotteKeyframeAnimation.AnimationListener<LotteTransform3D>() {
@Override
public void onValueChanged(Object progress) {
observable.setValue((LotteTransform3D) progress);
public void onValueChanged(LotteTransform3D progress) {
observable.setValue(progress);
}
});
return animation;
Expand All @@ -180,9 +177,6 @@ public Observable<LotteTransform3D> getObservable() {

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("LotteAnimatableScaleValue{");
sb.append("initialScale=").append(initialScale);
sb.append('}');
return sb.toString();
return "LotteAnimatableScaleValue{" + "initialScale=" + initialScale + '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

@SuppressWarnings({"EmptyCatchBlock", "unused", "FieldCanBeLocal", "WeakerAccess"})
public class LotteAnimatableShapeValue implements LotteAnimatableValue<Path> {
private static final String TAG = LotteAnimatableShapeValue.class.getSimpleName();

private final Observable<Path> observable = new Observable<>();

Expand All @@ -35,9 +34,7 @@ public class LotteAnimatableShapeValue implements LotteAnimatableValue<Path> {
private final List<Interpolator> interpolators = new ArrayList<>();
private long delay;
private long duration;
private int startFrame;
private long durationFrames;
private int frameRate;
private final int frameRate;
private final long compDuration;

public LotteAnimatableShapeValue(JSONObject shapeValues, int frameRate, long compDuration, boolean closed) {
Expand All @@ -64,14 +61,14 @@ public LotteAnimatableShapeValue(JSONObject shapeValues, int frameRate, long com

private void buildAnimationForKeyFrames(JSONArray keyframes, boolean closed) {
try {
startFrame = keyframes.getJSONObject(0).getInt("t");
int startFrame = keyframes.getJSONObject(0).getInt("t");
int endFrame = keyframes.getJSONObject(keyframes.length() - 1).getInt("t");

if (endFrame <= startFrame) {
throw new IllegalArgumentException("End frame must be after start frame " + endFrame + " vs " + startFrame);
}

durationFrames = endFrame - startFrame;
long durationFrames = endFrame - startFrame;

duration = (long) (durationFrames / (float) frameRate * 1000);
delay = (long) (startFrame / (float) frameRate * 1000);
Expand Down Expand Up @@ -225,6 +222,7 @@ private PointF vertexAtIndex(int idx, JSONArray points) {
@Override
public LotteKeyframeAnimation animationForKeyPath() {
LotteShapeKeyframeAnimation animation = new LotteShapeKeyframeAnimation(duration, compDuration, keyTimes, shapeKeyframes, interpolators);
// animation.setStartDelay(delay);
animation.addUpdateListener(new LotteKeyframeAnimation.AnimationListener<Path>() {
@Override
public void onValueChanged(Path progress) {
Expand All @@ -246,9 +244,6 @@ public Observable<Path> getObservable() {

@Override
public String toString() {
final StringBuilder sb = new StringBuilder("LotteAnimatableShapeValue{");
sb.append("initialShape=").append(initialShape);
sb.append('}');
return sb.toString();
return "LotteAnimatableShapeValue{" + "initialShape=" + initialShape + '}';
}
}
56 changes: 0 additions & 56 deletions lotte/src/main/java/com/airbnb/lotte/animation/LotteAnimation.java

This file was deleted.

Loading

0 comments on commit 2ca576a

Please sign in to comment.