Skip to content

Commit

Permalink
Cleaned up some javadocs
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Peal committed Dec 28, 2020
1 parent a71a9fb commit 1d3fca2
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 31 deletions.
6 changes: 6 additions & 0 deletions lottie/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
configurations.implementation.setCanBeResolved(true)
classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + configurations.implementation
}

tasks.withType(Javadoc) {
// This started failing with the following when upgrading to AGP 7 and JDK 11.
// TODO: investigate why once AGP 7 is stable.
// javadoc: error - The code being documented uses modules but the packages defined in https://developer.android.com/reference/ are in the unnamed module.
failOnError false
}

Expand Down
12 changes: 6 additions & 6 deletions lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
*
* @see <a href="http://airbnb.io/lottie">Full Documentation</a>
*/
@SuppressWarnings({"unused", "WeakerAccess"}) public class LottieAnimationView extends AppCompatImageView {
@SuppressWarnings({"WeakerAccess"}) public class LottieAnimationView extends AppCompatImageView {

private static final String TAG = LottieAnimationView.class.getSimpleName();
private static final LottieListener<Throwable> DEFAULT_FAILURE_LISTENER = new LottieListener<Throwable>() {
Expand Down Expand Up @@ -374,7 +374,7 @@ public boolean isMergePathsEnabledForKitKatAndAbove() {
*
* {@link R.attr#lottie_cacheComposition}
*/
public void setCacheComposition(boolean cacheComposition) {
public void setCacheComposition(boolean cacheComposition) {
this.cacheComposition = cacheComposition;
}

Expand Down Expand Up @@ -598,7 +598,7 @@ public boolean hasMatte() {
}

/**
* Plays the animation from the beginning. If speed is < 0, it will start at the end
* Plays the animation from the beginning. If speed is {@literal <} 0, it will start at the end
* and play towards the beginning
*/
@MainThread
Expand All @@ -612,7 +612,7 @@ public void playAnimation() {
}

/**
* Continues playing the animation from its current position. If speed < 0, it will play backwards
* Continues playing the animation from its current position. If speed {@literal <} 0, it will play backwards
* from the current position.
*/
@MainThread
Expand Down Expand Up @@ -737,14 +737,14 @@ public void reverseAnimationSpeed() {
}

/**
* Sets the playback speed. If speed < 0, the animation will play backwards.
* Sets the playback speed. If speed {@literal <} 0, the animation will play backwards.
*/
public void setSpeed(float speed) {
lottieDrawable.setSpeed(speed);
}

/**
* Returns the current playback speed. This will be < 0 if the animation is playing backwards.
* Returns the current playback speed. This will be {@literal <} 0 if the animation is playing backwards.
*/
public float getSpeed() {
return lottieDrawable.getSpeed();
Expand Down
28 changes: 16 additions & 12 deletions lottie/src/main/java/com/airbnb/lottie/LottieComposition.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import androidx.annotation.WorkerThread;
import androidx.collection.LongSparseArray;
import androidx.collection.SparseArrayCompat;
import android.util.Log;

import com.airbnb.lottie.model.Font;
import com.airbnb.lottie.model.FontCharacter;
Expand All @@ -20,7 +19,6 @@

import org.json.JSONObject;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -178,7 +176,7 @@ public List<Marker> getMarkers() {
@Nullable
public Marker getMarker(String markerName) {
int size = markers.size();
for (int i = 0; i < markers.size(); i++) {
for (int i = 0; i < size; i++) {
Marker marker = markers.get(i);
if (marker.matchesName(markerName)) {
return marker;
Expand Down Expand Up @@ -223,6 +221,7 @@ private Factory() {
/**
* @see LottieCompositionFactory#fromAsset(Context, String)
*/
@SuppressWarnings("deprecation")
@Deprecated
public static Cancellable fromAssetFileName(Context context, String fileName, OnCompositionLoadedListener l) {
ListenerAdapter listener = new ListenerAdapter(l);
Expand All @@ -233,6 +232,7 @@ public static Cancellable fromAssetFileName(Context context, String fileName, On
/**
* @see LottieCompositionFactory#fromRawRes(Context, int)
*/
@SuppressWarnings("deprecation")
@Deprecated
public static Cancellable fromRawFile(Context context, @RawRes int resId, OnCompositionLoadedListener l) {
ListenerAdapter listener = new ListenerAdapter(l);
Expand All @@ -241,8 +241,9 @@ public static Cancellable fromRawFile(Context context, @RawRes int resId, OnComp
}

/**
* @see LottieCompositionFactory#fromJsonInputStream(InputStream)
* @see LottieCompositionFactory#fromJsonInputStream(InputStream, String)
*/
@SuppressWarnings("deprecation")
@Deprecated
public static Cancellable fromInputStream(InputStream stream, OnCompositionLoadedListener l) {
ListenerAdapter listener = new ListenerAdapter(l);
Expand All @@ -251,8 +252,9 @@ public static Cancellable fromInputStream(InputStream stream, OnCompositionLoade
}

/**
* @see LottieCompositionFactory#fromJsonString(String)
* @see LottieCompositionFactory#fromJsonString(String, String)
*/
@SuppressWarnings("deprecation")
@Deprecated
public static Cancellable fromJsonString(String jsonString, OnCompositionLoadedListener l) {
ListenerAdapter listener = new ListenerAdapter(l);
Expand All @@ -261,8 +263,9 @@ public static Cancellable fromJsonString(String jsonString, OnCompositionLoadedL
}

/**
* @see LottieCompositionFactory#fromJsonReader(JsonReader)
* @see LottieCompositionFactory#fromJsonReader(JsonReader, String)
*/
@SuppressWarnings("deprecation")
@Deprecated
public static Cancellable fromJsonReader(JsonReader reader, OnCompositionLoadedListener l) {
ListenerAdapter listener = new ListenerAdapter(l);
Expand All @@ -281,7 +284,7 @@ public static LottieComposition fromFileSync(Context context, String fileName) {
}

/**
* @see LottieCompositionFactory#fromJsonInputStreamSync(InputStream)
* @see LottieCompositionFactory#fromJsonInputStreamSync(InputStream, String)
*/
@Nullable
@WorkerThread
Expand All @@ -293,7 +296,7 @@ public static LottieComposition fromInputStreamSync(InputStream stream) {
/**
* This will now auto-close the input stream!
*
* @see LottieCompositionFactory#fromJsonInputStreamSync(InputStream, boolean)
* @see LottieCompositionFactory#fromJsonInputStreamSync(InputStream, String)
*/
@Nullable
@WorkerThread
Expand All @@ -306,7 +309,7 @@ public static LottieComposition fromInputStreamSync(InputStream stream, boolean
}

/**
* @see LottieCompositionFactory#fromJsonSync(JSONObject)
* @see LottieCompositionFactory#fromJsonSync(JSONObject, String)
*/
@Nullable
@WorkerThread
Expand All @@ -316,7 +319,7 @@ public static LottieComposition fromJsonSync(@SuppressWarnings("unused") Resourc
}

/**
* @see LottieCompositionFactory#fromJsonStringSync(String)
* @see LottieCompositionFactory#fromJsonStringSync(String, String)
*/
@Nullable
@WorkerThread
Expand All @@ -326,15 +329,16 @@ public static LottieComposition fromJsonSync(String json) {
}

/**
* @see LottieCompositionFactory#fromJsonReaderSync(JsonReader)
* @see LottieCompositionFactory#fromJsonReaderSync(JsonReader, String)
*/
@Nullable
@WorkerThread
@Deprecated
public static LottieComposition fromJsonSync(JsonReader reader) throws IOException {
public static LottieComposition fromJsonSync(JsonReader reader) {
return LottieCompositionFactory.fromJsonReaderSync(reader, null).getValue();
}

@SuppressWarnings("deprecation")
private static final class ListenerAdapter implements LottieListener<LottieComposition>, Cancellable {
private final OnCompositionLoadedListener listener;
private boolean cancelled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import okio.BufferedSource;
import okio.Okio;

import static com.airbnb.lottie.parser.moshi.JsonReader.of;
import static com.airbnb.lottie.utils.Utils.closeQuietly;
import static okio.Okio.buffer;
import static okio.Okio.source;
Expand Down Expand Up @@ -63,7 +62,7 @@ private LottieCompositionFactory() {

/**
* Set the maximum number of compositions to keep cached in memory.
* This must be > 0.
* This must be {@literal >} 0.
*/
public static void setMaxCacheSize(int size) {
LottieCompositionCache.getInstance().resize(size);
Expand Down Expand Up @@ -310,7 +309,7 @@ public static LottieResult<LottieComposition> fromJsonInputStreamSync(InputStrea
@WorkerThread
private static LottieResult<LottieComposition> fromJsonInputStreamSync(InputStream stream, @Nullable String cacheKey, boolean close) {
try {
return fromJsonReaderSync(of(buffer(source(stream))), cacheKey);
return fromJsonReaderSync(JsonReader.of(buffer(source(stream))), cacheKey);
} finally {
if (close) {
closeQuietly(stream);
Expand Down Expand Up @@ -365,7 +364,7 @@ public static LottieResult<LottieComposition> fromJsonStringSync(String json, @N


ByteArrayInputStream stream = new ByteArrayInputStream(json.getBytes());
return fromJsonReaderSync(of(buffer(source(stream))), cacheKey);
return fromJsonReaderSync(JsonReader.of(buffer(source(stream))), cacheKey);
}

public static LottieTask<LottieComposition> fromJsonReader(final JsonReader reader, @Nullable final String cacheKey) {
Expand Down Expand Up @@ -439,7 +438,7 @@ private static LottieResult<LottieComposition> fromZipStreamSyncInternal(ZipInpu
} else if (entry.getName().equalsIgnoreCase("manifest.json")) { //ignore .lottie manifest
inputStream.closeEntry();
} else if (entry.getName().contains(".json")) {
com.airbnb.lottie.parser.moshi.JsonReader reader = of(buffer(source(inputStream)));
com.airbnb.lottie.parser.moshi.JsonReader reader = JsonReader.of(buffer(source(inputStream)));
composition = LottieCompositionFactory.fromJsonReaderSyncInternal(reader, null, false).getValue();
} else if (entryName.contains(".png") || entryName.contains(".webp")) {
String[] splitName = entryName.split("/");
Expand Down
8 changes: 4 additions & 4 deletions lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ public boolean isRunning() {
}

/**
* Plays the animation from the beginning. If speed is < 0, it will start at the end
* Plays the animation from the beginning. If speed is {@literal <} 0, it will start at the end
* and play towards the beginning
*/
@MainThread
Expand Down Expand Up @@ -461,7 +461,7 @@ public void endAnimation() {
}

/**
* Continues playing the animation from its current position. If speed < 0, it will play backwards
* Continues playing the animation from its current position. If speed {@literal <} 0, it will play backwards
* from the current position.
*/
@MainThread
Expand Down Expand Up @@ -715,14 +715,14 @@ public void reverseAnimationSpeed() {
}

/**
* Sets the playback speed. If speed < 0, the animation will play backwards.
* Sets the playback speed. If speed {@literal <} 0, the animation will play backwards.
*/
public void setSpeed(float speed) {
animator.setSpeed(speed);
}

/**
* Returns the current playback speed. This will be < 0 if the animation is playing backwards.
* Returns the current playback speed. This will be {@literal <} 0 if the animation is playing backwards.
*/
public float getSpeed() {
return animator.getSpeed();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void clear() {

/**
* Set the maximum number of compositions to keep cached in memory.
* This must be > 0.
* This must be {@literal >} 0.
*/
public void resize(int size) {
cache.resize(size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@
* skip the value's nested tokens, which may otherwise conflict.
*
* <p>If a value may be null, you should first check using {@link #peek()}.
* Null literals can be consumed using either {@link #nextNull()} or {@link
* #skipValue()}.
* Null literals can be consumed using {@link #skipValue()}.
*
* <h3>Example</h3>
* Suppose we'd like to parse a stream of messages such as the following: <pre> {@code
Expand Down Expand Up @@ -364,7 +363,7 @@ public final String getPath() {
}

/**
* A set of strings to be chosen with {@link #selectName} or {@link #selectString}. This prepares
* A set of strings to be chosen with {@link #selectName}. This prepares
* the encoded values of the strings so they can be read directly from the input source.
*/
public static final class Options {
Expand Down

0 comments on commit 1d3fca2

Please sign in to comment.