2025-03-31 16:33:42 +02:00

481 lines
20 KiB
Java

package androidx.constraintlayout.motion.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseIntArray;
import androidx.constraintlayout.core.motion.utils.TypedValues;
import androidx.constraintlayout.motion.utils.ViewOscillator;
import androidx.constraintlayout.motion.utils.ViewSpline;
import androidx.constraintlayout.widget.ConstraintAttribute;
import androidx.constraintlayout.widget.R;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
/* loaded from: classes.dex */
public class KeyCycle extends Key {
public static final int KEY_TYPE = 4;
static final String NAME = "KeyCycle";
public static final int SHAPE_BOUNCE = 6;
public static final int SHAPE_COS_WAVE = 5;
public static final int SHAPE_REVERSE_SAW_WAVE = 4;
public static final int SHAPE_SAW_WAVE = 3;
public static final int SHAPE_SIN_WAVE = 0;
public static final int SHAPE_SQUARE_WAVE = 1;
public static final int SHAPE_TRIANGLE_WAVE = 2;
private static final String TAG = "KeyCycle";
public static final String WAVE_OFFSET = "waveOffset";
public static final String WAVE_PERIOD = "wavePeriod";
public static final String WAVE_PHASE = "wavePhase";
public static final String WAVE_SHAPE = "waveShape";
private String mTransitionEasing = null;
private int mCurveFit = 0;
private int mWaveShape = -1;
private String mCustomWaveShape = null;
private float mWavePeriod = Float.NaN;
private float mWaveOffset = 0.0f;
private float mWavePhase = 0.0f;
private float mProgress = Float.NaN;
private int mWaveVariesBy = -1;
private float mAlpha = Float.NaN;
private float mElevation = Float.NaN;
private float mRotation = Float.NaN;
private float mTransitionPathRotate = Float.NaN;
private float mRotationX = Float.NaN;
private float mRotationY = Float.NaN;
private float mScaleX = Float.NaN;
private float mScaleY = Float.NaN;
private float mTranslationX = Float.NaN;
private float mTranslationY = Float.NaN;
private float mTranslationZ = Float.NaN;
public KeyCycle() {
this.mType = 4;
this.mCustomConstraints = new HashMap<>();
}
@Override // androidx.constraintlayout.motion.widget.Key
public void load(Context context, AttributeSet attrs) {
Loader.read(this, context.obtainStyledAttributes(attrs, R.styleable.KeyCycle));
}
@Override // androidx.constraintlayout.motion.widget.Key
public void getAttributeNames(HashSet<String> attributes) {
if (!Float.isNaN(this.mAlpha)) {
attributes.add("alpha");
}
if (!Float.isNaN(this.mElevation)) {
attributes.add("elevation");
}
if (!Float.isNaN(this.mRotation)) {
attributes.add(Key.ROTATION);
}
if (!Float.isNaN(this.mRotationX)) {
attributes.add("rotationX");
}
if (!Float.isNaN(this.mRotationY)) {
attributes.add("rotationY");
}
if (!Float.isNaN(this.mScaleX)) {
attributes.add("scaleX");
}
if (!Float.isNaN(this.mScaleY)) {
attributes.add("scaleY");
}
if (!Float.isNaN(this.mTransitionPathRotate)) {
attributes.add("transitionPathRotate");
}
if (!Float.isNaN(this.mTranslationX)) {
attributes.add("translationX");
}
if (!Float.isNaN(this.mTranslationY)) {
attributes.add("translationY");
}
if (!Float.isNaN(this.mTranslationZ)) {
attributes.add("translationZ");
}
if (this.mCustomConstraints.size() > 0) {
Iterator<String> it = this.mCustomConstraints.keySet().iterator();
while (it.hasNext()) {
attributes.add("CUSTOM," + it.next());
}
}
}
public void addCycleValues(HashMap<String, ViewOscillator> oscSet) {
ViewOscillator viewOscillator;
ViewOscillator viewOscillator2;
for (String str : oscSet.keySet()) {
if (str.startsWith("CUSTOM")) {
ConstraintAttribute constraintAttribute = this.mCustomConstraints.get(str.substring(7));
if (constraintAttribute != null && constraintAttribute.getType() == ConstraintAttribute.AttributeType.FLOAT_TYPE && (viewOscillator = oscSet.get(str)) != null) {
viewOscillator.setPoint(this.mFramePosition, this.mWaveShape, this.mCustomWaveShape, this.mWaveVariesBy, this.mWavePeriod, this.mWaveOffset, this.mWavePhase, constraintAttribute.getValueToInterpolate(), constraintAttribute);
}
} else {
float value = getValue(str);
if (!Float.isNaN(value) && (viewOscillator2 = oscSet.get(str)) != null) {
viewOscillator2.setPoint(this.mFramePosition, this.mWaveShape, this.mCustomWaveShape, this.mWaveVariesBy, this.mWavePeriod, this.mWaveOffset, this.mWavePhase, value);
}
}
}
}
public float getValue(String key) {
key.hashCode();
switch (key) {
case "rotationX":
return this.mRotationX;
case "rotationY":
return this.mRotationY;
case "translationX":
return this.mTranslationX;
case "translationY":
return this.mTranslationY;
case "translationZ":
return this.mTranslationZ;
case "progress":
return this.mProgress;
case "scaleX":
return this.mScaleX;
case "scaleY":
return this.mScaleY;
case "rotation":
return this.mRotation;
case "elevation":
return this.mElevation;
case "transitionPathRotate":
return this.mTransitionPathRotate;
case "alpha":
return this.mAlpha;
case "waveOffset":
return this.mWaveOffset;
case "wavePhase":
return this.mWavePhase;
default:
if (key.startsWith("CUSTOM")) {
return Float.NaN;
}
Log.v("WARNING! KeyCycle", " UNKNOWN " + key);
return Float.NaN;
}
}
@Override // androidx.constraintlayout.motion.widget.Key
public void addValues(HashMap<String, ViewSpline> splines) {
Debug.logStack(TypedValues.CycleType.NAME, "add " + splines.size() + " values", 2);
for (String str : splines.keySet()) {
ViewSpline viewSpline = splines.get(str);
if (viewSpline != null) {
str.hashCode();
switch (str) {
case "rotationX":
viewSpline.setPoint(this.mFramePosition, this.mRotationX);
break;
case "rotationY":
viewSpline.setPoint(this.mFramePosition, this.mRotationY);
break;
case "translationX":
viewSpline.setPoint(this.mFramePosition, this.mTranslationX);
break;
case "translationY":
viewSpline.setPoint(this.mFramePosition, this.mTranslationY);
break;
case "translationZ":
viewSpline.setPoint(this.mFramePosition, this.mTranslationZ);
break;
case "progress":
viewSpline.setPoint(this.mFramePosition, this.mProgress);
break;
case "scaleX":
viewSpline.setPoint(this.mFramePosition, this.mScaleX);
break;
case "scaleY":
viewSpline.setPoint(this.mFramePosition, this.mScaleY);
break;
case "rotation":
viewSpline.setPoint(this.mFramePosition, this.mRotation);
break;
case "elevation":
viewSpline.setPoint(this.mFramePosition, this.mElevation);
break;
case "transitionPathRotate":
viewSpline.setPoint(this.mFramePosition, this.mTransitionPathRotate);
break;
case "alpha":
viewSpline.setPoint(this.mFramePosition, this.mAlpha);
break;
case "waveOffset":
viewSpline.setPoint(this.mFramePosition, this.mWaveOffset);
break;
case "wavePhase":
viewSpline.setPoint(this.mFramePosition, this.mWavePhase);
break;
default:
if (str.startsWith("CUSTOM")) {
break;
} else {
Log.v("WARNING KeyCycle", " UNKNOWN " + str);
break;
}
}
}
}
}
private static class Loader {
private static final int ANDROID_ALPHA = 9;
private static final int ANDROID_ELEVATION = 10;
private static final int ANDROID_ROTATION = 11;
private static final int ANDROID_ROTATION_X = 12;
private static final int ANDROID_ROTATION_Y = 13;
private static final int ANDROID_SCALE_X = 15;
private static final int ANDROID_SCALE_Y = 16;
private static final int ANDROID_TRANSLATION_X = 17;
private static final int ANDROID_TRANSLATION_Y = 18;
private static final int ANDROID_TRANSLATION_Z = 19;
private static final int CURVE_FIT = 4;
private static final int FRAME_POSITION = 2;
private static final int PROGRESS = 20;
private static final int TARGET_ID = 1;
private static final int TRANSITION_EASING = 3;
private static final int TRANSITION_PATH_ROTATE = 14;
private static final int WAVE_OFFSET = 7;
private static final int WAVE_PERIOD = 6;
private static final int WAVE_PHASE = 21;
private static final int WAVE_SHAPE = 5;
private static final int WAVE_VARIES_BY = 8;
private static SparseIntArray mAttrMap;
private Loader() {
}
static {
SparseIntArray sparseIntArray = new SparseIntArray();
mAttrMap = sparseIntArray;
sparseIntArray.append(R.styleable.KeyCycle_motionTarget, 1);
mAttrMap.append(R.styleable.KeyCycle_framePosition, 2);
mAttrMap.append(R.styleable.KeyCycle_transitionEasing, 3);
mAttrMap.append(R.styleable.KeyCycle_curveFit, 4);
mAttrMap.append(R.styleable.KeyCycle_waveShape, 5);
mAttrMap.append(R.styleable.KeyCycle_wavePeriod, 6);
mAttrMap.append(R.styleable.KeyCycle_waveOffset, 7);
mAttrMap.append(R.styleable.KeyCycle_waveVariesBy, 8);
mAttrMap.append(R.styleable.KeyCycle_android_alpha, 9);
mAttrMap.append(R.styleable.KeyCycle_android_elevation, 10);
mAttrMap.append(R.styleable.KeyCycle_android_rotation, 11);
mAttrMap.append(R.styleable.KeyCycle_android_rotationX, 12);
mAttrMap.append(R.styleable.KeyCycle_android_rotationY, 13);
mAttrMap.append(R.styleable.KeyCycle_transitionPathRotate, 14);
mAttrMap.append(R.styleable.KeyCycle_android_scaleX, 15);
mAttrMap.append(R.styleable.KeyCycle_android_scaleY, 16);
mAttrMap.append(R.styleable.KeyCycle_android_translationX, 17);
mAttrMap.append(R.styleable.KeyCycle_android_translationY, 18);
mAttrMap.append(R.styleable.KeyCycle_android_translationZ, 19);
mAttrMap.append(R.styleable.KeyCycle_motionProgress, 20);
mAttrMap.append(R.styleable.KeyCycle_wavePhase, 21);
}
/* JADX INFO: Access modifiers changed from: private */
public static void read(KeyCycle c, TypedArray a) {
int indexCount = a.getIndexCount();
for (int i = 0; i < indexCount; i++) {
int index = a.getIndex(i);
switch (mAttrMap.get(index)) {
case 1:
if (MotionLayout.IS_IN_EDIT_MODE) {
c.mTargetId = a.getResourceId(index, c.mTargetId);
if (c.mTargetId == -1) {
c.mTargetString = a.getString(index);
break;
} else {
break;
}
} else if (a.peekValue(index).type == 3) {
c.mTargetString = a.getString(index);
break;
} else {
c.mTargetId = a.getResourceId(index, c.mTargetId);
break;
}
case 2:
c.mFramePosition = a.getInt(index, c.mFramePosition);
break;
case 3:
c.mTransitionEasing = a.getString(index);
break;
case 4:
c.mCurveFit = a.getInteger(index, c.mCurveFit);
break;
case 5:
if (a.peekValue(index).type == 3) {
c.mCustomWaveShape = a.getString(index);
c.mWaveShape = 7;
break;
} else {
c.mWaveShape = a.getInt(index, c.mWaveShape);
break;
}
case 6:
c.mWavePeriod = a.getFloat(index, c.mWavePeriod);
break;
case 7:
if (a.peekValue(index).type == 5) {
c.mWaveOffset = a.getDimension(index, c.mWaveOffset);
break;
} else {
c.mWaveOffset = a.getFloat(index, c.mWaveOffset);
break;
}
case 8:
c.mWaveVariesBy = a.getInt(index, c.mWaveVariesBy);
break;
case 9:
c.mAlpha = a.getFloat(index, c.mAlpha);
break;
case 10:
c.mElevation = a.getDimension(index, c.mElevation);
break;
case 11:
c.mRotation = a.getFloat(index, c.mRotation);
break;
case 12:
c.mRotationX = a.getFloat(index, c.mRotationX);
break;
case 13:
c.mRotationY = a.getFloat(index, c.mRotationY);
break;
case 14:
c.mTransitionPathRotate = a.getFloat(index, c.mTransitionPathRotate);
break;
case 15:
c.mScaleX = a.getFloat(index, c.mScaleX);
break;
case 16:
c.mScaleY = a.getFloat(index, c.mScaleY);
break;
case 17:
c.mTranslationX = a.getDimension(index, c.mTranslationX);
break;
case 18:
c.mTranslationY = a.getDimension(index, c.mTranslationY);
break;
case 19:
c.mTranslationZ = a.getDimension(index, c.mTranslationZ);
break;
case 20:
c.mProgress = a.getFloat(index, c.mProgress);
break;
case 21:
c.mWavePhase = a.getFloat(index, c.mWavePhase) / 360.0f;
break;
default:
Log.e(TypedValues.CycleType.NAME, "unused attribute 0x" + Integer.toHexString(index) + " " + mAttrMap.get(index));
break;
}
}
}
}
@Override // androidx.constraintlayout.motion.widget.Key
public void setValue(String tag, Object value) {
tag.hashCode();
switch (tag) {
case "motionProgress":
this.mProgress = toFloat(value);
break;
case "transitionEasing":
this.mTransitionEasing = value.toString();
break;
case "rotationX":
this.mRotationX = toFloat(value);
break;
case "rotationY":
this.mRotationY = toFloat(value);
break;
case "translationX":
this.mTranslationX = toFloat(value);
break;
case "translationY":
this.mTranslationY = toFloat(value);
break;
case "translationZ":
this.mTranslationZ = toFloat(value);
break;
case "scaleX":
this.mScaleX = toFloat(value);
break;
case "scaleY":
this.mScaleY = toFloat(value);
break;
case "rotation":
this.mRotation = toFloat(value);
break;
case "elevation":
this.mElevation = toFloat(value);
break;
case "transitionPathRotate":
this.mTransitionPathRotate = toFloat(value);
break;
case "alpha":
this.mAlpha = toFloat(value);
break;
case "waveOffset":
this.mWaveOffset = toFloat(value);
break;
case "wavePeriod":
this.mWavePeriod = toFloat(value);
break;
case "curveFit":
this.mCurveFit = toInt(value);
break;
case "wavePhase":
this.mWavePhase = toFloat(value);
break;
case "waveShape":
if (value instanceof Integer) {
this.mWaveShape = toInt(value);
break;
} else {
this.mWaveShape = 7;
this.mCustomWaveShape = value.toString();
break;
}
}
}
@Override // androidx.constraintlayout.motion.widget.Key
public Key copy(Key src) {
super.copy(src);
KeyCycle keyCycle = (KeyCycle) src;
this.mTransitionEasing = keyCycle.mTransitionEasing;
this.mCurveFit = keyCycle.mCurveFit;
this.mWaveShape = keyCycle.mWaveShape;
this.mCustomWaveShape = keyCycle.mCustomWaveShape;
this.mWavePeriod = keyCycle.mWavePeriod;
this.mWaveOffset = keyCycle.mWaveOffset;
this.mWavePhase = keyCycle.mWavePhase;
this.mProgress = keyCycle.mProgress;
this.mWaveVariesBy = keyCycle.mWaveVariesBy;
this.mAlpha = keyCycle.mAlpha;
this.mElevation = keyCycle.mElevation;
this.mRotation = keyCycle.mRotation;
this.mTransitionPathRotate = keyCycle.mTransitionPathRotate;
this.mRotationX = keyCycle.mRotationX;
this.mRotationY = keyCycle.mRotationY;
this.mScaleX = keyCycle.mScaleX;
this.mScaleY = keyCycle.mScaleY;
this.mTranslationX = keyCycle.mTranslationX;
this.mTranslationY = keyCycle.mTranslationY;
this.mTranslationZ = keyCycle.mTranslationZ;
return this;
}
@Override // androidx.constraintlayout.motion.widget.Key
/* renamed from: clone */
public Key mo49clone() {
return new KeyCycle().copy(this);
}
}