mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-30 11:02:31 -06:00
2699 lines
113 KiB
Java
2699 lines
113 KiB
Java
package androidx.constraintlayout.motion.widget;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.TypedArray;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.DashPathEffect;
|
|
import android.graphics.Paint;
|
|
import android.graphics.Path;
|
|
import android.graphics.Rect;
|
|
import android.graphics.RectF;
|
|
import android.os.Bundle;
|
|
import android.util.AttributeSet;
|
|
import android.util.Log;
|
|
import android.util.SparseArray;
|
|
import android.util.SparseIntArray;
|
|
import android.view.MotionEvent;
|
|
import android.view.VelocityTracker;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.animation.Interpolator;
|
|
import android.widget.TextView;
|
|
import androidx.constraintlayout.motion.utils.StopLogic;
|
|
import androidx.constraintlayout.motion.widget.MotionScene;
|
|
import androidx.constraintlayout.solver.widgets.Barrier;
|
|
import androidx.constraintlayout.solver.widgets.ConstraintAnchor;
|
|
import androidx.constraintlayout.solver.widgets.ConstraintWidget;
|
|
import androidx.constraintlayout.solver.widgets.ConstraintWidgetContainer;
|
|
import androidx.constraintlayout.solver.widgets.Flow;
|
|
import androidx.constraintlayout.solver.widgets.Guideline;
|
|
import androidx.constraintlayout.solver.widgets.Helper;
|
|
import androidx.constraintlayout.solver.widgets.HelperWidget;
|
|
import androidx.constraintlayout.solver.widgets.VirtualLayout;
|
|
import androidx.constraintlayout.widget.ConstraintHelper;
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
import androidx.constraintlayout.widget.ConstraintSet;
|
|
import androidx.constraintlayout.widget.Constraints;
|
|
import androidx.constraintlayout.widget.R;
|
|
import androidx.core.internal.view.SupportMenu;
|
|
import androidx.core.view.NestedScrollingParent3;
|
|
import androidx.core.view.ViewCompat;
|
|
import androidx.exifinterface.media.ExifInterface;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import tech.rabbit.r1launcher.BuildConfig;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class MotionLayout extends ConstraintLayout implements NestedScrollingParent3 {
|
|
private static final boolean DEBUG = false;
|
|
public static final int DEBUG_SHOW_NONE = 0;
|
|
public static final int DEBUG_SHOW_PATH = 2;
|
|
public static final int DEBUG_SHOW_PROGRESS = 1;
|
|
private static final float EPSILON = 1.0E-5f;
|
|
public static boolean IS_IN_EDIT_MODE = false;
|
|
static final int MAX_KEY_FRAMES = 50;
|
|
static final String TAG = "MotionLayout";
|
|
public static final int TOUCH_UP_COMPLETE = 0;
|
|
public static final int TOUCH_UP_COMPLETE_TO_END = 2;
|
|
public static final int TOUCH_UP_COMPLETE_TO_START = 1;
|
|
public static final int TOUCH_UP_DECELERATE = 4;
|
|
public static final int TOUCH_UP_DECELERATE_AND_COMPLETE = 5;
|
|
public static final int TOUCH_UP_STOP = 3;
|
|
public static final int VELOCITY_LAYOUT = 1;
|
|
public static final int VELOCITY_POST_LAYOUT = 0;
|
|
public static final int VELOCITY_STATIC_LAYOUT = 3;
|
|
public static final int VELOCITY_STATIC_POST_LAYOUT = 2;
|
|
boolean firstDown;
|
|
private float lastPos;
|
|
private float lastY;
|
|
private long mAnimationStartTime;
|
|
private int mBeginState;
|
|
private RectF mBoundsCheck;
|
|
int mCurrentState;
|
|
int mDebugPath;
|
|
private DecelerateInterpolator mDecelerateLogic;
|
|
private DesignTool mDesignTool;
|
|
DevModeDraw mDevModeDraw;
|
|
private int mEndState;
|
|
int mEndWrapHeight;
|
|
int mEndWrapWidth;
|
|
HashMap<View, MotionController> mFrameArrayList;
|
|
private int mFrames;
|
|
int mHeightMeasureMode;
|
|
private boolean mInLayout;
|
|
boolean mInTransition;
|
|
boolean mIndirectTransition;
|
|
private boolean mInteractionEnabled;
|
|
Interpolator mInterpolator;
|
|
boolean mIsAnimating;
|
|
private boolean mKeepAnimating;
|
|
private KeyCache mKeyCache;
|
|
private long mLastDrawTime;
|
|
private float mLastFps;
|
|
private int mLastHeightMeasureSpec;
|
|
int mLastLayoutHeight;
|
|
int mLastLayoutWidth;
|
|
float mLastVelocity;
|
|
private int mLastWidthMeasureSpec;
|
|
private float mListenerPosition;
|
|
private int mListenerState;
|
|
protected boolean mMeasureDuringTransition;
|
|
Model mModel;
|
|
private boolean mNeedsFireTransitionCompleted;
|
|
int mOldHeight;
|
|
int mOldWidth;
|
|
private ArrayList<MotionHelper> mOnHideHelpers;
|
|
private ArrayList<MotionHelper> mOnShowHelpers;
|
|
float mPostInterpolationPosition;
|
|
private View mRegionView;
|
|
MotionScene mScene;
|
|
float mScrollTargetDT;
|
|
float mScrollTargetDX;
|
|
float mScrollTargetDY;
|
|
long mScrollTargetTime;
|
|
int mStartWrapHeight;
|
|
int mStartWrapWidth;
|
|
private StateCache mStateCache;
|
|
private StopLogic mStopLogic;
|
|
private boolean mTemporalInterpolator;
|
|
ArrayList<Integer> mTransitionCompleted;
|
|
private float mTransitionDuration;
|
|
float mTransitionGoalPosition;
|
|
private boolean mTransitionInstantly;
|
|
float mTransitionLastPosition;
|
|
private long mTransitionLastTime;
|
|
private TransitionListener mTransitionListener;
|
|
private ArrayList<TransitionListener> mTransitionListeners;
|
|
float mTransitionPosition;
|
|
TransitionState mTransitionState;
|
|
boolean mUndergoingMotion;
|
|
int mWidthMeasureMode;
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
/* loaded from: classes.dex */
|
|
public interface MotionTracker {
|
|
void addMovement(MotionEvent motionEvent);
|
|
|
|
void clear();
|
|
|
|
void computeCurrentVelocity(int i);
|
|
|
|
void computeCurrentVelocity(int i, float f);
|
|
|
|
float getXVelocity();
|
|
|
|
float getXVelocity(int i);
|
|
|
|
float getYVelocity();
|
|
|
|
float getYVelocity(int i);
|
|
|
|
void recycle();
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public interface TransitionListener {
|
|
void onTransitionChange(MotionLayout motionLayout, int i, int i2, float f);
|
|
|
|
void onTransitionCompleted(MotionLayout motionLayout, int i);
|
|
|
|
void onTransitionStarted(MotionLayout motionLayout, int i, int i2);
|
|
|
|
void onTransitionTrigger(MotionLayout motionLayout, int i, boolean z, float f);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public enum TransitionState {
|
|
UNDEFINED,
|
|
SETUP,
|
|
MOVING,
|
|
FINISHED
|
|
}
|
|
|
|
private static boolean willJump(float f, float f2, float f3) {
|
|
if (f > 0.0f) {
|
|
float f4 = f / f3;
|
|
return f2 + ((f * f4) - (((f3 * f4) * f4) / 2.0f)) > 1.0f;
|
|
}
|
|
float f5 = (-f) / f3;
|
|
return f2 + ((f * f5) + (((f3 * f5) * f5) / 2.0f)) < 0.0f;
|
|
}
|
|
|
|
public int getCurrentState() {
|
|
return this.mCurrentState;
|
|
}
|
|
|
|
public int getEndState() {
|
|
return this.mEndState;
|
|
}
|
|
|
|
public float getProgress() {
|
|
return this.mTransitionLastPosition;
|
|
}
|
|
|
|
public int getStartState() {
|
|
return this.mBeginState;
|
|
}
|
|
|
|
public float getTargetPosition() {
|
|
return this.mTransitionGoalPosition;
|
|
}
|
|
|
|
public float getVelocity() {
|
|
return this.mLastVelocity;
|
|
}
|
|
|
|
public boolean isInteractionEnabled() {
|
|
return this.mInteractionEnabled;
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.ViewParent, androidx.core.view.NestedScrollingParent
|
|
public boolean onNestedFling(View view, float f, float f2, boolean z) {
|
|
return false;
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.ViewParent, androidx.core.view.NestedScrollingParent
|
|
public boolean onNestedPreFling(View view, float f, float f2) {
|
|
return false;
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingParent2
|
|
public void onNestedScroll(View view, int i, int i2, int i3, int i4, int i5) {
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingParent2
|
|
public void onNestedScrollAccepted(View view, View view2, int i, int i2) {
|
|
}
|
|
|
|
public void setInteractionEnabled(boolean z) {
|
|
this.mInteractionEnabled = z;
|
|
}
|
|
|
|
public void setTransitionListener(TransitionListener transitionListener) {
|
|
this.mTransitionListener = transitionListener;
|
|
}
|
|
|
|
public MotionLayout(Context context) {
|
|
super(context);
|
|
this.mLastVelocity = 0.0f;
|
|
this.mBeginState = -1;
|
|
this.mCurrentState = -1;
|
|
this.mEndState = -1;
|
|
this.mLastWidthMeasureSpec = 0;
|
|
this.mLastHeightMeasureSpec = 0;
|
|
this.mInteractionEnabled = true;
|
|
this.mFrameArrayList = new HashMap<>();
|
|
this.mAnimationStartTime = 0L;
|
|
this.mTransitionDuration = 1.0f;
|
|
this.mTransitionPosition = 0.0f;
|
|
this.mTransitionLastPosition = 0.0f;
|
|
this.mTransitionGoalPosition = 0.0f;
|
|
this.mInTransition = false;
|
|
this.mIndirectTransition = false;
|
|
this.mDebugPath = 0;
|
|
this.mTemporalInterpolator = false;
|
|
this.mStopLogic = new StopLogic();
|
|
this.mDecelerateLogic = new DecelerateInterpolator();
|
|
this.firstDown = true;
|
|
this.mUndergoingMotion = false;
|
|
this.mKeepAnimating = false;
|
|
this.mOnShowHelpers = null;
|
|
this.mOnHideHelpers = null;
|
|
this.mTransitionListeners = null;
|
|
this.mFrames = 0;
|
|
this.mLastDrawTime = -1L;
|
|
this.mLastFps = 0.0f;
|
|
this.mListenerState = 0;
|
|
this.mListenerPosition = 0.0f;
|
|
this.mIsAnimating = false;
|
|
this.mMeasureDuringTransition = false;
|
|
this.mKeyCache = new KeyCache();
|
|
this.mInLayout = false;
|
|
this.mTransitionState = TransitionState.UNDEFINED;
|
|
this.mModel = new Model();
|
|
this.mNeedsFireTransitionCompleted = false;
|
|
this.mBoundsCheck = new RectF();
|
|
this.mRegionView = null;
|
|
this.mTransitionCompleted = new ArrayList<>();
|
|
init(null);
|
|
}
|
|
|
|
public MotionLayout(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
this.mLastVelocity = 0.0f;
|
|
this.mBeginState = -1;
|
|
this.mCurrentState = -1;
|
|
this.mEndState = -1;
|
|
this.mLastWidthMeasureSpec = 0;
|
|
this.mLastHeightMeasureSpec = 0;
|
|
this.mInteractionEnabled = true;
|
|
this.mFrameArrayList = new HashMap<>();
|
|
this.mAnimationStartTime = 0L;
|
|
this.mTransitionDuration = 1.0f;
|
|
this.mTransitionPosition = 0.0f;
|
|
this.mTransitionLastPosition = 0.0f;
|
|
this.mTransitionGoalPosition = 0.0f;
|
|
this.mInTransition = false;
|
|
this.mIndirectTransition = false;
|
|
this.mDebugPath = 0;
|
|
this.mTemporalInterpolator = false;
|
|
this.mStopLogic = new StopLogic();
|
|
this.mDecelerateLogic = new DecelerateInterpolator();
|
|
this.firstDown = true;
|
|
this.mUndergoingMotion = false;
|
|
this.mKeepAnimating = false;
|
|
this.mOnShowHelpers = null;
|
|
this.mOnHideHelpers = null;
|
|
this.mTransitionListeners = null;
|
|
this.mFrames = 0;
|
|
this.mLastDrawTime = -1L;
|
|
this.mLastFps = 0.0f;
|
|
this.mListenerState = 0;
|
|
this.mListenerPosition = 0.0f;
|
|
this.mIsAnimating = false;
|
|
this.mMeasureDuringTransition = false;
|
|
this.mKeyCache = new KeyCache();
|
|
this.mInLayout = false;
|
|
this.mTransitionState = TransitionState.UNDEFINED;
|
|
this.mModel = new Model();
|
|
this.mNeedsFireTransitionCompleted = false;
|
|
this.mBoundsCheck = new RectF();
|
|
this.mRegionView = null;
|
|
this.mTransitionCompleted = new ArrayList<>();
|
|
init(attributeSet);
|
|
}
|
|
|
|
public MotionLayout(Context context, AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
this.mLastVelocity = 0.0f;
|
|
this.mBeginState = -1;
|
|
this.mCurrentState = -1;
|
|
this.mEndState = -1;
|
|
this.mLastWidthMeasureSpec = 0;
|
|
this.mLastHeightMeasureSpec = 0;
|
|
this.mInteractionEnabled = true;
|
|
this.mFrameArrayList = new HashMap<>();
|
|
this.mAnimationStartTime = 0L;
|
|
this.mTransitionDuration = 1.0f;
|
|
this.mTransitionPosition = 0.0f;
|
|
this.mTransitionLastPosition = 0.0f;
|
|
this.mTransitionGoalPosition = 0.0f;
|
|
this.mInTransition = false;
|
|
this.mIndirectTransition = false;
|
|
this.mDebugPath = 0;
|
|
this.mTemporalInterpolator = false;
|
|
this.mStopLogic = new StopLogic();
|
|
this.mDecelerateLogic = new DecelerateInterpolator();
|
|
this.firstDown = true;
|
|
this.mUndergoingMotion = false;
|
|
this.mKeepAnimating = false;
|
|
this.mOnShowHelpers = null;
|
|
this.mOnHideHelpers = null;
|
|
this.mTransitionListeners = null;
|
|
this.mFrames = 0;
|
|
this.mLastDrawTime = -1L;
|
|
this.mLastFps = 0.0f;
|
|
this.mListenerState = 0;
|
|
this.mListenerPosition = 0.0f;
|
|
this.mIsAnimating = false;
|
|
this.mMeasureDuringTransition = false;
|
|
this.mKeyCache = new KeyCache();
|
|
this.mInLayout = false;
|
|
this.mTransitionState = TransitionState.UNDEFINED;
|
|
this.mModel = new Model();
|
|
this.mNeedsFireTransitionCompleted = false;
|
|
this.mBoundsCheck = new RectF();
|
|
this.mRegionView = null;
|
|
this.mTransitionCompleted = new ArrayList<>();
|
|
init(attributeSet);
|
|
}
|
|
|
|
protected long getNanoTime() {
|
|
return System.nanoTime();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
public MotionTracker obtainVelocityTracker() {
|
|
return MyTracker.obtain();
|
|
}
|
|
|
|
public void enableTransition(int i, boolean z) {
|
|
MotionScene.Transition transition = getTransition(i);
|
|
if (z) {
|
|
transition.setEnable(true);
|
|
return;
|
|
}
|
|
if (transition == this.mScene.mCurrentTransition) {
|
|
Iterator<MotionScene.Transition> it = this.mScene.getTransitionsWithState(this.mCurrentState).iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
break;
|
|
}
|
|
MotionScene.Transition next = it.next();
|
|
if (next.isEnabled()) {
|
|
this.mScene.mCurrentTransition = next;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
transition.setEnable(false);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public void setState(TransitionState transitionState) {
|
|
if (transitionState == TransitionState.FINISHED && this.mCurrentState == -1) {
|
|
return;
|
|
}
|
|
TransitionState transitionState2 = this.mTransitionState;
|
|
this.mTransitionState = transitionState;
|
|
if (transitionState2 == TransitionState.MOVING && transitionState == TransitionState.MOVING) {
|
|
fireTransitionChange();
|
|
}
|
|
int i = AnonymousClass2.$SwitchMap$androidx$constraintlayout$motion$widget$MotionLayout$TransitionState[transitionState2.ordinal()];
|
|
if (i == 1 || i == 2) {
|
|
if (transitionState == TransitionState.MOVING) {
|
|
fireTransitionChange();
|
|
}
|
|
if (transitionState == TransitionState.FINISHED) {
|
|
fireTransitionCompleted();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
if (i == 3 && transitionState == TransitionState.FINISHED) {
|
|
fireTransitionCompleted();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* renamed from: androidx.constraintlayout.motion.widget.MotionLayout$2, reason: invalid class name */
|
|
/* loaded from: classes.dex */
|
|
public static /* synthetic */ class AnonymousClass2 {
|
|
static final /* synthetic */ int[] $SwitchMap$androidx$constraintlayout$motion$widget$MotionLayout$TransitionState;
|
|
|
|
static {
|
|
int[] iArr = new int[TransitionState.values().length];
|
|
$SwitchMap$androidx$constraintlayout$motion$widget$MotionLayout$TransitionState = iArr;
|
|
try {
|
|
iArr[TransitionState.UNDEFINED.ordinal()] = 1;
|
|
} catch (NoSuchFieldError unused) {
|
|
}
|
|
try {
|
|
$SwitchMap$androidx$constraintlayout$motion$widget$MotionLayout$TransitionState[TransitionState.SETUP.ordinal()] = 2;
|
|
} catch (NoSuchFieldError unused2) {
|
|
}
|
|
try {
|
|
$SwitchMap$androidx$constraintlayout$motion$widget$MotionLayout$TransitionState[TransitionState.MOVING.ordinal()] = 3;
|
|
} catch (NoSuchFieldError unused3) {
|
|
}
|
|
try {
|
|
$SwitchMap$androidx$constraintlayout$motion$widget$MotionLayout$TransitionState[TransitionState.FINISHED.ordinal()] = 4;
|
|
} catch (NoSuchFieldError unused4) {
|
|
}
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
private static class MyTracker implements MotionTracker {
|
|
private static MyTracker me = new MyTracker();
|
|
VelocityTracker tracker;
|
|
|
|
private MyTracker() {
|
|
}
|
|
|
|
public static MyTracker obtain() {
|
|
me.tracker = VelocityTracker.obtain();
|
|
return me;
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.MotionLayout.MotionTracker
|
|
public void recycle() {
|
|
this.tracker.recycle();
|
|
this.tracker = null;
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.MotionLayout.MotionTracker
|
|
public void clear() {
|
|
this.tracker.clear();
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.MotionLayout.MotionTracker
|
|
public void addMovement(MotionEvent motionEvent) {
|
|
VelocityTracker velocityTracker = this.tracker;
|
|
if (velocityTracker != null) {
|
|
velocityTracker.addMovement(motionEvent);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.MotionLayout.MotionTracker
|
|
public void computeCurrentVelocity(int i) {
|
|
this.tracker.computeCurrentVelocity(i);
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.MotionLayout.MotionTracker
|
|
public void computeCurrentVelocity(int i, float f) {
|
|
this.tracker.computeCurrentVelocity(i, f);
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.MotionLayout.MotionTracker
|
|
public float getXVelocity() {
|
|
return this.tracker.getXVelocity();
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.MotionLayout.MotionTracker
|
|
public float getYVelocity() {
|
|
return this.tracker.getYVelocity();
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.MotionLayout.MotionTracker
|
|
public float getXVelocity(int i) {
|
|
return this.tracker.getXVelocity(i);
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.MotionLayout.MotionTracker
|
|
public float getYVelocity(int i) {
|
|
return getYVelocity(i);
|
|
}
|
|
}
|
|
|
|
public void setTransition(int i, int i2) {
|
|
if (!isAttachedToWindow()) {
|
|
if (this.mStateCache == null) {
|
|
this.mStateCache = new StateCache();
|
|
}
|
|
this.mStateCache.setStartState(i);
|
|
this.mStateCache.setEndState(i2);
|
|
return;
|
|
}
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene != null) {
|
|
this.mBeginState = i;
|
|
this.mEndState = i2;
|
|
motionScene.setTransition(i, i2);
|
|
this.mModel.initFrom(this.mLayoutWidget, this.mScene.getConstraintSet(i), this.mScene.getConstraintSet(i2));
|
|
rebuildScene();
|
|
this.mTransitionLastPosition = 0.0f;
|
|
transitionToStart();
|
|
}
|
|
}
|
|
|
|
public void setTransition(int i) {
|
|
if (this.mScene != null) {
|
|
MotionScene.Transition transition = getTransition(i);
|
|
this.mBeginState = transition.getStartConstraintSetId();
|
|
this.mEndState = transition.getEndConstraintSetId();
|
|
if (!isAttachedToWindow()) {
|
|
if (this.mStateCache == null) {
|
|
this.mStateCache = new StateCache();
|
|
}
|
|
this.mStateCache.setStartState(this.mBeginState);
|
|
this.mStateCache.setEndState(this.mEndState);
|
|
return;
|
|
}
|
|
int i2 = this.mCurrentState;
|
|
float f = i2 == this.mBeginState ? 0.0f : i2 == this.mEndState ? 1.0f : Float.NaN;
|
|
this.mScene.setTransition(transition);
|
|
this.mModel.initFrom(this.mLayoutWidget, this.mScene.getConstraintSet(this.mBeginState), this.mScene.getConstraintSet(this.mEndState));
|
|
rebuildScene();
|
|
this.mTransitionLastPosition = Float.isNaN(f) ? 0.0f : f;
|
|
if (Float.isNaN(f)) {
|
|
Log.v(TAG, Debug.getLocation() + " transitionToStart ");
|
|
transitionToStart();
|
|
} else {
|
|
setProgress(f);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
public void setTransition(MotionScene.Transition transition) {
|
|
this.mScene.setTransition(transition);
|
|
setState(TransitionState.SETUP);
|
|
if (this.mCurrentState == this.mScene.getEndId()) {
|
|
this.mTransitionLastPosition = 1.0f;
|
|
this.mTransitionPosition = 1.0f;
|
|
this.mTransitionGoalPosition = 1.0f;
|
|
} else {
|
|
this.mTransitionLastPosition = 0.0f;
|
|
this.mTransitionPosition = 0.0f;
|
|
this.mTransitionGoalPosition = 0.0f;
|
|
}
|
|
this.mTransitionLastTime = transition.isTransitionFlag(1) ? -1L : getNanoTime();
|
|
int startId = this.mScene.getStartId();
|
|
int endId = this.mScene.getEndId();
|
|
if (startId == this.mBeginState && endId == this.mEndState) {
|
|
return;
|
|
}
|
|
this.mBeginState = startId;
|
|
this.mEndState = endId;
|
|
this.mScene.setTransition(startId, endId);
|
|
this.mModel.initFrom(this.mLayoutWidget, this.mScene.getConstraintSet(this.mBeginState), this.mScene.getConstraintSet(this.mEndState));
|
|
this.mModel.setMeasuredId(this.mBeginState, this.mEndState);
|
|
this.mModel.reEvaluateState();
|
|
rebuildScene();
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.widget.ConstraintLayout
|
|
public void loadLayoutDescription(int i) {
|
|
if (i == 0) {
|
|
this.mScene = null;
|
|
return;
|
|
}
|
|
try {
|
|
this.mScene = new MotionScene(getContext(), this, i);
|
|
if (isAttachedToWindow()) {
|
|
this.mScene.readFallback(this);
|
|
this.mModel.initFrom(this.mLayoutWidget, this.mScene.getConstraintSet(this.mBeginState), this.mScene.getConstraintSet(this.mEndState));
|
|
rebuildScene();
|
|
this.mScene.setRtl(isRtl());
|
|
}
|
|
} catch (Exception e) {
|
|
throw new IllegalArgumentException("unable to parse MotionScene file", e);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public boolean isAttachedToWindow() {
|
|
return super.isAttachedToWindow();
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.widget.ConstraintLayout
|
|
public void setState(int i, int i2, int i3) {
|
|
setState(TransitionState.SETUP);
|
|
this.mCurrentState = i;
|
|
this.mBeginState = -1;
|
|
this.mEndState = -1;
|
|
if (this.mConstraintLayoutSpec != null) {
|
|
this.mConstraintLayoutSpec.updateConstraints(i, i2, i3);
|
|
return;
|
|
}
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene != null) {
|
|
motionScene.getConstraintSet(i).applyTo(this);
|
|
}
|
|
}
|
|
|
|
public void setInterpolatedProgress(float f) {
|
|
if (this.mScene != null) {
|
|
setState(TransitionState.MOVING);
|
|
Interpolator interpolator = this.mScene.getInterpolator();
|
|
if (interpolator != null) {
|
|
setProgress(interpolator.getInterpolation(f));
|
|
return;
|
|
}
|
|
}
|
|
setProgress(f);
|
|
}
|
|
|
|
public void setProgress(float f, float f2) {
|
|
if (!isAttachedToWindow()) {
|
|
if (this.mStateCache == null) {
|
|
this.mStateCache = new StateCache();
|
|
}
|
|
this.mStateCache.setProgress(f);
|
|
this.mStateCache.setVelocity(f2);
|
|
return;
|
|
}
|
|
setProgress(f);
|
|
setState(TransitionState.MOVING);
|
|
this.mLastVelocity = f2;
|
|
animateTo(1.0f);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public class StateCache {
|
|
float mProgress = Float.NaN;
|
|
float mVelocity = Float.NaN;
|
|
int startState = -1;
|
|
int endState = -1;
|
|
final String KeyProgress = "motion.progress";
|
|
final String KeyVelocity = "motion.velocity";
|
|
final String KeyStartState = "motion.StartState";
|
|
final String KeyEndState = "motion.EndState";
|
|
|
|
public void setEndState(int i) {
|
|
this.endState = i;
|
|
}
|
|
|
|
public void setProgress(float f) {
|
|
this.mProgress = f;
|
|
}
|
|
|
|
public void setStartState(int i) {
|
|
this.startState = i;
|
|
}
|
|
|
|
public void setVelocity(float f) {
|
|
this.mVelocity = f;
|
|
}
|
|
|
|
StateCache() {
|
|
}
|
|
|
|
void apply() {
|
|
int i = this.startState;
|
|
if (i != -1 || this.endState != -1) {
|
|
if (i == -1) {
|
|
MotionLayout.this.transitionToState(this.endState);
|
|
} else {
|
|
int i2 = this.endState;
|
|
if (i2 == -1) {
|
|
MotionLayout.this.setState(i, -1, -1);
|
|
} else {
|
|
MotionLayout.this.setTransition(i, i2);
|
|
}
|
|
}
|
|
MotionLayout.this.setState(TransitionState.SETUP);
|
|
}
|
|
if (Float.isNaN(this.mVelocity)) {
|
|
if (Float.isNaN(this.mProgress)) {
|
|
return;
|
|
}
|
|
MotionLayout.this.setProgress(this.mProgress);
|
|
} else {
|
|
MotionLayout.this.setProgress(this.mProgress, this.mVelocity);
|
|
this.mProgress = Float.NaN;
|
|
this.mVelocity = Float.NaN;
|
|
this.startState = -1;
|
|
this.endState = -1;
|
|
}
|
|
}
|
|
|
|
public Bundle getTransitionState() {
|
|
Bundle bundle = new Bundle();
|
|
bundle.putFloat("motion.progress", this.mProgress);
|
|
bundle.putFloat("motion.velocity", this.mVelocity);
|
|
bundle.putInt("motion.StartState", this.startState);
|
|
bundle.putInt("motion.EndState", this.endState);
|
|
return bundle;
|
|
}
|
|
|
|
public void setTransitionState(Bundle bundle) {
|
|
this.mProgress = bundle.getFloat("motion.progress");
|
|
this.mVelocity = bundle.getFloat("motion.velocity");
|
|
this.startState = bundle.getInt("motion.StartState");
|
|
this.endState = bundle.getInt("motion.EndState");
|
|
}
|
|
|
|
public void recordState() {
|
|
this.endState = MotionLayout.this.mEndState;
|
|
this.startState = MotionLayout.this.mBeginState;
|
|
this.mVelocity = MotionLayout.this.getVelocity();
|
|
this.mProgress = MotionLayout.this.getProgress();
|
|
}
|
|
}
|
|
|
|
public void setTransitionState(Bundle bundle) {
|
|
if (this.mStateCache == null) {
|
|
this.mStateCache = new StateCache();
|
|
}
|
|
this.mStateCache.setTransitionState(bundle);
|
|
if (isAttachedToWindow()) {
|
|
this.mStateCache.apply();
|
|
}
|
|
}
|
|
|
|
public Bundle getTransitionState() {
|
|
if (this.mStateCache == null) {
|
|
this.mStateCache = new StateCache();
|
|
}
|
|
this.mStateCache.recordState();
|
|
return this.mStateCache.getTransitionState();
|
|
}
|
|
|
|
public void setProgress(float f) {
|
|
if (!isAttachedToWindow()) {
|
|
if (this.mStateCache == null) {
|
|
this.mStateCache = new StateCache();
|
|
}
|
|
this.mStateCache.setProgress(f);
|
|
return;
|
|
}
|
|
if (f <= 0.0f) {
|
|
this.mCurrentState = this.mBeginState;
|
|
if (this.mTransitionLastPosition == 0.0f) {
|
|
setState(TransitionState.FINISHED);
|
|
}
|
|
} else if (f >= 1.0f) {
|
|
this.mCurrentState = this.mEndState;
|
|
if (this.mTransitionLastPosition == 1.0f) {
|
|
setState(TransitionState.FINISHED);
|
|
}
|
|
} else {
|
|
this.mCurrentState = -1;
|
|
setState(TransitionState.MOVING);
|
|
}
|
|
if (this.mScene == null) {
|
|
return;
|
|
}
|
|
this.mTransitionInstantly = true;
|
|
this.mTransitionGoalPosition = f;
|
|
this.mTransitionPosition = f;
|
|
this.mTransitionLastTime = -1L;
|
|
this.mAnimationStartTime = -1L;
|
|
this.mInterpolator = null;
|
|
this.mInTransition = true;
|
|
invalidate();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void setupMotionViews() {
|
|
int childCount = getChildCount();
|
|
this.mModel.build();
|
|
this.mInTransition = true;
|
|
int width = getWidth();
|
|
int height = getHeight();
|
|
int gatPathMotionArc = this.mScene.gatPathMotionArc();
|
|
int i = 0;
|
|
if (gatPathMotionArc != -1) {
|
|
for (int i2 = 0; i2 < childCount; i2++) {
|
|
MotionController motionController = this.mFrameArrayList.get(getChildAt(i2));
|
|
if (motionController != null) {
|
|
motionController.setPathMotionArc(gatPathMotionArc);
|
|
}
|
|
}
|
|
}
|
|
for (int i3 = 0; i3 < childCount; i3++) {
|
|
MotionController motionController2 = this.mFrameArrayList.get(getChildAt(i3));
|
|
if (motionController2 != null) {
|
|
this.mScene.getKeyFrames(motionController2);
|
|
motionController2.setup(width, height, this.mTransitionDuration, getNanoTime());
|
|
}
|
|
}
|
|
float staggered = this.mScene.getStaggered();
|
|
if (staggered != 0.0f) {
|
|
boolean z = ((double) staggered) < BuildConfig.SENTRY_SAMPLE_RATE;
|
|
float abs = Math.abs(staggered);
|
|
float f = -3.4028235E38f;
|
|
float f2 = Float.MAX_VALUE;
|
|
float f3 = -3.4028235E38f;
|
|
float f4 = Float.MAX_VALUE;
|
|
for (int i4 = 0; i4 < childCount; i4++) {
|
|
MotionController motionController3 = this.mFrameArrayList.get(getChildAt(i4));
|
|
if (!Float.isNaN(motionController3.mMotionStagger)) {
|
|
for (int i5 = 0; i5 < childCount; i5++) {
|
|
MotionController motionController4 = this.mFrameArrayList.get(getChildAt(i5));
|
|
if (!Float.isNaN(motionController4.mMotionStagger)) {
|
|
f2 = Math.min(f2, motionController4.mMotionStagger);
|
|
f = Math.max(f, motionController4.mMotionStagger);
|
|
}
|
|
}
|
|
while (i < childCount) {
|
|
MotionController motionController5 = this.mFrameArrayList.get(getChildAt(i));
|
|
if (!Float.isNaN(motionController5.mMotionStagger)) {
|
|
motionController5.mStaggerScale = 1.0f / (1.0f - abs);
|
|
if (z) {
|
|
motionController5.mStaggerOffset = abs - (((f - motionController5.mMotionStagger) / (f - f2)) * abs);
|
|
} else {
|
|
motionController5.mStaggerOffset = abs - (((motionController5.mMotionStagger - f2) * abs) / (f - f2));
|
|
}
|
|
}
|
|
i++;
|
|
}
|
|
return;
|
|
}
|
|
float finalX = motionController3.getFinalX();
|
|
float finalY = motionController3.getFinalY();
|
|
float f5 = z ? finalY - finalX : finalY + finalX;
|
|
f4 = Math.min(f4, f5);
|
|
f3 = Math.max(f3, f5);
|
|
}
|
|
while (i < childCount) {
|
|
MotionController motionController6 = this.mFrameArrayList.get(getChildAt(i));
|
|
float finalX2 = motionController6.getFinalX();
|
|
float finalY2 = motionController6.getFinalY();
|
|
float f6 = z ? finalY2 - finalX2 : finalY2 + finalX2;
|
|
motionController6.mStaggerScale = 1.0f / (1.0f - abs);
|
|
motionController6.mStaggerOffset = abs - (((f6 - f4) * abs) / (f3 - f4));
|
|
i++;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void touchAnimateTo(int i, float f, float f2) {
|
|
if (this.mScene == null || this.mTransitionLastPosition == f) {
|
|
return;
|
|
}
|
|
this.mTemporalInterpolator = true;
|
|
this.mAnimationStartTime = getNanoTime();
|
|
float duration = this.mScene.getDuration() / 1000.0f;
|
|
this.mTransitionDuration = duration;
|
|
this.mTransitionGoalPosition = f;
|
|
this.mInTransition = true;
|
|
if (i == 0 || i == 1 || i == 2) {
|
|
if (i == 1) {
|
|
f = 0.0f;
|
|
} else if (i == 2) {
|
|
f = 1.0f;
|
|
}
|
|
this.mStopLogic.config(this.mTransitionLastPosition, f, f2, duration, this.mScene.getMaxAcceleration(), this.mScene.getMaxVelocity());
|
|
int i2 = this.mCurrentState;
|
|
this.mTransitionGoalPosition = f;
|
|
this.mCurrentState = i2;
|
|
this.mInterpolator = this.mStopLogic;
|
|
} else if (i == 4) {
|
|
this.mDecelerateLogic.config(f2, this.mTransitionLastPosition, this.mScene.getMaxAcceleration());
|
|
this.mInterpolator = this.mDecelerateLogic;
|
|
} else if (i == 5) {
|
|
if (willJump(f2, this.mTransitionLastPosition, this.mScene.getMaxAcceleration())) {
|
|
this.mDecelerateLogic.config(f2, this.mTransitionLastPosition, this.mScene.getMaxAcceleration());
|
|
this.mInterpolator = this.mDecelerateLogic;
|
|
} else {
|
|
this.mStopLogic.config(this.mTransitionLastPosition, f, f2, this.mTransitionDuration, this.mScene.getMaxAcceleration(), this.mScene.getMaxVelocity());
|
|
this.mLastVelocity = 0.0f;
|
|
int i3 = this.mCurrentState;
|
|
this.mTransitionGoalPosition = f;
|
|
this.mCurrentState = i3;
|
|
this.mInterpolator = this.mStopLogic;
|
|
}
|
|
}
|
|
this.mTransitionInstantly = false;
|
|
this.mAnimationStartTime = getNanoTime();
|
|
invalidate();
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
class DecelerateInterpolator extends MotionInterpolator {
|
|
float maxA;
|
|
float initalV = 0.0f;
|
|
float currentP = 0.0f;
|
|
|
|
public void config(float f, float f2, float f3) {
|
|
this.initalV = f;
|
|
this.currentP = f2;
|
|
this.maxA = f3;
|
|
}
|
|
|
|
DecelerateInterpolator() {
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.MotionInterpolator, android.animation.TimeInterpolator
|
|
public float getInterpolation(float f) {
|
|
float f2;
|
|
float f3;
|
|
float f4 = this.initalV;
|
|
if (f4 > 0.0f) {
|
|
float f5 = this.maxA;
|
|
if (f4 / f5 < f) {
|
|
f = f4 / f5;
|
|
}
|
|
MotionLayout.this.mLastVelocity = f4 - (f5 * f);
|
|
f2 = (this.initalV * f) - (((this.maxA * f) * f) / 2.0f);
|
|
f3 = this.currentP;
|
|
} else {
|
|
float f6 = this.maxA;
|
|
if ((-f4) / f6 < f) {
|
|
f = (-f4) / f6;
|
|
}
|
|
MotionLayout.this.mLastVelocity = f4 + (f6 * f);
|
|
f2 = (this.initalV * f) + (((this.maxA * f) * f) / 2.0f);
|
|
f3 = this.currentP;
|
|
}
|
|
return f2 + f3;
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.MotionInterpolator
|
|
public float getVelocity() {
|
|
return MotionLayout.this.mLastVelocity;
|
|
}
|
|
}
|
|
|
|
void animateTo(float f) {
|
|
if (this.mScene == null) {
|
|
return;
|
|
}
|
|
float f2 = this.mTransitionLastPosition;
|
|
float f3 = this.mTransitionPosition;
|
|
if (f2 != f3 && this.mTransitionInstantly) {
|
|
this.mTransitionLastPosition = f3;
|
|
}
|
|
float f4 = this.mTransitionLastPosition;
|
|
if (f4 == f) {
|
|
return;
|
|
}
|
|
this.mTemporalInterpolator = false;
|
|
this.mTransitionGoalPosition = f;
|
|
this.mTransitionDuration = r0.getDuration() / 1000.0f;
|
|
setProgress(this.mTransitionGoalPosition);
|
|
this.mInterpolator = this.mScene.getInterpolator();
|
|
this.mTransitionInstantly = false;
|
|
this.mAnimationStartTime = getNanoTime();
|
|
this.mInTransition = true;
|
|
this.mTransitionPosition = f4;
|
|
this.mTransitionLastPosition = f4;
|
|
invalidate();
|
|
}
|
|
|
|
private void computeCurrentPositions() {
|
|
int childCount = getChildCount();
|
|
for (int i = 0; i < childCount; i++) {
|
|
View childAt = getChildAt(i);
|
|
MotionController motionController = this.mFrameArrayList.get(childAt);
|
|
if (motionController != null) {
|
|
motionController.setStartCurrentState(childAt);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void transitionToStart() {
|
|
animateTo(0.0f);
|
|
}
|
|
|
|
public void transitionToEnd() {
|
|
animateTo(1.0f);
|
|
}
|
|
|
|
public void transitionToState(int i) {
|
|
if (!isAttachedToWindow()) {
|
|
if (this.mStateCache == null) {
|
|
this.mStateCache = new StateCache();
|
|
}
|
|
this.mStateCache.setEndState(i);
|
|
return;
|
|
}
|
|
transitionToState(i, -1, -1);
|
|
}
|
|
|
|
public void transitionToState(int i, int i2, int i3) {
|
|
int convertToConstraintSet;
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene != null && motionScene.mStateSet != null && (convertToConstraintSet = this.mScene.mStateSet.convertToConstraintSet(this.mCurrentState, i, i2, i3)) != -1) {
|
|
i = convertToConstraintSet;
|
|
}
|
|
int i4 = this.mCurrentState;
|
|
if (i4 == i) {
|
|
return;
|
|
}
|
|
if (this.mBeginState == i) {
|
|
animateTo(0.0f);
|
|
return;
|
|
}
|
|
if (this.mEndState == i) {
|
|
animateTo(1.0f);
|
|
return;
|
|
}
|
|
this.mEndState = i;
|
|
if (i4 != -1) {
|
|
setTransition(i4, i);
|
|
animateTo(1.0f);
|
|
this.mTransitionLastPosition = 0.0f;
|
|
transitionToEnd();
|
|
return;
|
|
}
|
|
this.mTemporalInterpolator = false;
|
|
this.mTransitionGoalPosition = 1.0f;
|
|
this.mTransitionPosition = 0.0f;
|
|
this.mTransitionLastPosition = 0.0f;
|
|
this.mTransitionLastTime = getNanoTime();
|
|
this.mAnimationStartTime = getNanoTime();
|
|
this.mTransitionInstantly = false;
|
|
this.mInterpolator = null;
|
|
this.mTransitionDuration = this.mScene.getDuration() / 1000.0f;
|
|
this.mBeginState = -1;
|
|
this.mScene.setTransition(-1, this.mEndState);
|
|
this.mScene.getStartId();
|
|
int childCount = getChildCount();
|
|
this.mFrameArrayList.clear();
|
|
for (int i5 = 0; i5 < childCount; i5++) {
|
|
View childAt = getChildAt(i5);
|
|
this.mFrameArrayList.put(childAt, new MotionController(childAt));
|
|
}
|
|
this.mInTransition = true;
|
|
this.mModel.initFrom(this.mLayoutWidget, null, this.mScene.getConstraintSet(i));
|
|
rebuildScene();
|
|
this.mModel.build();
|
|
computeCurrentPositions();
|
|
int width = getWidth();
|
|
int height = getHeight();
|
|
for (int i6 = 0; i6 < childCount; i6++) {
|
|
MotionController motionController = this.mFrameArrayList.get(getChildAt(i6));
|
|
this.mScene.getKeyFrames(motionController);
|
|
motionController.setup(width, height, this.mTransitionDuration, getNanoTime());
|
|
}
|
|
float staggered = this.mScene.getStaggered();
|
|
if (staggered != 0.0f) {
|
|
float f = Float.MAX_VALUE;
|
|
float f2 = -3.4028235E38f;
|
|
for (int i7 = 0; i7 < childCount; i7++) {
|
|
MotionController motionController2 = this.mFrameArrayList.get(getChildAt(i7));
|
|
float finalY = motionController2.getFinalY() + motionController2.getFinalX();
|
|
f = Math.min(f, finalY);
|
|
f2 = Math.max(f2, finalY);
|
|
}
|
|
for (int i8 = 0; i8 < childCount; i8++) {
|
|
MotionController motionController3 = this.mFrameArrayList.get(getChildAt(i8));
|
|
float finalX = motionController3.getFinalX();
|
|
float finalY2 = motionController3.getFinalY();
|
|
motionController3.mStaggerScale = 1.0f / (1.0f - staggered);
|
|
motionController3.mStaggerOffset = staggered - ((((finalX + finalY2) - f) * staggered) / (f2 - f));
|
|
}
|
|
}
|
|
this.mTransitionPosition = 0.0f;
|
|
this.mTransitionLastPosition = 0.0f;
|
|
this.mInTransition = true;
|
|
invalidate();
|
|
}
|
|
|
|
public void getViewVelocity(View view, float f, float f2, float[] fArr, int i) {
|
|
float f3;
|
|
float f4 = this.mLastVelocity;
|
|
float f5 = this.mTransitionLastPosition;
|
|
if (this.mInterpolator != null) {
|
|
float signum = Math.signum(this.mTransitionGoalPosition - f5);
|
|
float interpolation = this.mInterpolator.getInterpolation(this.mTransitionLastPosition + EPSILON);
|
|
f3 = this.mInterpolator.getInterpolation(this.mTransitionLastPosition);
|
|
f4 = (signum * ((interpolation - f3) / EPSILON)) / this.mTransitionDuration;
|
|
} else {
|
|
f3 = f5;
|
|
}
|
|
Interpolator interpolator = this.mInterpolator;
|
|
if (interpolator instanceof MotionInterpolator) {
|
|
f4 = ((MotionInterpolator) interpolator).getVelocity();
|
|
}
|
|
MotionController motionController = this.mFrameArrayList.get(view);
|
|
if ((i & 1) == 0) {
|
|
motionController.getPostLayoutDvDp(f3, view.getWidth(), view.getHeight(), f, f2, fArr);
|
|
} else {
|
|
motionController.getDpDt(f3, f, f2, fArr);
|
|
}
|
|
if (i < 2) {
|
|
fArr[0] = fArr[0] * f4;
|
|
fArr[1] = fArr[1] * f4;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes.dex */
|
|
public class Model {
|
|
int mEndId;
|
|
int mStartId;
|
|
ConstraintWidgetContainer mLayoutStart = new ConstraintWidgetContainer();
|
|
ConstraintWidgetContainer mLayoutEnd = new ConstraintWidgetContainer();
|
|
ConstraintSet mStart = null;
|
|
ConstraintSet mEnd = null;
|
|
|
|
public boolean isNotConfiguredWith(int i, int i2) {
|
|
return (i == this.mStartId && i2 == this.mEndId) ? false : true;
|
|
}
|
|
|
|
public void setMeasuredId(int i, int i2) {
|
|
this.mStartId = i;
|
|
this.mEndId = i2;
|
|
}
|
|
|
|
Model() {
|
|
}
|
|
|
|
void copy(ConstraintWidgetContainer constraintWidgetContainer, ConstraintWidgetContainer constraintWidgetContainer2) {
|
|
ConstraintWidget constraintWidget;
|
|
ArrayList<ConstraintWidget> children = constraintWidgetContainer.getChildren();
|
|
HashMap<ConstraintWidget, ConstraintWidget> hashMap = new HashMap<>();
|
|
hashMap.put(constraintWidgetContainer, constraintWidgetContainer2);
|
|
constraintWidgetContainer2.getChildren().clear();
|
|
constraintWidgetContainer2.copy(constraintWidgetContainer, hashMap);
|
|
Iterator<ConstraintWidget> it = children.iterator();
|
|
while (it.hasNext()) {
|
|
ConstraintWidget next = it.next();
|
|
if (next instanceof Barrier) {
|
|
constraintWidget = new Barrier();
|
|
} else if (next instanceof Guideline) {
|
|
constraintWidget = new Guideline();
|
|
} else if (next instanceof Flow) {
|
|
constraintWidget = new Flow();
|
|
} else if (next instanceof Helper) {
|
|
constraintWidget = new HelperWidget();
|
|
} else {
|
|
constraintWidget = new ConstraintWidget();
|
|
}
|
|
constraintWidgetContainer2.add(constraintWidget);
|
|
hashMap.put(next, constraintWidget);
|
|
}
|
|
Iterator<ConstraintWidget> it2 = children.iterator();
|
|
while (it2.hasNext()) {
|
|
ConstraintWidget next2 = it2.next();
|
|
hashMap.get(next2).copy(next2, hashMap);
|
|
}
|
|
}
|
|
|
|
void initFrom(ConstraintWidgetContainer constraintWidgetContainer, ConstraintSet constraintSet, ConstraintSet constraintSet2) {
|
|
this.mStart = constraintSet;
|
|
this.mEnd = constraintSet2;
|
|
this.mLayoutStart = new ConstraintWidgetContainer();
|
|
this.mLayoutEnd = new ConstraintWidgetContainer();
|
|
this.mLayoutStart.setMeasurer(MotionLayout.this.mLayoutWidget.getMeasurer());
|
|
this.mLayoutEnd.setMeasurer(MotionLayout.this.mLayoutWidget.getMeasurer());
|
|
this.mLayoutStart.removeAllChildren();
|
|
this.mLayoutEnd.removeAllChildren();
|
|
copy(MotionLayout.this.mLayoutWidget, this.mLayoutStart);
|
|
copy(MotionLayout.this.mLayoutWidget, this.mLayoutEnd);
|
|
if (MotionLayout.this.mTransitionLastPosition > 0.5d) {
|
|
if (constraintSet != null) {
|
|
setupConstraintWidget(this.mLayoutStart, constraintSet);
|
|
}
|
|
setupConstraintWidget(this.mLayoutEnd, constraintSet2);
|
|
} else {
|
|
setupConstraintWidget(this.mLayoutEnd, constraintSet2);
|
|
if (constraintSet != null) {
|
|
setupConstraintWidget(this.mLayoutStart, constraintSet);
|
|
}
|
|
}
|
|
this.mLayoutStart.setRtl(MotionLayout.this.isRtl());
|
|
this.mLayoutStart.updateHierarchy();
|
|
this.mLayoutEnd.setRtl(MotionLayout.this.isRtl());
|
|
this.mLayoutEnd.updateHierarchy();
|
|
ViewGroup.LayoutParams layoutParams = MotionLayout.this.getLayoutParams();
|
|
if (layoutParams != null) {
|
|
if (layoutParams.width == -2) {
|
|
this.mLayoutStart.setHorizontalDimensionBehaviour(ConstraintWidget.DimensionBehaviour.WRAP_CONTENT);
|
|
this.mLayoutEnd.setHorizontalDimensionBehaviour(ConstraintWidget.DimensionBehaviour.WRAP_CONTENT);
|
|
}
|
|
if (layoutParams.height == -2) {
|
|
this.mLayoutStart.setVerticalDimensionBehaviour(ConstraintWidget.DimensionBehaviour.WRAP_CONTENT);
|
|
this.mLayoutEnd.setVerticalDimensionBehaviour(ConstraintWidget.DimensionBehaviour.WRAP_CONTENT);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
private void setupConstraintWidget(ConstraintWidgetContainer constraintWidgetContainer, ConstraintSet constraintSet) {
|
|
SparseArray<ConstraintWidget> sparseArray = new SparseArray<>();
|
|
Constraints.LayoutParams layoutParams = new Constraints.LayoutParams(-2, -2);
|
|
sparseArray.clear();
|
|
sparseArray.put(0, constraintWidgetContainer);
|
|
sparseArray.put(MotionLayout.this.getId(), constraintWidgetContainer);
|
|
Iterator<ConstraintWidget> it = constraintWidgetContainer.getChildren().iterator();
|
|
while (it.hasNext()) {
|
|
ConstraintWidget next = it.next();
|
|
sparseArray.put(((View) next.getCompanionWidget()).getId(), next);
|
|
}
|
|
Iterator<ConstraintWidget> it2 = constraintWidgetContainer.getChildren().iterator();
|
|
while (it2.hasNext()) {
|
|
ConstraintWidget next2 = it2.next();
|
|
View view = (View) next2.getCompanionWidget();
|
|
constraintSet.applyToLayoutParams(view.getId(), layoutParams);
|
|
next2.setWidth(constraintSet.getWidth(view.getId()));
|
|
next2.setHeight(constraintSet.getHeight(view.getId()));
|
|
if (view instanceof ConstraintHelper) {
|
|
constraintSet.applyToHelper((ConstraintHelper) view, next2, layoutParams, sparseArray);
|
|
if (view instanceof androidx.constraintlayout.widget.Barrier) {
|
|
((androidx.constraintlayout.widget.Barrier) view).validateParams();
|
|
}
|
|
}
|
|
layoutParams.resolveLayoutDirection(MotionLayout.this.getLayoutDirection());
|
|
MotionLayout.this.applyConstraintsFromLayoutParams(false, view, next2, layoutParams, sparseArray);
|
|
if (constraintSet.getVisibilityMode(view.getId()) == 1) {
|
|
next2.setVisibility(view.getVisibility());
|
|
} else {
|
|
next2.setVisibility(constraintSet.getVisibility(view.getId()));
|
|
}
|
|
}
|
|
Iterator<ConstraintWidget> it3 = constraintWidgetContainer.getChildren().iterator();
|
|
while (it3.hasNext()) {
|
|
ConstraintWidget next3 = it3.next();
|
|
if (next3 instanceof VirtualLayout) {
|
|
ConstraintHelper constraintHelper = (ConstraintHelper) next3.getCompanionWidget();
|
|
Helper helper = (Helper) next3;
|
|
constraintHelper.updatePreLayout(constraintWidgetContainer, helper, sparseArray);
|
|
((VirtualLayout) helper).captureWidgets();
|
|
}
|
|
}
|
|
}
|
|
|
|
ConstraintWidget getWidget(ConstraintWidgetContainer constraintWidgetContainer, View view) {
|
|
if (constraintWidgetContainer.getCompanionWidget() == view) {
|
|
return constraintWidgetContainer;
|
|
}
|
|
ArrayList<ConstraintWidget> children = constraintWidgetContainer.getChildren();
|
|
int size = children.size();
|
|
for (int i = 0; i < size; i++) {
|
|
ConstraintWidget constraintWidget = children.get(i);
|
|
if (constraintWidget.getCompanionWidget() == view) {
|
|
return constraintWidget;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private void debugLayoutParam(String str, ConstraintLayout.LayoutParams layoutParams) {
|
|
Log.v(MotionLayout.TAG, str + (((((((((((" ".concat(layoutParams.startToStart != -1 ? "SS" : "__") + (layoutParams.startToEnd != -1 ? "|SE" : "|__")) + (layoutParams.endToStart != -1 ? "|ES" : "|__")) + (layoutParams.endToEnd != -1 ? "|EE" : "|__")) + (layoutParams.leftToLeft != -1 ? "|LL" : "|__")) + (layoutParams.leftToRight != -1 ? "|LR" : "|__")) + (layoutParams.rightToLeft != -1 ? "|RL" : "|__")) + (layoutParams.rightToRight != -1 ? "|RR" : "|__")) + (layoutParams.topToTop != -1 ? "|TT" : "|__")) + (layoutParams.topToBottom != -1 ? "|TB" : "|__")) + (layoutParams.bottomToTop != -1 ? "|BT" : "|__")) + (layoutParams.bottomToBottom != -1 ? "|BB" : "|__")));
|
|
}
|
|
|
|
private void debugWidget(String str, ConstraintWidget constraintWidget) {
|
|
String str2;
|
|
String str3;
|
|
String str4;
|
|
StringBuilder sb = new StringBuilder(" ");
|
|
ConstraintAnchor constraintAnchor = constraintWidget.mTop.mTarget;
|
|
String str5 = ExifInterface.GPS_DIRECTION_TRUE;
|
|
String str6 = "__";
|
|
if (constraintAnchor != null) {
|
|
str2 = ExifInterface.GPS_DIRECTION_TRUE.concat(constraintWidget.mTop.mTarget.mType == ConstraintAnchor.Type.TOP ? ExifInterface.GPS_DIRECTION_TRUE : "B");
|
|
} else {
|
|
str2 = "__";
|
|
}
|
|
StringBuilder append = new StringBuilder().append(sb.append(str2).toString());
|
|
if (constraintWidget.mBottom.mTarget != null) {
|
|
if (constraintWidget.mBottom.mTarget.mType != ConstraintAnchor.Type.TOP) {
|
|
str5 = "B";
|
|
}
|
|
str3 = "B".concat(str5);
|
|
} else {
|
|
str3 = "__";
|
|
}
|
|
StringBuilder append2 = new StringBuilder().append(append.append(str3).toString());
|
|
if (constraintWidget.mLeft.mTarget != null) {
|
|
str4 = "L".concat(constraintWidget.mLeft.mTarget.mType == ConstraintAnchor.Type.LEFT ? "L" : "R");
|
|
} else {
|
|
str4 = "__";
|
|
}
|
|
StringBuilder append3 = new StringBuilder().append(append2.append(str4).toString());
|
|
if (constraintWidget.mRight.mTarget != null) {
|
|
str6 = "R".concat(constraintWidget.mRight.mTarget.mType != ConstraintAnchor.Type.LEFT ? "R" : "L");
|
|
}
|
|
Log.v(MotionLayout.TAG, str + append3.append(str6).toString() + " --- " + constraintWidget);
|
|
}
|
|
|
|
private void debugLayout(String str, ConstraintWidgetContainer constraintWidgetContainer) {
|
|
String str2 = str + " " + Debug.getName((View) constraintWidgetContainer.getCompanionWidget());
|
|
Log.v(MotionLayout.TAG, str2 + " ========= " + constraintWidgetContainer);
|
|
int size = constraintWidgetContainer.getChildren().size();
|
|
for (int i = 0; i < size; i++) {
|
|
String str3 = str2 + "[" + i + "] ";
|
|
ConstraintWidget constraintWidget = constraintWidgetContainer.getChildren().get(i);
|
|
String str4 = (((constraintWidget.mTop.mTarget != null ? ExifInterface.GPS_DIRECTION_TRUE : "_") + (constraintWidget.mBottom.mTarget != null ? "B" : "_")) + (constraintWidget.mLeft.mTarget != null ? "L" : "_")) + (constraintWidget.mRight.mTarget != null ? "R" : "_");
|
|
View view = (View) constraintWidget.getCompanionWidget();
|
|
String name = Debug.getName(view);
|
|
if (view instanceof TextView) {
|
|
name = name + "(" + ((Object) ((TextView) view).getText()) + ")";
|
|
}
|
|
Log.v(MotionLayout.TAG, str3 + " " + name + " " + constraintWidget + " " + str4);
|
|
}
|
|
Log.v(MotionLayout.TAG, str2 + " done. ");
|
|
}
|
|
|
|
public void reEvaluateState() {
|
|
measure(MotionLayout.this.mLastWidthMeasureSpec, MotionLayout.this.mLastHeightMeasureSpec);
|
|
MotionLayout.this.setupMotionViews();
|
|
}
|
|
|
|
public void measure(int i, int i2) {
|
|
int mode = View.MeasureSpec.getMode(i);
|
|
int mode2 = View.MeasureSpec.getMode(i2);
|
|
MotionLayout.this.mWidthMeasureMode = mode;
|
|
MotionLayout.this.mHeightMeasureMode = mode2;
|
|
int optimizationLevel = MotionLayout.this.getOptimizationLevel();
|
|
if (MotionLayout.this.mCurrentState == MotionLayout.this.getStartState()) {
|
|
MotionLayout.this.resolveSystem(this.mLayoutEnd, optimizationLevel, i, i2);
|
|
if (this.mStart != null) {
|
|
MotionLayout.this.resolveSystem(this.mLayoutStart, optimizationLevel, i, i2);
|
|
}
|
|
} else {
|
|
if (this.mStart != null) {
|
|
MotionLayout.this.resolveSystem(this.mLayoutStart, optimizationLevel, i, i2);
|
|
}
|
|
MotionLayout.this.resolveSystem(this.mLayoutEnd, optimizationLevel, i, i2);
|
|
}
|
|
if (!(MotionLayout.this.getParent() instanceof MotionLayout) || mode != 1073741824 || mode2 != 1073741824) {
|
|
MotionLayout.this.mWidthMeasureMode = mode;
|
|
MotionLayout.this.mHeightMeasureMode = mode2;
|
|
if (MotionLayout.this.mCurrentState == MotionLayout.this.getStartState()) {
|
|
MotionLayout.this.resolveSystem(this.mLayoutEnd, optimizationLevel, i, i2);
|
|
if (this.mStart != null) {
|
|
MotionLayout.this.resolveSystem(this.mLayoutStart, optimizationLevel, i, i2);
|
|
}
|
|
} else {
|
|
if (this.mStart != null) {
|
|
MotionLayout.this.resolveSystem(this.mLayoutStart, optimizationLevel, i, i2);
|
|
}
|
|
MotionLayout.this.resolveSystem(this.mLayoutEnd, optimizationLevel, i, i2);
|
|
}
|
|
MotionLayout.this.mStartWrapWidth = this.mLayoutStart.getWidth();
|
|
MotionLayout.this.mStartWrapHeight = this.mLayoutStart.getHeight();
|
|
MotionLayout.this.mEndWrapWidth = this.mLayoutEnd.getWidth();
|
|
MotionLayout.this.mEndWrapHeight = this.mLayoutEnd.getHeight();
|
|
MotionLayout motionLayout = MotionLayout.this;
|
|
motionLayout.mMeasureDuringTransition = (motionLayout.mStartWrapWidth == MotionLayout.this.mEndWrapWidth && MotionLayout.this.mStartWrapHeight == MotionLayout.this.mEndWrapHeight) ? false : true;
|
|
}
|
|
int i3 = MotionLayout.this.mStartWrapWidth;
|
|
int i4 = MotionLayout.this.mStartWrapHeight;
|
|
if (MotionLayout.this.mWidthMeasureMode == Integer.MIN_VALUE || MotionLayout.this.mWidthMeasureMode == 0) {
|
|
i3 = (int) (MotionLayout.this.mStartWrapWidth + (MotionLayout.this.mPostInterpolationPosition * (MotionLayout.this.mEndWrapWidth - MotionLayout.this.mStartWrapWidth)));
|
|
}
|
|
int i5 = i3;
|
|
if (MotionLayout.this.mHeightMeasureMode == Integer.MIN_VALUE || MotionLayout.this.mHeightMeasureMode == 0) {
|
|
i4 = (int) (MotionLayout.this.mStartWrapHeight + (MotionLayout.this.mPostInterpolationPosition * (MotionLayout.this.mEndWrapHeight - MotionLayout.this.mStartWrapHeight)));
|
|
}
|
|
MotionLayout.this.resolveMeasuredDimension(i, i2, i5, i4, this.mLayoutStart.isWidthMeasuredTooSmall() || this.mLayoutEnd.isWidthMeasuredTooSmall(), this.mLayoutStart.isHeightMeasuredTooSmall() || this.mLayoutEnd.isHeightMeasuredTooSmall());
|
|
}
|
|
|
|
public void build() {
|
|
int childCount = MotionLayout.this.getChildCount();
|
|
MotionLayout.this.mFrameArrayList.clear();
|
|
for (int i = 0; i < childCount; i++) {
|
|
View childAt = MotionLayout.this.getChildAt(i);
|
|
MotionLayout.this.mFrameArrayList.put(childAt, new MotionController(childAt));
|
|
}
|
|
for (int i2 = 0; i2 < childCount; i2++) {
|
|
View childAt2 = MotionLayout.this.getChildAt(i2);
|
|
MotionController motionController = MotionLayout.this.mFrameArrayList.get(childAt2);
|
|
if (motionController != null) {
|
|
if (this.mStart != null) {
|
|
ConstraintWidget widget = getWidget(this.mLayoutStart, childAt2);
|
|
if (widget != null) {
|
|
motionController.setStartState(widget, this.mStart);
|
|
} else if (MotionLayout.this.mDebugPath != 0) {
|
|
Log.e(MotionLayout.TAG, Debug.getLocation() + "no widget for " + Debug.getName(childAt2) + " (" + childAt2.getClass().getName() + ")");
|
|
}
|
|
}
|
|
if (this.mEnd != null) {
|
|
ConstraintWidget widget2 = getWidget(this.mLayoutEnd, childAt2);
|
|
if (widget2 != null) {
|
|
motionController.setEndState(widget2, this.mEnd);
|
|
} else if (MotionLayout.this.mDebugPath != 0) {
|
|
Log.e(MotionLayout.TAG, Debug.getLocation() + "no widget for " + Debug.getName(childAt2) + " (" + childAt2.getClass().getName() + ")");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.widget.ConstraintLayout, android.view.View, android.view.ViewParent
|
|
public void requestLayout() {
|
|
MotionScene motionScene;
|
|
if (this.mMeasureDuringTransition || this.mCurrentState != -1 || (motionScene = this.mScene) == null || motionScene.mCurrentTransition == null || this.mScene.mCurrentTransition.getLayoutDuringTransition() != 0) {
|
|
super.requestLayout();
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public String toString() {
|
|
Context context = getContext();
|
|
return Debug.getName(context, this.mBeginState) + "->" + Debug.getName(context, this.mEndState) + " (pos:" + this.mTransitionLastPosition + " Dpos/Dt:" + this.mLastVelocity;
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.widget.ConstraintLayout, android.view.View
|
|
protected void onMeasure(int i, int i2) {
|
|
if (this.mScene == null) {
|
|
super.onMeasure(i, i2);
|
|
return;
|
|
}
|
|
boolean z = false;
|
|
boolean z2 = (this.mLastWidthMeasureSpec == i && this.mLastHeightMeasureSpec == i2) ? false : true;
|
|
if (this.mNeedsFireTransitionCompleted) {
|
|
this.mNeedsFireTransitionCompleted = false;
|
|
onNewStateAttachHandlers();
|
|
processTransitionCompleted();
|
|
z2 = true;
|
|
}
|
|
if (this.mDirtyHierarchy) {
|
|
z2 = true;
|
|
}
|
|
this.mLastWidthMeasureSpec = i;
|
|
this.mLastHeightMeasureSpec = i2;
|
|
int startId = this.mScene.getStartId();
|
|
int endId = this.mScene.getEndId();
|
|
if ((z2 || this.mModel.isNotConfiguredWith(startId, endId)) && this.mBeginState != -1) {
|
|
super.onMeasure(i, i2);
|
|
this.mModel.initFrom(this.mLayoutWidget, this.mScene.getConstraintSet(startId), this.mScene.getConstraintSet(endId));
|
|
this.mModel.reEvaluateState();
|
|
this.mModel.setMeasuredId(startId, endId);
|
|
} else {
|
|
z = true;
|
|
}
|
|
if (this.mMeasureDuringTransition || z) {
|
|
int paddingTop = getPaddingTop() + getPaddingBottom();
|
|
int width = this.mLayoutWidget.getWidth() + getPaddingLeft() + getPaddingRight();
|
|
int height = this.mLayoutWidget.getHeight() + paddingTop;
|
|
int i3 = this.mWidthMeasureMode;
|
|
if (i3 == Integer.MIN_VALUE || i3 == 0) {
|
|
width = (int) (this.mStartWrapWidth + (this.mPostInterpolationPosition * (this.mEndWrapWidth - r7)));
|
|
requestLayout();
|
|
}
|
|
int i4 = this.mHeightMeasureMode;
|
|
if (i4 == Integer.MIN_VALUE || i4 == 0) {
|
|
height = (int) (this.mStartWrapHeight + (this.mPostInterpolationPosition * (this.mEndWrapHeight - r7)));
|
|
requestLayout();
|
|
}
|
|
setMeasuredDimension(width, height);
|
|
}
|
|
evaluateLayout();
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingParent2
|
|
public boolean onStartNestedScroll(View view, View view2, int i, int i2) {
|
|
MotionScene motionScene = this.mScene;
|
|
return (motionScene == null || motionScene.mCurrentTransition == null || this.mScene.mCurrentTransition.getTouchResponse() == null || (this.mScene.mCurrentTransition.getTouchResponse().getFlags() & 2) != 0) ? false : true;
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingParent2
|
|
public void onStopNestedScroll(View view, int i) {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene == null) {
|
|
return;
|
|
}
|
|
float f = this.mScrollTargetDX;
|
|
float f2 = this.mScrollTargetDT;
|
|
motionScene.processScrollUp(f / f2, this.mScrollTargetDY / f2);
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingParent3
|
|
public void onNestedScroll(View view, int i, int i2, int i3, int i4, int i5, int[] iArr) {
|
|
if (this.mUndergoingMotion || i != 0 || i2 != 0) {
|
|
iArr[0] = iArr[0] + i3;
|
|
iArr[1] = iArr[1] + i4;
|
|
}
|
|
this.mUndergoingMotion = false;
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingParent2
|
|
public void onNestedPreScroll(final View view, int i, int i2, int[] iArr, int i3) {
|
|
TouchResponse touchResponse;
|
|
int touchRegionId;
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene == null || motionScene.mCurrentTransition == null || !this.mScene.mCurrentTransition.isEnabled()) {
|
|
return;
|
|
}
|
|
MotionScene.Transition transition = this.mScene.mCurrentTransition;
|
|
if (transition == null || !transition.isEnabled() || (touchResponse = transition.getTouchResponse()) == null || (touchRegionId = touchResponse.getTouchRegionId()) == -1 || view.getId() == touchRegionId) {
|
|
MotionScene motionScene2 = this.mScene;
|
|
if (motionScene2 != null && motionScene2.getMoveWhenScrollAtTop()) {
|
|
float f = this.mTransitionPosition;
|
|
if ((f == 1.0f || f == 0.0f) && view.canScrollVertically(-1)) {
|
|
return;
|
|
}
|
|
}
|
|
if (transition.getTouchResponse() != null && (this.mScene.mCurrentTransition.getTouchResponse().getFlags() & 1) != 0) {
|
|
float progressDirection = this.mScene.getProgressDirection(i, i2);
|
|
float f2 = this.mTransitionLastPosition;
|
|
if ((f2 <= 0.0f && progressDirection < 0.0f) || (f2 >= 1.0f && progressDirection > 0.0f)) {
|
|
view.setNestedScrollingEnabled(false);
|
|
view.post(new Runnable() { // from class: androidx.constraintlayout.motion.widget.MotionLayout.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
view.setNestedScrollingEnabled(true);
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
}
|
|
float f3 = this.mTransitionPosition;
|
|
long nanoTime = getNanoTime();
|
|
float f4 = i;
|
|
this.mScrollTargetDX = f4;
|
|
float f5 = i2;
|
|
this.mScrollTargetDY = f5;
|
|
this.mScrollTargetDT = (float) ((nanoTime - this.mScrollTargetTime) * 1.0E-9d);
|
|
this.mScrollTargetTime = nanoTime;
|
|
this.mScene.processScrollMove(f4, f5);
|
|
if (f3 != this.mTransitionPosition) {
|
|
iArr[0] = i;
|
|
iArr[1] = i2;
|
|
}
|
|
evaluate(false);
|
|
if (iArr[0] == 0 && iArr[1] == 0) {
|
|
return;
|
|
}
|
|
this.mUndergoingMotion = true;
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
private class DevModeDraw {
|
|
private static final int DEBUG_PATH_TICKS_PER_MS = 16;
|
|
DashPathEffect mDashPathEffect;
|
|
Paint mFillPaint;
|
|
int mKeyFrameCount;
|
|
float[] mKeyFramePoints;
|
|
Paint mPaint;
|
|
Paint mPaintGraph;
|
|
Paint mPaintKeyframes;
|
|
Path mPath;
|
|
int[] mPathMode;
|
|
float[] mPoints;
|
|
private float[] mRectangle;
|
|
int mShadowTranslate;
|
|
Paint mTextPaint;
|
|
final int RED_COLOR = -21965;
|
|
final int KEYFRAME_COLOR = -2067046;
|
|
final int GRAPH_COLOR = -13391360;
|
|
final int SHADOW_COLOR = 1996488704;
|
|
final int DIAMOND_SIZE = 10;
|
|
Rect mBounds = new Rect();
|
|
boolean mPresentationMode = false;
|
|
|
|
public DevModeDraw() {
|
|
this.mShadowTranslate = 1;
|
|
Paint paint = new Paint();
|
|
this.mPaint = paint;
|
|
paint.setAntiAlias(true);
|
|
this.mPaint.setColor(-21965);
|
|
this.mPaint.setStrokeWidth(2.0f);
|
|
this.mPaint.setStyle(Paint.Style.STROKE);
|
|
Paint paint2 = new Paint();
|
|
this.mPaintKeyframes = paint2;
|
|
paint2.setAntiAlias(true);
|
|
this.mPaintKeyframes.setColor(-2067046);
|
|
this.mPaintKeyframes.setStrokeWidth(2.0f);
|
|
this.mPaintKeyframes.setStyle(Paint.Style.STROKE);
|
|
Paint paint3 = new Paint();
|
|
this.mPaintGraph = paint3;
|
|
paint3.setAntiAlias(true);
|
|
this.mPaintGraph.setColor(-13391360);
|
|
this.mPaintGraph.setStrokeWidth(2.0f);
|
|
this.mPaintGraph.setStyle(Paint.Style.STROKE);
|
|
Paint paint4 = new Paint();
|
|
this.mTextPaint = paint4;
|
|
paint4.setAntiAlias(true);
|
|
this.mTextPaint.setColor(-13391360);
|
|
this.mTextPaint.setTextSize(MotionLayout.this.getContext().getResources().getDisplayMetrics().density * 12.0f);
|
|
this.mRectangle = new float[8];
|
|
Paint paint5 = new Paint();
|
|
this.mFillPaint = paint5;
|
|
paint5.setAntiAlias(true);
|
|
DashPathEffect dashPathEffect = new DashPathEffect(new float[]{4.0f, 8.0f}, 0.0f);
|
|
this.mDashPathEffect = dashPathEffect;
|
|
this.mPaintGraph.setPathEffect(dashPathEffect);
|
|
this.mKeyFramePoints = new float[100];
|
|
this.mPathMode = new int[50];
|
|
if (this.mPresentationMode) {
|
|
this.mPaint.setStrokeWidth(8.0f);
|
|
this.mFillPaint.setStrokeWidth(8.0f);
|
|
this.mPaintKeyframes.setStrokeWidth(8.0f);
|
|
this.mShadowTranslate = 4;
|
|
}
|
|
}
|
|
|
|
public void draw(Canvas canvas, HashMap<View, MotionController> hashMap, int i, int i2) {
|
|
if (hashMap == null || hashMap.size() == 0) {
|
|
return;
|
|
}
|
|
canvas.save();
|
|
if (!MotionLayout.this.isInEditMode() && (i2 & 1) == 2) {
|
|
String str = MotionLayout.this.getContext().getResources().getResourceName(MotionLayout.this.mEndState) + ":" + MotionLayout.this.getProgress();
|
|
canvas.drawText(str, 10.0f, MotionLayout.this.getHeight() - 30, this.mTextPaint);
|
|
canvas.drawText(str, 11.0f, MotionLayout.this.getHeight() - 29, this.mPaint);
|
|
}
|
|
for (MotionController motionController : hashMap.values()) {
|
|
int drawPath = motionController.getDrawPath();
|
|
if (i2 > 0 && drawPath == 0) {
|
|
drawPath = 1;
|
|
}
|
|
if (drawPath != 0) {
|
|
this.mKeyFrameCount = motionController.buildKeyFrames(this.mKeyFramePoints, this.mPathMode);
|
|
if (drawPath >= 1) {
|
|
int i3 = i / 16;
|
|
float[] fArr = this.mPoints;
|
|
if (fArr == null || fArr.length != i3 * 2) {
|
|
this.mPoints = new float[i3 * 2];
|
|
this.mPath = new Path();
|
|
}
|
|
int i4 = this.mShadowTranslate;
|
|
canvas.translate(i4, i4);
|
|
this.mPaint.setColor(1996488704);
|
|
this.mFillPaint.setColor(1996488704);
|
|
this.mPaintKeyframes.setColor(1996488704);
|
|
this.mPaintGraph.setColor(1996488704);
|
|
motionController.buildPath(this.mPoints, i3);
|
|
drawAll(canvas, drawPath, this.mKeyFrameCount, motionController);
|
|
this.mPaint.setColor(-21965);
|
|
this.mPaintKeyframes.setColor(-2067046);
|
|
this.mFillPaint.setColor(-2067046);
|
|
this.mPaintGraph.setColor(-13391360);
|
|
int i5 = this.mShadowTranslate;
|
|
canvas.translate(-i5, -i5);
|
|
drawAll(canvas, drawPath, this.mKeyFrameCount, motionController);
|
|
if (drawPath == 5) {
|
|
drawRectangle(canvas, motionController);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
canvas.restore();
|
|
}
|
|
|
|
public void drawAll(Canvas canvas, int i, int i2, MotionController motionController) {
|
|
if (i == 4) {
|
|
drawPathAsConfigured(canvas);
|
|
}
|
|
if (i == 2) {
|
|
drawPathRelative(canvas);
|
|
}
|
|
if (i == 3) {
|
|
drawPathCartesian(canvas);
|
|
}
|
|
drawBasicPath(canvas);
|
|
drawTicks(canvas, i, i2, motionController);
|
|
}
|
|
|
|
private void drawBasicPath(Canvas canvas) {
|
|
canvas.drawLines(this.mPoints, this.mPaint);
|
|
}
|
|
|
|
private void drawTicks(Canvas canvas, int i, int i2, MotionController motionController) {
|
|
int i3;
|
|
int i4;
|
|
int i5;
|
|
float f;
|
|
float f2;
|
|
if (motionController.mView != null) {
|
|
i3 = motionController.mView.getWidth();
|
|
i4 = motionController.mView.getHeight();
|
|
} else {
|
|
i3 = 0;
|
|
i4 = 0;
|
|
}
|
|
for (int i6 = 1; i6 < i2 - 1; i6++) {
|
|
if (i != 4 || this.mPathMode[i6 - 1] != 0) {
|
|
float[] fArr = this.mKeyFramePoints;
|
|
int i7 = i6 * 2;
|
|
float f3 = fArr[i7];
|
|
float f4 = fArr[i7 + 1];
|
|
this.mPath.reset();
|
|
this.mPath.moveTo(f3, f4 + 10.0f);
|
|
this.mPath.lineTo(f3 + 10.0f, f4);
|
|
this.mPath.lineTo(f3, f4 - 10.0f);
|
|
this.mPath.lineTo(f3 - 10.0f, f4);
|
|
this.mPath.close();
|
|
int i8 = i6 - 1;
|
|
motionController.getKeyFrame(i8);
|
|
if (i == 4) {
|
|
int i9 = this.mPathMode[i8];
|
|
if (i9 == 1) {
|
|
drawPathRelativeTicks(canvas, f3 - 0.0f, f4 - 0.0f);
|
|
} else if (i9 == 2) {
|
|
drawPathCartesianTicks(canvas, f3 - 0.0f, f4 - 0.0f);
|
|
} else if (i9 == 3) {
|
|
i5 = 3;
|
|
f = f4;
|
|
f2 = f3;
|
|
drawPathScreenTicks(canvas, f3 - 0.0f, f4 - 0.0f, i3, i4);
|
|
canvas.drawPath(this.mPath, this.mFillPaint);
|
|
}
|
|
i5 = 3;
|
|
f = f4;
|
|
f2 = f3;
|
|
canvas.drawPath(this.mPath, this.mFillPaint);
|
|
} else {
|
|
i5 = 3;
|
|
f = f4;
|
|
f2 = f3;
|
|
}
|
|
if (i == 2) {
|
|
drawPathRelativeTicks(canvas, f2 - 0.0f, f - 0.0f);
|
|
}
|
|
if (i == i5) {
|
|
drawPathCartesianTicks(canvas, f2 - 0.0f, f - 0.0f);
|
|
}
|
|
if (i == 6) {
|
|
drawPathScreenTicks(canvas, f2 - 0.0f, f - 0.0f, i3, i4);
|
|
}
|
|
canvas.drawPath(this.mPath, this.mFillPaint);
|
|
}
|
|
}
|
|
float[] fArr2 = this.mPoints;
|
|
if (fArr2.length > 1) {
|
|
canvas.drawCircle(fArr2[0], fArr2[1], 8.0f, this.mPaintKeyframes);
|
|
float[] fArr3 = this.mPoints;
|
|
canvas.drawCircle(fArr3[fArr3.length - 2], fArr3[fArr3.length - 1], 8.0f, this.mPaintKeyframes);
|
|
}
|
|
}
|
|
|
|
private void drawTranslation(Canvas canvas, float f, float f2, float f3, float f4) {
|
|
canvas.drawRect(f, f2, f3, f4, this.mPaintGraph);
|
|
canvas.drawLine(f, f2, f3, f4, this.mPaintGraph);
|
|
}
|
|
|
|
private void drawPathRelative(Canvas canvas) {
|
|
float[] fArr = this.mPoints;
|
|
canvas.drawLine(fArr[0], fArr[1], fArr[fArr.length - 2], fArr[fArr.length - 1], this.mPaintGraph);
|
|
}
|
|
|
|
private void drawPathAsConfigured(Canvas canvas) {
|
|
boolean z = false;
|
|
boolean z2 = false;
|
|
for (int i = 0; i < this.mKeyFrameCount; i++) {
|
|
int i2 = this.mPathMode[i];
|
|
if (i2 == 1) {
|
|
z = true;
|
|
}
|
|
if (i2 == 2) {
|
|
z2 = true;
|
|
}
|
|
}
|
|
if (z) {
|
|
drawPathRelative(canvas);
|
|
}
|
|
if (z2) {
|
|
drawPathCartesian(canvas);
|
|
}
|
|
}
|
|
|
|
private void drawPathRelativeTicks(Canvas canvas, float f, float f2) {
|
|
float[] fArr = this.mPoints;
|
|
float f3 = fArr[0];
|
|
float f4 = fArr[1];
|
|
float f5 = fArr[fArr.length - 2];
|
|
float f6 = fArr[fArr.length - 1];
|
|
float hypot = (float) Math.hypot(f3 - f5, f4 - f6);
|
|
float f7 = f5 - f3;
|
|
float f8 = f6 - f4;
|
|
float f9 = (((f - f3) * f7) + ((f2 - f4) * f8)) / (hypot * hypot);
|
|
float f10 = f3 + (f7 * f9);
|
|
float f11 = f4 + (f9 * f8);
|
|
Path path = new Path();
|
|
path.moveTo(f, f2);
|
|
path.lineTo(f10, f11);
|
|
float hypot2 = (float) Math.hypot(f10 - f, f11 - f2);
|
|
String str = "" + (((int) ((hypot2 * 100.0f) / hypot)) / 100.0f);
|
|
getTextBounds(str, this.mTextPaint);
|
|
canvas.drawTextOnPath(str, path, (hypot2 / 2.0f) - (this.mBounds.width() / 2), -20.0f, this.mTextPaint);
|
|
canvas.drawLine(f, f2, f10, f11, this.mPaintGraph);
|
|
}
|
|
|
|
void getTextBounds(String str, Paint paint) {
|
|
paint.getTextBounds(str, 0, str.length(), this.mBounds);
|
|
}
|
|
|
|
private void drawPathCartesian(Canvas canvas) {
|
|
float[] fArr = this.mPoints;
|
|
float f = fArr[0];
|
|
float f2 = fArr[1];
|
|
float f3 = fArr[fArr.length - 2];
|
|
float f4 = fArr[fArr.length - 1];
|
|
canvas.drawLine(Math.min(f, f3), Math.max(f2, f4), Math.max(f, f3), Math.max(f2, f4), this.mPaintGraph);
|
|
canvas.drawLine(Math.min(f, f3), Math.min(f2, f4), Math.min(f, f3), Math.max(f2, f4), this.mPaintGraph);
|
|
}
|
|
|
|
private void drawPathCartesianTicks(Canvas canvas, float f, float f2) {
|
|
float[] fArr = this.mPoints;
|
|
float f3 = fArr[0];
|
|
float f4 = fArr[1];
|
|
float f5 = fArr[fArr.length - 2];
|
|
float f6 = fArr[fArr.length - 1];
|
|
float min = Math.min(f3, f5);
|
|
float max = Math.max(f4, f6);
|
|
float min2 = f - Math.min(f3, f5);
|
|
float max2 = Math.max(f4, f6) - f2;
|
|
String str = "" + (((int) (((min2 * 100.0f) / Math.abs(f5 - f3)) + 0.5d)) / 100.0f);
|
|
getTextBounds(str, this.mTextPaint);
|
|
canvas.drawText(str, ((min2 / 2.0f) - (this.mBounds.width() / 2)) + min, f2 - 20.0f, this.mTextPaint);
|
|
canvas.drawLine(f, f2, Math.min(f3, f5), f2, this.mPaintGraph);
|
|
String str2 = "" + (((int) (((max2 * 100.0f) / Math.abs(f6 - f4)) + 0.5d)) / 100.0f);
|
|
getTextBounds(str2, this.mTextPaint);
|
|
canvas.drawText(str2, f + 5.0f, max - ((max2 / 2.0f) - (this.mBounds.height() / 2)), this.mTextPaint);
|
|
canvas.drawLine(f, f2, f, Math.max(f4, f6), this.mPaintGraph);
|
|
}
|
|
|
|
private void drawPathScreenTicks(Canvas canvas, float f, float f2, int i, int i2) {
|
|
String str = "" + (((int) ((((f - (i / 2)) * 100.0f) / (MotionLayout.this.getWidth() - i)) + 0.5d)) / 100.0f);
|
|
getTextBounds(str, this.mTextPaint);
|
|
canvas.drawText(str, ((f / 2.0f) - (this.mBounds.width() / 2)) + 0.0f, f2 - 20.0f, this.mTextPaint);
|
|
canvas.drawLine(f, f2, Math.min(0.0f, 1.0f), f2, this.mPaintGraph);
|
|
String str2 = "" + (((int) ((((f2 - (i2 / 2)) * 100.0f) / (MotionLayout.this.getHeight() - i2)) + 0.5d)) / 100.0f);
|
|
getTextBounds(str2, this.mTextPaint);
|
|
canvas.drawText(str2, f + 5.0f, 0.0f - ((f2 / 2.0f) - (this.mBounds.height() / 2)), this.mTextPaint);
|
|
canvas.drawLine(f, f2, f, Math.max(0.0f, 1.0f), this.mPaintGraph);
|
|
}
|
|
|
|
private void drawRectangle(Canvas canvas, MotionController motionController) {
|
|
this.mPath.reset();
|
|
for (int i = 0; i <= 50; i++) {
|
|
motionController.buildRect(i / 50, this.mRectangle, 0);
|
|
Path path = this.mPath;
|
|
float[] fArr = this.mRectangle;
|
|
path.moveTo(fArr[0], fArr[1]);
|
|
Path path2 = this.mPath;
|
|
float[] fArr2 = this.mRectangle;
|
|
path2.lineTo(fArr2[2], fArr2[3]);
|
|
Path path3 = this.mPath;
|
|
float[] fArr3 = this.mRectangle;
|
|
path3.lineTo(fArr3[4], fArr3[5]);
|
|
Path path4 = this.mPath;
|
|
float[] fArr4 = this.mRectangle;
|
|
path4.lineTo(fArr4[6], fArr4[7]);
|
|
this.mPath.close();
|
|
}
|
|
this.mPaint.setColor(1140850688);
|
|
canvas.translate(2.0f, 2.0f);
|
|
canvas.drawPath(this.mPath, this.mPaint);
|
|
canvas.translate(-2.0f, -2.0f);
|
|
this.mPaint.setColor(SupportMenu.CATEGORY_MASK);
|
|
canvas.drawPath(this.mPath, this.mPaint);
|
|
}
|
|
}
|
|
|
|
private void debugPos() {
|
|
for (int i = 0; i < getChildCount(); i++) {
|
|
View childAt = getChildAt(i);
|
|
Log.v(TAG, " " + Debug.getLocation() + " " + Debug.getName(this) + " " + Debug.getName(getContext(), this.mCurrentState) + " " + Debug.getName(childAt) + childAt.getLeft() + " " + childAt.getTop());
|
|
}
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.widget.ConstraintLayout, android.view.ViewGroup, android.view.View
|
|
protected void dispatchDraw(Canvas canvas) {
|
|
evaluate(false);
|
|
super.dispatchDraw(canvas);
|
|
if (this.mScene == null) {
|
|
return;
|
|
}
|
|
if ((this.mDebugPath & 1) == 1 && !isInEditMode()) {
|
|
this.mFrames++;
|
|
long nanoTime = getNanoTime();
|
|
long j = this.mLastDrawTime;
|
|
if (j != -1) {
|
|
if (nanoTime - j > 200000000) {
|
|
this.mLastFps = ((int) ((this.mFrames / (((float) r5) * 1.0E-9f)) * 100.0f)) / 100.0f;
|
|
this.mFrames = 0;
|
|
this.mLastDrawTime = nanoTime;
|
|
}
|
|
} else {
|
|
this.mLastDrawTime = nanoTime;
|
|
}
|
|
Paint paint = new Paint();
|
|
paint.setTextSize(42.0f);
|
|
StringBuilder append = new StringBuilder().append(this.mLastFps + " fps " + Debug.getState(this, this.mBeginState) + " -> ").append(Debug.getState(this, this.mEndState)).append(" (progress: ").append(((int) (getProgress() * 1000.0f)) / 10.0f).append(" ) state=");
|
|
int i = this.mCurrentState;
|
|
String sb = append.append(i == -1 ? "undefined" : Debug.getState(this, i)).toString();
|
|
paint.setColor(ViewCompat.MEASURED_STATE_MASK);
|
|
canvas.drawText(sb, 11.0f, getHeight() - 29, paint);
|
|
paint.setColor(-7864184);
|
|
canvas.drawText(sb, 10.0f, getHeight() - 30, paint);
|
|
}
|
|
if (this.mDebugPath > 1) {
|
|
if (this.mDevModeDraw == null) {
|
|
this.mDevModeDraw = new DevModeDraw();
|
|
}
|
|
this.mDevModeDraw.draw(canvas, this.mFrameArrayList, this.mScene.getDuration(), this.mDebugPath);
|
|
}
|
|
}
|
|
|
|
private void evaluateLayout() {
|
|
boolean z;
|
|
float signum = Math.signum(this.mTransitionGoalPosition - this.mTransitionLastPosition);
|
|
long nanoTime = getNanoTime();
|
|
Interpolator interpolator = this.mInterpolator;
|
|
float f = this.mTransitionLastPosition + (!(interpolator instanceof StopLogic) ? ((((float) (nanoTime - this.mTransitionLastTime)) * signum) * 1.0E-9f) / this.mTransitionDuration : 0.0f);
|
|
if (this.mTransitionInstantly) {
|
|
f = this.mTransitionGoalPosition;
|
|
}
|
|
if ((signum <= 0.0f || f < this.mTransitionGoalPosition) && (signum > 0.0f || f > this.mTransitionGoalPosition)) {
|
|
z = false;
|
|
} else {
|
|
f = this.mTransitionGoalPosition;
|
|
z = true;
|
|
}
|
|
if (interpolator != null && !z) {
|
|
if (this.mTemporalInterpolator) {
|
|
f = interpolator.getInterpolation(((float) (nanoTime - this.mAnimationStartTime)) * 1.0E-9f);
|
|
} else {
|
|
f = interpolator.getInterpolation(f);
|
|
}
|
|
}
|
|
if ((signum > 0.0f && f >= this.mTransitionGoalPosition) || (signum <= 0.0f && f <= this.mTransitionGoalPosition)) {
|
|
f = this.mTransitionGoalPosition;
|
|
}
|
|
this.mPostInterpolationPosition = f;
|
|
int childCount = getChildCount();
|
|
long nanoTime2 = getNanoTime();
|
|
for (int i = 0; i < childCount; i++) {
|
|
View childAt = getChildAt(i);
|
|
MotionController motionController = this.mFrameArrayList.get(childAt);
|
|
if (motionController != null) {
|
|
motionController.interpolate(childAt, f, nanoTime2, this.mKeyCache);
|
|
}
|
|
}
|
|
if (this.mMeasureDuringTransition) {
|
|
requestLayout();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public void evaluate(boolean z) {
|
|
float f;
|
|
boolean z2;
|
|
int i;
|
|
float interpolation;
|
|
boolean z3;
|
|
if (this.mTransitionLastTime == -1) {
|
|
this.mTransitionLastTime = getNanoTime();
|
|
}
|
|
float f2 = this.mTransitionLastPosition;
|
|
if (f2 > 0.0f && f2 < 1.0f) {
|
|
this.mCurrentState = -1;
|
|
}
|
|
boolean z4 = false;
|
|
if (this.mKeepAnimating || (this.mInTransition && (z || this.mTransitionGoalPosition != f2))) {
|
|
float signum = Math.signum(this.mTransitionGoalPosition - f2);
|
|
long nanoTime = getNanoTime();
|
|
Interpolator interpolator = this.mInterpolator;
|
|
if (interpolator instanceof MotionInterpolator) {
|
|
f = 0.0f;
|
|
} else {
|
|
f = ((((float) (nanoTime - this.mTransitionLastTime)) * signum) * 1.0E-9f) / this.mTransitionDuration;
|
|
this.mLastVelocity = f;
|
|
}
|
|
float f3 = this.mTransitionLastPosition + f;
|
|
if (this.mTransitionInstantly) {
|
|
f3 = this.mTransitionGoalPosition;
|
|
}
|
|
if ((signum <= 0.0f || f3 < this.mTransitionGoalPosition) && (signum > 0.0f || f3 > this.mTransitionGoalPosition)) {
|
|
z2 = false;
|
|
} else {
|
|
f3 = this.mTransitionGoalPosition;
|
|
this.mInTransition = false;
|
|
z2 = true;
|
|
}
|
|
this.mTransitionLastPosition = f3;
|
|
this.mTransitionPosition = f3;
|
|
this.mTransitionLastTime = nanoTime;
|
|
if (interpolator != null && !z2) {
|
|
if (this.mTemporalInterpolator) {
|
|
interpolation = interpolator.getInterpolation(((float) (nanoTime - this.mAnimationStartTime)) * 1.0E-9f);
|
|
this.mTransitionLastPosition = interpolation;
|
|
this.mTransitionLastTime = nanoTime;
|
|
Interpolator interpolator2 = this.mInterpolator;
|
|
if (interpolator2 instanceof MotionInterpolator) {
|
|
float velocity = ((MotionInterpolator) interpolator2).getVelocity();
|
|
this.mLastVelocity = velocity;
|
|
if (Math.abs(velocity) * this.mTransitionDuration <= EPSILON) {
|
|
this.mInTransition = false;
|
|
}
|
|
if (velocity > 0.0f && interpolation >= 1.0f) {
|
|
this.mTransitionLastPosition = 1.0f;
|
|
this.mInTransition = false;
|
|
interpolation = 1.0f;
|
|
}
|
|
if (velocity < 0.0f && interpolation <= 0.0f) {
|
|
this.mTransitionLastPosition = 0.0f;
|
|
this.mInTransition = false;
|
|
f3 = 0.0f;
|
|
}
|
|
}
|
|
} else {
|
|
interpolation = interpolator.getInterpolation(f3);
|
|
Interpolator interpolator3 = this.mInterpolator;
|
|
if (interpolator3 instanceof MotionInterpolator) {
|
|
this.mLastVelocity = ((MotionInterpolator) interpolator3).getVelocity();
|
|
} else {
|
|
this.mLastVelocity = ((interpolator3.getInterpolation(f3 + f) - interpolation) * signum) / f;
|
|
}
|
|
}
|
|
f3 = interpolation;
|
|
}
|
|
if (Math.abs(this.mLastVelocity) > EPSILON) {
|
|
setState(TransitionState.MOVING);
|
|
}
|
|
if ((signum > 0.0f && f3 >= this.mTransitionGoalPosition) || (signum <= 0.0f && f3 <= this.mTransitionGoalPosition)) {
|
|
f3 = this.mTransitionGoalPosition;
|
|
this.mInTransition = false;
|
|
}
|
|
if (f3 >= 1.0f || f3 <= 0.0f) {
|
|
this.mInTransition = false;
|
|
setState(TransitionState.FINISHED);
|
|
}
|
|
int childCount = getChildCount();
|
|
this.mKeepAnimating = false;
|
|
long nanoTime2 = getNanoTime();
|
|
this.mPostInterpolationPosition = f3;
|
|
for (int i2 = 0; i2 < childCount; i2++) {
|
|
View childAt = getChildAt(i2);
|
|
MotionController motionController = this.mFrameArrayList.get(childAt);
|
|
if (motionController != null) {
|
|
this.mKeepAnimating = motionController.interpolate(childAt, f3, nanoTime2, this.mKeyCache) | this.mKeepAnimating;
|
|
}
|
|
}
|
|
boolean z5 = (signum > 0.0f && f3 >= this.mTransitionGoalPosition) || (signum <= 0.0f && f3 <= this.mTransitionGoalPosition);
|
|
if (!this.mKeepAnimating && !this.mInTransition && z5) {
|
|
setState(TransitionState.FINISHED);
|
|
}
|
|
if (this.mMeasureDuringTransition) {
|
|
requestLayout();
|
|
}
|
|
this.mKeepAnimating = (!z5) | this.mKeepAnimating;
|
|
if (f3 <= 0.0f && (i = this.mBeginState) != -1 && this.mCurrentState != i) {
|
|
this.mCurrentState = i;
|
|
this.mScene.getConstraintSet(i).applyCustomAttributes(this);
|
|
setState(TransitionState.FINISHED);
|
|
z4 = true;
|
|
}
|
|
if (f3 >= 1.0d) {
|
|
int i3 = this.mCurrentState;
|
|
int i4 = this.mEndState;
|
|
if (i3 != i4) {
|
|
this.mCurrentState = i4;
|
|
this.mScene.getConstraintSet(i4).applyCustomAttributes(this);
|
|
setState(TransitionState.FINISHED);
|
|
z4 = true;
|
|
}
|
|
}
|
|
if (this.mKeepAnimating || this.mInTransition) {
|
|
invalidate();
|
|
} else if ((signum > 0.0f && f3 == 1.0f) || (signum < 0.0f && f3 == 0.0f)) {
|
|
setState(TransitionState.FINISHED);
|
|
}
|
|
if ((!this.mKeepAnimating && this.mInTransition && signum > 0.0f && f3 == 1.0f) || (signum < 0.0f && f3 == 0.0f)) {
|
|
onNewStateAttachHandlers();
|
|
}
|
|
}
|
|
float f4 = this.mTransitionLastPosition;
|
|
if (f4 < 1.0f) {
|
|
if (f4 <= 0.0f) {
|
|
int i5 = this.mCurrentState;
|
|
int i6 = this.mBeginState;
|
|
z3 = i5 == i6 ? z4 : true;
|
|
this.mCurrentState = i6;
|
|
}
|
|
this.mNeedsFireTransitionCompleted |= z4;
|
|
if (z4 && !this.mInLayout) {
|
|
requestLayout();
|
|
}
|
|
this.mTransitionPosition = this.mTransitionLastPosition;
|
|
}
|
|
int i7 = this.mCurrentState;
|
|
int i8 = this.mEndState;
|
|
z3 = i7 == i8 ? z4 : true;
|
|
this.mCurrentState = i8;
|
|
z4 = z3;
|
|
this.mNeedsFireTransitionCompleted |= z4;
|
|
if (z4) {
|
|
requestLayout();
|
|
}
|
|
this.mTransitionPosition = this.mTransitionLastPosition;
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.widget.ConstraintLayout, android.view.ViewGroup, android.view.View
|
|
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
|
|
this.mInLayout = true;
|
|
try {
|
|
if (this.mScene == null) {
|
|
super.onLayout(z, i, i2, i3, i4);
|
|
return;
|
|
}
|
|
int i5 = i3 - i;
|
|
int i6 = i4 - i2;
|
|
if (this.mLastLayoutWidth != i5 || this.mLastLayoutHeight != i6) {
|
|
rebuildScene();
|
|
evaluate(true);
|
|
}
|
|
this.mLastLayoutWidth = i5;
|
|
this.mLastLayoutHeight = i6;
|
|
this.mOldWidth = i5;
|
|
this.mOldHeight = i6;
|
|
} finally {
|
|
this.mInLayout = false;
|
|
}
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.widget.ConstraintLayout
|
|
protected void parseLayoutDescription(int i) {
|
|
this.mConstraintLayoutSpec = null;
|
|
}
|
|
|
|
private void init(AttributeSet attributeSet) {
|
|
MotionScene motionScene;
|
|
IS_IN_EDIT_MODE = isInEditMode();
|
|
if (attributeSet != null) {
|
|
TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attributeSet, R.styleable.MotionLayout);
|
|
int indexCount = obtainStyledAttributes.getIndexCount();
|
|
boolean z = true;
|
|
for (int i = 0; i < indexCount; i++) {
|
|
int index = obtainStyledAttributes.getIndex(i);
|
|
if (index == R.styleable.MotionLayout_layoutDescription) {
|
|
this.mScene = new MotionScene(getContext(), this, obtainStyledAttributes.getResourceId(index, -1));
|
|
} else if (index == R.styleable.MotionLayout_currentState) {
|
|
this.mCurrentState = obtainStyledAttributes.getResourceId(index, -1);
|
|
} else if (index == R.styleable.MotionLayout_motionProgress) {
|
|
this.mTransitionGoalPosition = obtainStyledAttributes.getFloat(index, 0.0f);
|
|
this.mInTransition = true;
|
|
} else if (index == R.styleable.MotionLayout_applyMotionScene) {
|
|
z = obtainStyledAttributes.getBoolean(index, z);
|
|
} else if (index == R.styleable.MotionLayout_showPaths) {
|
|
if (this.mDebugPath == 0) {
|
|
this.mDebugPath = obtainStyledAttributes.getBoolean(index, false) ? 2 : 0;
|
|
}
|
|
} else if (index == R.styleable.MotionLayout_motionDebug) {
|
|
this.mDebugPath = obtainStyledAttributes.getInt(index, 0);
|
|
}
|
|
}
|
|
obtainStyledAttributes.recycle();
|
|
if (this.mScene == null) {
|
|
Log.e(TAG, "WARNING NO app:layoutDescription tag");
|
|
}
|
|
if (!z) {
|
|
this.mScene = null;
|
|
}
|
|
}
|
|
if (this.mDebugPath != 0) {
|
|
checkStructure();
|
|
}
|
|
if (this.mCurrentState != -1 || (motionScene = this.mScene) == null) {
|
|
return;
|
|
}
|
|
this.mCurrentState = motionScene.getStartId();
|
|
this.mBeginState = this.mScene.getStartId();
|
|
this.mEndState = this.mScene.getEndId();
|
|
}
|
|
|
|
public void setScene(MotionScene motionScene) {
|
|
this.mScene = motionScene;
|
|
motionScene.setRtl(isRtl());
|
|
rebuildScene();
|
|
}
|
|
|
|
private void checkStructure() {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene == null) {
|
|
Log.e(TAG, "CHECK: motion scene not set! set \"app:layoutDescription=\"@xml/file\"");
|
|
return;
|
|
}
|
|
int startId = motionScene.getStartId();
|
|
MotionScene motionScene2 = this.mScene;
|
|
checkStructure(startId, motionScene2.getConstraintSet(motionScene2.getStartId()));
|
|
SparseIntArray sparseIntArray = new SparseIntArray();
|
|
SparseIntArray sparseIntArray2 = new SparseIntArray();
|
|
Iterator<MotionScene.Transition> it = this.mScene.getDefinedTransitions().iterator();
|
|
while (it.hasNext()) {
|
|
MotionScene.Transition next = it.next();
|
|
if (next == this.mScene.mCurrentTransition) {
|
|
Log.v(TAG, "CHECK: CURRENT");
|
|
}
|
|
checkStructure(next);
|
|
int startConstraintSetId = next.getStartConstraintSetId();
|
|
int endConstraintSetId = next.getEndConstraintSetId();
|
|
String name = Debug.getName(getContext(), startConstraintSetId);
|
|
String name2 = Debug.getName(getContext(), endConstraintSetId);
|
|
if (sparseIntArray.get(startConstraintSetId) == endConstraintSetId) {
|
|
Log.e(TAG, "CHECK: two transitions with the same start and end " + name + "->" + name2);
|
|
}
|
|
if (sparseIntArray2.get(endConstraintSetId) == startConstraintSetId) {
|
|
Log.e(TAG, "CHECK: you can't have reverse transitions" + name + "->" + name2);
|
|
}
|
|
sparseIntArray.put(startConstraintSetId, endConstraintSetId);
|
|
sparseIntArray2.put(endConstraintSetId, startConstraintSetId);
|
|
if (this.mScene.getConstraintSet(startConstraintSetId) == null) {
|
|
Log.e(TAG, " no such constraintSetStart " + name);
|
|
}
|
|
if (this.mScene.getConstraintSet(endConstraintSetId) == null) {
|
|
Log.e(TAG, " no such constraintSetEnd " + name);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void checkStructure(int i, ConstraintSet constraintSet) {
|
|
String name = Debug.getName(getContext(), i);
|
|
int childCount = getChildCount();
|
|
for (int i2 = 0; i2 < childCount; i2++) {
|
|
View childAt = getChildAt(i2);
|
|
int id = childAt.getId();
|
|
if (id == -1) {
|
|
Log.w(TAG, "CHECK: " + name + " ALL VIEWS SHOULD HAVE ID's " + childAt.getClass().getName() + " does not!");
|
|
}
|
|
if (constraintSet.getConstraint(id) == null) {
|
|
Log.w(TAG, "CHECK: " + name + " NO CONSTRAINTS for " + Debug.getName(childAt));
|
|
}
|
|
}
|
|
int[] knownIds = constraintSet.getKnownIds();
|
|
for (int i3 = 0; i3 < knownIds.length; i3++) {
|
|
int i4 = knownIds[i3];
|
|
String name2 = Debug.getName(getContext(), i4);
|
|
if (findViewById(knownIds[i3]) == null) {
|
|
Log.w(TAG, "CHECK: " + name + " NO View matches id " + name2);
|
|
}
|
|
if (constraintSet.getHeight(i4) == -1) {
|
|
Log.w(TAG, "CHECK: " + name + "(" + name2 + ") no LAYOUT_HEIGHT");
|
|
}
|
|
if (constraintSet.getWidth(i4) == -1) {
|
|
Log.w(TAG, "CHECK: " + name + "(" + name2 + ") no LAYOUT_HEIGHT");
|
|
}
|
|
}
|
|
}
|
|
|
|
private void checkStructure(MotionScene.Transition transition) {
|
|
Log.v(TAG, "CHECK: transition = " + transition.debugString(getContext()));
|
|
Log.v(TAG, "CHECK: transition.setDuration = " + transition.getDuration());
|
|
if (transition.getStartConstraintSetId() == transition.getEndConstraintSetId()) {
|
|
Log.e(TAG, "CHECK: start and end constraint set should not be the same!");
|
|
}
|
|
}
|
|
|
|
public void setDebugMode(int i) {
|
|
this.mDebugPath = i;
|
|
invalidate();
|
|
}
|
|
|
|
public void getDebugMode(boolean z) {
|
|
this.mDebugPath = z ? 2 : 1;
|
|
invalidate();
|
|
}
|
|
|
|
private boolean handlesTouchEvent(float f, float f2, View view, MotionEvent motionEvent) {
|
|
if (view instanceof ViewGroup) {
|
|
ViewGroup viewGroup = (ViewGroup) view;
|
|
int childCount = viewGroup.getChildCount();
|
|
for (int i = 0; i < childCount; i++) {
|
|
if (handlesTouchEvent(view.getLeft() + f, view.getTop() + f2, viewGroup.getChildAt(i), motionEvent)) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
this.mBoundsCheck.set(view.getLeft() + f, view.getTop() + f2, f + view.getRight(), f2 + view.getBottom());
|
|
if (motionEvent.getAction() == 0) {
|
|
if (this.mBoundsCheck.contains(motionEvent.getX(), motionEvent.getY()) && view.onTouchEvent(motionEvent)) {
|
|
return true;
|
|
}
|
|
} else if (view.onTouchEvent(motionEvent)) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
|
|
MotionScene.Transition transition;
|
|
TouchResponse touchResponse;
|
|
int touchRegionId;
|
|
RectF touchRegion;
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene != null && this.mInteractionEnabled && (transition = motionScene.mCurrentTransition) != null && transition.isEnabled() && (touchResponse = transition.getTouchResponse()) != null && ((motionEvent.getAction() != 0 || (touchRegion = touchResponse.getTouchRegion(this, new RectF())) == null || touchRegion.contains(motionEvent.getX(), motionEvent.getY())) && (touchRegionId = touchResponse.getTouchRegionId()) != -1)) {
|
|
View view = this.mRegionView;
|
|
if (view == null || view.getId() != touchRegionId) {
|
|
this.mRegionView = findViewById(touchRegionId);
|
|
}
|
|
if (this.mRegionView != null) {
|
|
this.mBoundsCheck.set(r0.getLeft(), this.mRegionView.getTop(), this.mRegionView.getRight(), this.mRegionView.getBottom());
|
|
if (this.mBoundsCheck.contains(motionEvent.getX(), motionEvent.getY()) && !handlesTouchEvent(0.0f, 0.0f, this.mRegionView, motionEvent)) {
|
|
return onTouchEvent(motionEvent);
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public boolean onTouchEvent(MotionEvent motionEvent) {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene != null && this.mInteractionEnabled && motionScene.supportTouch()) {
|
|
MotionScene.Transition transition = this.mScene.mCurrentTransition;
|
|
if (transition != null && !transition.isEnabled()) {
|
|
return super.onTouchEvent(motionEvent);
|
|
}
|
|
this.mScene.processTouchEvent(motionEvent, getCurrentState(), this);
|
|
return true;
|
|
}
|
|
return super.onTouchEvent(motionEvent);
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
protected void onAttachedToWindow() {
|
|
int i;
|
|
super.onAttachedToWindow();
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene != null && (i = this.mCurrentState) != -1) {
|
|
ConstraintSet constraintSet = motionScene.getConstraintSet(i);
|
|
this.mScene.readFallback(this);
|
|
if (constraintSet != null) {
|
|
constraintSet.applyTo(this);
|
|
}
|
|
this.mBeginState = this.mCurrentState;
|
|
}
|
|
onNewStateAttachHandlers();
|
|
StateCache stateCache = this.mStateCache;
|
|
if (stateCache != null) {
|
|
stateCache.apply();
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onRtlPropertiesChanged(int i) {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene != null) {
|
|
motionScene.setRtl(isRtl());
|
|
}
|
|
}
|
|
|
|
private void onNewStateAttachHandlers() {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene == null) {
|
|
return;
|
|
}
|
|
if (motionScene.autoTransition(this, this.mCurrentState)) {
|
|
requestLayout();
|
|
return;
|
|
}
|
|
int i = this.mCurrentState;
|
|
if (i != -1) {
|
|
this.mScene.addOnClickListeners(this, i);
|
|
}
|
|
if (this.mScene.supportTouch()) {
|
|
this.mScene.setupTouch();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public void getAnchorDpDt(int i, float f, float f2, float f3, float[] fArr) {
|
|
String resourceName;
|
|
HashMap<View, MotionController> hashMap = this.mFrameArrayList;
|
|
View viewById = getViewById(i);
|
|
MotionController motionController = hashMap.get(viewById);
|
|
if (motionController != null) {
|
|
motionController.getDpDt(f, f2, f3, fArr);
|
|
float y = viewById.getY();
|
|
this.lastPos = f;
|
|
this.lastY = y;
|
|
return;
|
|
}
|
|
if (viewById == null) {
|
|
resourceName = "" + i;
|
|
} else {
|
|
resourceName = viewById.getContext().getResources().getResourceName(i);
|
|
}
|
|
Log.w(TAG, "WARNING could not find view id " + resourceName);
|
|
}
|
|
|
|
public long getTransitionTimeMs() {
|
|
if (this.mScene != null) {
|
|
this.mTransitionDuration = r0.getDuration() / 1000.0f;
|
|
}
|
|
return this.mTransitionDuration * 1000.0f;
|
|
}
|
|
|
|
public void addTransitionListener(TransitionListener transitionListener) {
|
|
if (this.mTransitionListeners == null) {
|
|
this.mTransitionListeners = new ArrayList<>();
|
|
}
|
|
this.mTransitionListeners.add(transitionListener);
|
|
}
|
|
|
|
public boolean removeTransitionListener(TransitionListener transitionListener) {
|
|
ArrayList<TransitionListener> arrayList = this.mTransitionListeners;
|
|
if (arrayList == null) {
|
|
return false;
|
|
}
|
|
return arrayList.remove(transitionListener);
|
|
}
|
|
|
|
public void fireTrigger(int i, boolean z, float f) {
|
|
TransitionListener transitionListener = this.mTransitionListener;
|
|
if (transitionListener != null) {
|
|
transitionListener.onTransitionTrigger(this, i, z, f);
|
|
}
|
|
ArrayList<TransitionListener> arrayList = this.mTransitionListeners;
|
|
if (arrayList != null) {
|
|
Iterator<TransitionListener> it = arrayList.iterator();
|
|
while (it.hasNext()) {
|
|
it.next().onTransitionTrigger(this, i, z, f);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void fireTransitionChange() {
|
|
ArrayList<TransitionListener> arrayList;
|
|
if ((this.mTransitionListener == null && ((arrayList = this.mTransitionListeners) == null || arrayList.isEmpty())) || this.mListenerPosition == this.mTransitionPosition) {
|
|
return;
|
|
}
|
|
if (this.mListenerState != -1) {
|
|
TransitionListener transitionListener = this.mTransitionListener;
|
|
if (transitionListener != null) {
|
|
transitionListener.onTransitionStarted(this, this.mBeginState, this.mEndState);
|
|
}
|
|
ArrayList<TransitionListener> arrayList2 = this.mTransitionListeners;
|
|
if (arrayList2 != null) {
|
|
Iterator<TransitionListener> it = arrayList2.iterator();
|
|
while (it.hasNext()) {
|
|
it.next().onTransitionStarted(this, this.mBeginState, this.mEndState);
|
|
}
|
|
}
|
|
this.mIsAnimating = true;
|
|
}
|
|
this.mListenerState = -1;
|
|
float f = this.mTransitionPosition;
|
|
this.mListenerPosition = f;
|
|
TransitionListener transitionListener2 = this.mTransitionListener;
|
|
if (transitionListener2 != null) {
|
|
transitionListener2.onTransitionChange(this, this.mBeginState, this.mEndState, f);
|
|
}
|
|
ArrayList<TransitionListener> arrayList3 = this.mTransitionListeners;
|
|
if (arrayList3 != null) {
|
|
Iterator<TransitionListener> it2 = arrayList3.iterator();
|
|
while (it2.hasNext()) {
|
|
it2.next().onTransitionChange(this, this.mBeginState, this.mEndState, this.mTransitionPosition);
|
|
}
|
|
}
|
|
this.mIsAnimating = true;
|
|
}
|
|
|
|
protected void fireTransitionCompleted() {
|
|
int i;
|
|
ArrayList<TransitionListener> arrayList;
|
|
if ((this.mTransitionListener != null || ((arrayList = this.mTransitionListeners) != null && !arrayList.isEmpty())) && this.mListenerState == -1) {
|
|
this.mListenerState = this.mCurrentState;
|
|
if (this.mTransitionCompleted.isEmpty()) {
|
|
i = -1;
|
|
} else {
|
|
i = this.mTransitionCompleted.get(r0.size() - 1).intValue();
|
|
}
|
|
int i2 = this.mCurrentState;
|
|
if (i != i2 && i2 != -1) {
|
|
this.mTransitionCompleted.add(Integer.valueOf(i2));
|
|
}
|
|
}
|
|
processTransitionCompleted();
|
|
}
|
|
|
|
private void processTransitionCompleted() {
|
|
ArrayList<TransitionListener> arrayList;
|
|
if (this.mTransitionListener == null && ((arrayList = this.mTransitionListeners) == null || arrayList.isEmpty())) {
|
|
return;
|
|
}
|
|
this.mIsAnimating = false;
|
|
Iterator<Integer> it = this.mTransitionCompleted.iterator();
|
|
while (it.hasNext()) {
|
|
Integer next = it.next();
|
|
TransitionListener transitionListener = this.mTransitionListener;
|
|
if (transitionListener != null) {
|
|
transitionListener.onTransitionCompleted(this, next.intValue());
|
|
}
|
|
ArrayList<TransitionListener> arrayList2 = this.mTransitionListeners;
|
|
if (arrayList2 != null) {
|
|
Iterator<TransitionListener> it2 = arrayList2.iterator();
|
|
while (it2.hasNext()) {
|
|
it2.next().onTransitionCompleted(this, next.intValue());
|
|
}
|
|
}
|
|
}
|
|
this.mTransitionCompleted.clear();
|
|
}
|
|
|
|
public DesignTool getDesignTool() {
|
|
if (this.mDesignTool == null) {
|
|
this.mDesignTool = new DesignTool(this);
|
|
}
|
|
return this.mDesignTool;
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.widget.ConstraintLayout, android.view.ViewGroup
|
|
public void onViewAdded(View view) {
|
|
super.onViewAdded(view);
|
|
if (view instanceof MotionHelper) {
|
|
MotionHelper motionHelper = (MotionHelper) view;
|
|
if (this.mTransitionListeners == null) {
|
|
this.mTransitionListeners = new ArrayList<>();
|
|
}
|
|
this.mTransitionListeners.add(motionHelper);
|
|
if (motionHelper.isUsedOnShow()) {
|
|
if (this.mOnShowHelpers == null) {
|
|
this.mOnShowHelpers = new ArrayList<>();
|
|
}
|
|
this.mOnShowHelpers.add(motionHelper);
|
|
}
|
|
if (motionHelper.isUseOnHide()) {
|
|
if (this.mOnHideHelpers == null) {
|
|
this.mOnHideHelpers = new ArrayList<>();
|
|
}
|
|
this.mOnHideHelpers.add(motionHelper);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.widget.ConstraintLayout, android.view.ViewGroup
|
|
public void onViewRemoved(View view) {
|
|
super.onViewRemoved(view);
|
|
ArrayList<MotionHelper> arrayList = this.mOnShowHelpers;
|
|
if (arrayList != null) {
|
|
arrayList.remove(view);
|
|
}
|
|
ArrayList<MotionHelper> arrayList2 = this.mOnHideHelpers;
|
|
if (arrayList2 != null) {
|
|
arrayList2.remove(view);
|
|
}
|
|
}
|
|
|
|
public void setOnShow(float f) {
|
|
ArrayList<MotionHelper> arrayList = this.mOnShowHelpers;
|
|
if (arrayList != null) {
|
|
int size = arrayList.size();
|
|
for (int i = 0; i < size; i++) {
|
|
this.mOnShowHelpers.get(i).setProgress(f);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setOnHide(float f) {
|
|
ArrayList<MotionHelper> arrayList = this.mOnHideHelpers;
|
|
if (arrayList != null) {
|
|
int size = arrayList.size();
|
|
for (int i = 0; i < size; i++) {
|
|
this.mOnHideHelpers.get(i).setProgress(f);
|
|
}
|
|
}
|
|
}
|
|
|
|
public int[] getConstraintSetIds() {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene == null) {
|
|
return null;
|
|
}
|
|
return motionScene.getConstraintSetIds();
|
|
}
|
|
|
|
public ConstraintSet getConstraintSet(int i) {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene == null) {
|
|
return null;
|
|
}
|
|
return motionScene.getConstraintSet(i);
|
|
}
|
|
|
|
@Deprecated
|
|
public void rebuildMotion() {
|
|
Log.e(TAG, "This method is deprecated. Please call rebuildScene() instead.");
|
|
rebuildScene();
|
|
}
|
|
|
|
public void rebuildScene() {
|
|
this.mModel.reEvaluateState();
|
|
invalidate();
|
|
}
|
|
|
|
public void updateState(int i, ConstraintSet constraintSet) {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene != null) {
|
|
motionScene.setConstraintSet(i, constraintSet);
|
|
}
|
|
updateState();
|
|
if (this.mCurrentState == i) {
|
|
constraintSet.applyTo(this);
|
|
}
|
|
}
|
|
|
|
public void updateState() {
|
|
this.mModel.initFrom(this.mLayoutWidget, this.mScene.getConstraintSet(this.mBeginState), this.mScene.getConstraintSet(this.mEndState));
|
|
rebuildScene();
|
|
}
|
|
|
|
public ArrayList<MotionScene.Transition> getDefinedTransitions() {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene == null) {
|
|
return null;
|
|
}
|
|
return motionScene.getDefinedTransitions();
|
|
}
|
|
|
|
public void setTransitionDuration(int i) {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene == null) {
|
|
Log.e(TAG, "MotionScene not defined");
|
|
} else {
|
|
motionScene.setDuration(i);
|
|
}
|
|
}
|
|
|
|
public MotionScene.Transition getTransition(int i) {
|
|
return this.mScene.getTransitionById(i);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public int lookUpConstraintId(String str) {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene == null) {
|
|
return 0;
|
|
}
|
|
return motionScene.lookUpConstraintId(str);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public String getConstraintSetNames(int i) {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene == null) {
|
|
return null;
|
|
}
|
|
return motionScene.lookUpConstraintName(i);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public void disableAutoTransition(boolean z) {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene == null) {
|
|
return;
|
|
}
|
|
motionScene.disableAutoTransition(z);
|
|
}
|
|
|
|
private void fireTransitionStarted(MotionLayout motionLayout, int i, int i2) {
|
|
TransitionListener transitionListener = this.mTransitionListener;
|
|
if (transitionListener != null) {
|
|
transitionListener.onTransitionStarted(this, i, i2);
|
|
}
|
|
ArrayList<TransitionListener> arrayList = this.mTransitionListeners;
|
|
if (arrayList != null) {
|
|
Iterator<TransitionListener> it = arrayList.iterator();
|
|
while (it.hasNext()) {
|
|
it.next().onTransitionStarted(motionLayout, i, i2);
|
|
}
|
|
}
|
|
}
|
|
}
|