alexandroid/decompiled/jadx/sources/com/google/android/material/animation/MotionSpec.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

156 lines
5.8 KiB
Java

package com.google.android.material.animation;
import android.animation.Animator;
import android.animation.AnimatorInflater;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.Log;
import android.util.Property;
import androidx.annotation.AnimatorRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StyleableRes;
import androidx.collection.SimpleArrayMap;
import com.google.gson.Gson$$ExternalSyntheticBUOutline0;
import java.util.ArrayList;
import java.util.List;
import kotlinx.serialization.json.internal.AbstractJsonLexerKt;
import okio.Path$$ExternalSyntheticBUOutline0;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
/* loaded from: classes7.dex */
public class MotionSpec {
private static final String TAG = "MotionSpec";
private final SimpleArrayMap<String, MotionTiming> timings = new SimpleArrayMap<>();
private final SimpleArrayMap<String, PropertyValuesHolder[]> propertyValues = new SimpleArrayMap<>();
private static void addInfoFromAnimator(@NonNull MotionSpec motionSpec, Animator animator) {
if (!(animator instanceof ObjectAnimator)) {
Gson$$ExternalSyntheticBUOutline0.m((Object) animator, "Animator must be an ObjectAnimator: ");
return;
}
ObjectAnimator objectAnimator = (ObjectAnimator) animator;
motionSpec.setPropertyValues(objectAnimator.getPropertyName(), objectAnimator.getValues());
motionSpec.setTiming(objectAnimator.getPropertyName(), MotionTiming.createFromAnimator(objectAnimator));
}
@NonNull
private PropertyValuesHolder[] clonePropertyValuesHolder(@NonNull PropertyValuesHolder[] propertyValuesHolderArr) {
PropertyValuesHolder[] propertyValuesHolderArr2 = new PropertyValuesHolder[propertyValuesHolderArr.length];
for (int i = 0; i < propertyValuesHolderArr.length; i++) {
propertyValuesHolderArr2[i] = propertyValuesHolderArr[i].clone();
}
return propertyValuesHolderArr2;
}
@Nullable
public static MotionSpec createFromAttribute(@NonNull Context context, @NonNull TypedArray typedArray, @StyleableRes int i) {
int resourceId;
if (!typedArray.hasValue(i) || (resourceId = typedArray.getResourceId(i, 0)) == 0) {
return null;
}
return createFromResource(context, resourceId);
}
@Nullable
public static MotionSpec createFromResource(@NonNull Context context, @AnimatorRes int i) {
try {
Animator loadAnimator = AnimatorInflater.loadAnimator(context, i);
if (loadAnimator instanceof AnimatorSet) {
return createSpecFromAnimators(((AnimatorSet) loadAnimator).getChildAnimations());
}
if (loadAnimator == null) {
return null;
}
ArrayList arrayList = new ArrayList();
arrayList.add(loadAnimator);
return createSpecFromAnimators(arrayList);
} catch (Exception e) {
Log.w(TAG, "Can't load animation resource ID #0x" + Integer.toHexString(i), e);
return null;
}
}
@NonNull
private static MotionSpec createSpecFromAnimators(@NonNull List<Animator> list) {
MotionSpec motionSpec = new MotionSpec();
int size = list.size();
for (int i = 0; i < size; i++) {
addInfoFromAnimator(motionSpec, list.get(i));
}
return motionSpec;
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof MotionSpec) {
return this.timings.equals(((MotionSpec) obj).timings);
}
return false;
}
@NonNull
public <T> ObjectAnimator getAnimator(@NonNull String str, @NonNull T t, @NonNull Property<T, ?> property) {
ObjectAnimator ofPropertyValuesHolder = ObjectAnimator.ofPropertyValuesHolder(t, getPropertyValues(str));
ofPropertyValuesHolder.setProperty(property);
getTiming(str).apply(ofPropertyValuesHolder);
return ofPropertyValuesHolder;
}
@NonNull
public PropertyValuesHolder[] getPropertyValues(String str) {
if (hasPropertyValues(str)) {
return clonePropertyValuesHolder(this.propertyValues.get(str));
}
Path$$ExternalSyntheticBUOutline0.m();
return null;
}
public MotionTiming getTiming(String str) {
if (hasTiming(str)) {
return this.timings.get(str);
}
Path$$ExternalSyntheticBUOutline0.m();
return null;
}
public long getTotalDuration() {
int size = this.timings.getSize();
long j = 0;
for (int i = 0; i < size; i++) {
MotionTiming valueAt = this.timings.valueAt(i);
j = Math.max(j, valueAt.getDuration() + valueAt.getDelay());
}
return j;
}
public boolean hasPropertyValues(String str) {
return this.propertyValues.get(str) != null;
}
public boolean hasTiming(String str) {
return this.timings.get(str) != null;
}
public int hashCode() {
return this.timings.hashCode();
}
public void setPropertyValues(String str, PropertyValuesHolder[] propertyValuesHolderArr) {
this.propertyValues.put(str, propertyValuesHolderArr);
}
public void setTiming(String str, @Nullable MotionTiming motionTiming) {
this.timings.put(str, motionTiming);
}
@NonNull
public String toString() {
return "\n" + getClass().getName() + AbstractJsonLexerKt.BEGIN_OBJ + Integer.toHexString(System.identityHashCode(this)) + " timings: " + this.timings + "}\n";
}
}