/
LottieShapeFill.java
59 lines (48 loc) · 1.86 KB
/
LottieShapeFill.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package com.airbnb.lottie.model;
import android.util.Log;
import com.airbnb.lottie.L;
import com.airbnb.lottie.animation.LottieAnimatableColorValue;
import com.airbnb.lottie.animation.LottieAnimatableIntegerValue;
import org.json.JSONException;
import org.json.JSONObject;
@SuppressWarnings({"EmptyCatchBlock", "WeakerAccess", "FieldCanBeLocal"})
public class LottieShapeFill {
private static final String TAG = LottieShapeFill.class.getSimpleName();
private boolean fillEnabled;
private LottieAnimatableColorValue color;
private LottieAnimatableIntegerValue opacity;
public LottieShapeFill(JSONObject json, int frameRate, long compDuration) {
JSONObject jsonColor = null;
try {
jsonColor = json.getJSONObject("c");
} catch (JSONException e) { }
if (jsonColor != null) {
color = new LottieAnimatableColorValue(jsonColor, frameRate, compDuration);
}
JSONObject jsonOpacity = null;
try {
jsonOpacity = json.getJSONObject("o");
} catch (JSONException e) { }
if (jsonOpacity != null) {
opacity = new LottieAnimatableIntegerValue(jsonOpacity, frameRate, compDuration);
opacity.remapValues(0, 100, 0, 255);
}
try {
fillEnabled = json.getBoolean("fillEnabled");
} catch (JSONException e) { }
if (L.DBG) Log.d(TAG, "Parsed new shape fill " + toString());
}
public LottieAnimatableColorValue getColor() {
return color;
}
public LottieAnimatableIntegerValue getOpacity() {
return opacity;
}
@Override
public String toString() {
return "LottieShapeFill{" + "color=" + Integer.toHexString(color.getInitialValue()) +
", fillEnabled=" + fillEnabled +
", opacity=" + opacity.getInitialValue() +
'}';
}
}