discord-jadx/app/src/main/java/androidx/constraintlayout/motion/widget/MotionLayout.java

2786 lines
119 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.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.motion.utils.StopLogic;
import androidx.constraintlayout.motion.widget.MotionScene;
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.Barrier;
import androidx.constraintlayout.widget.ConstraintHelper;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.ConstraintLayoutStates;
import androidx.constraintlayout.widget.ConstraintSet;
import androidx.constraintlayout.widget.Constraints;
import androidx.constraintlayout.widget.R;
import androidx.constraintlayout.widget.StateSet;
import androidx.core.view.NestedScrollingParent3;
import c.d.b.a.a;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
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;
public static final int MAX_KEY_FRAMES = 50;
public 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;
public boolean firstDown = true;
private float lastPos;
private float lastY;
private long mAnimationStartTime = 0;
private int mBeginState = -1;
private RectF mBoundsCheck = new RectF();
public int mCurrentState = -1;
public int mDebugPath = 0;
private DecelerateInterpolator mDecelerateLogic = new DecelerateInterpolator();
private DesignTool mDesignTool;
public DevModeDraw mDevModeDraw;
private int mEndState = -1;
public int mEndWrapHeight;
public int mEndWrapWidth;
public HashMap<View, MotionController> mFrameArrayList = new HashMap<>();
private int mFrames = 0;
public int mHeightMeasureMode;
private boolean mInLayout = false;
public boolean mInTransition = false;
public boolean mIndirectTransition = false;
private boolean mInteractionEnabled = true;
public Interpolator mInterpolator;
public boolean mIsAnimating = false;
private boolean mKeepAnimating = false;
private KeyCache mKeyCache = new KeyCache();
private long mLastDrawTime = -1;
private float mLastFps = 0.0f;
private int mLastHeightMeasureSpec = 0;
public int mLastLayoutHeight;
public int mLastLayoutWidth;
public float mLastVelocity = 0.0f;
private int mLastWidthMeasureSpec = 0;
private float mListenerPosition = 0.0f;
private int mListenerState = 0;
public boolean mMeasureDuringTransition = false;
public Model mModel = new Model();
private boolean mNeedsFireTransitionCompleted = false;
public int mOldHeight;
public int mOldWidth;
private ArrayList<MotionHelper> mOnHideHelpers = null;
private ArrayList<MotionHelper> mOnShowHelpers = null;
public float mPostInterpolationPosition;
private View mRegionView = null;
public MotionScene mScene;
public float mScrollTargetDT;
public float mScrollTargetDX;
public float mScrollTargetDY;
public long mScrollTargetTime;
public int mStartWrapHeight;
public int mStartWrapWidth;
private StateCache mStateCache;
private StopLogic mStopLogic = new StopLogic();
private boolean mTemporalInterpolator = false;
public ArrayList<Integer> mTransitionCompleted = new ArrayList<>();
private float mTransitionDuration = 1.0f;
public float mTransitionGoalPosition = 0.0f;
private boolean mTransitionInstantly;
public float mTransitionLastPosition = 0.0f;
private long mTransitionLastTime;
private TransitionListener mTransitionListener;
private ArrayList<TransitionListener> mTransitionListeners = null;
public float mTransitionPosition = 0.0f;
public TransitionState mTransitionState = TransitionState.UNDEFINED;
public boolean mUndergoingMotion = false;
public int mWidthMeasureMode;
/* renamed from: androidx.constraintlayout.motion.widget.MotionLayout$1 reason: invalid class name */
public class AnonymousClass1 implements Runnable {
public final /* synthetic */ View val$target;
public AnonymousClass1(View view) {
this.val$target = view;
}
@Override // java.lang.Runnable
public void run() {
this.val$target.setNestedScrollingEnabled(true);
}
}
/* renamed from: androidx.constraintlayout.motion.widget.MotionLayout$2 reason: invalid class name */
public static /* synthetic */ class AnonymousClass2 {
public static final /* synthetic */ int[] $SwitchMap$androidx$constraintlayout$motion$widget$MotionLayout$TransitionState;
static {
TransitionState.values();
int[] iArr = new int[4];
$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) {
}
}
}
public class DecelerateInterpolator extends MotionInterpolator {
public float currentP = 0.0f;
public float initalV = 0.0f;
public float maxA;
public DecelerateInterpolator() {
}
public void config(float f, float f2, float f3) {
this.initalV = f;
this.currentP = f2;
this.maxA = f3;
}
@Override // androidx.constraintlayout.motion.widget.MotionInterpolator, android.animation.TimeInterpolator
public float getInterpolation(float f) {
float f2 = this.initalV;
if (f2 > 0.0f) {
float f3 = this.maxA;
if (f2 / f3 < f) {
f = f2 / f3;
}
MotionLayout.this.mLastVelocity = f2 - (f3 * f);
return ((f2 * f) - (((f3 * f) * f) / 2.0f)) + this.currentP;
}
float f4 = this.maxA;
if ((-f2) / f4 < f) {
f = (-f2) / f4;
}
MotionLayout.this.mLastVelocity = (f4 * f) + f2;
return (((f4 * f) * f) / 2.0f) + (f2 * f) + this.currentP;
}
@Override // androidx.constraintlayout.motion.widget.MotionInterpolator
public float getVelocity() {
return MotionLayout.this.mLastVelocity;
}
}
public class DevModeDraw {
private static final int DEBUG_PATH_TICKS_PER_MS = 16;
public final int DIAMOND_SIZE = 10;
public final int GRAPH_COLOR = -13391360;
public final int KEYFRAME_COLOR = -2067046;
public final int RED_COLOR = -21965;
public final int SHADOW_COLOR = 1996488704;
public Rect mBounds = new Rect();
public DashPathEffect mDashPathEffect;
public Paint mFillPaint;
public int mKeyFrameCount;
public float[] mKeyFramePoints;
public Paint mPaint;
public Paint mPaintGraph;
public Paint mPaintKeyframes;
public Path mPath;
public int[] mPathMode;
public float[] mPoints;
public boolean mPresentationMode = false;
private float[] mRectangle;
public int mShadowTranslate = 1;
public Paint mTextPaint;
public DevModeDraw() {
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;
}
}
private void drawBasicPath(Canvas canvas) {
canvas.drawLines(this.mPoints, this.mPaint);
}
private void drawPathAsConfigured(Canvas canvas) {
boolean z2 = false;
boolean z3 = false;
for (int i = 0; i < this.mKeyFrameCount; i++) {
int[] iArr = this.mPathMode;
if (iArr[i] == 1) {
z2 = true;
}
if (iArr[i] == 2) {
z3 = true;
}
}
if (z2) {
drawPathRelative(canvas);
}
if (z3) {
drawPathCartesian(canvas);
}
}
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;
StringBuilder L = a.L("");
L.append(((float) ((int) (((double) ((min2 * 100.0f) / Math.abs(f5 - f3))) + 0.5d))) / 100.0f);
String sb = L.toString();
getTextBounds(sb, this.mTextPaint);
canvas.drawText(sb, ((min2 / 2.0f) - ((float) (this.mBounds.width() / 2))) + min, f2 - 20.0f, this.mTextPaint);
canvas.drawLine(f, f2, Math.min(f3, f5), f2, this.mPaintGraph);
StringBuilder L2 = a.L("");
L2.append(((float) ((int) (((double) ((max2 * 100.0f) / Math.abs(f6 - f4))) + 0.5d))) / 100.0f);
String sb2 = L2.toString();
getTextBounds(sb2, this.mTextPaint);
canvas.drawText(sb2, f + 5.0f, max - ((max2 / 2.0f) - ((float) (this.mBounds.height() / 2))), this.mTextPaint);
canvas.drawLine(f, f2, f, Math.max(f4, f6), 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 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((double) (f3 - f5), (double) (f4 - f6));
float f7 = f5 - f3;
float f8 = f6 - f4;
float f9 = (((f2 - f4) * f8) + ((f - f3) * f7)) / (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((double) (f10 - f), (double) (f11 - f2));
StringBuilder L = a.L("");
L.append(((float) ((int) ((hypot2 * 100.0f) / hypot))) / 100.0f);
String sb = L.toString();
getTextBounds(sb, this.mTextPaint);
canvas.drawTextOnPath(sb, path, (hypot2 / 2.0f) - ((float) (this.mBounds.width() / 2)), -20.0f, this.mTextPaint);
canvas.drawLine(f, f2, f10, f11, this.mPaintGraph);
}
private void drawPathScreenTicks(Canvas canvas, float f, float f2, int i, int i2) {
StringBuilder L = a.L("");
L.append(((float) ((int) (((double) (((f - ((float) (i / 2))) * 100.0f) / ((float) (MotionLayout.this.getWidth() - i)))) + 0.5d))) / 100.0f);
String sb = L.toString();
getTextBounds(sb, this.mTextPaint);
canvas.drawText(sb, ((f / 2.0f) - ((float) (this.mBounds.width() / 2))) + 0.0f, f2 - 20.0f, this.mTextPaint);
canvas.drawLine(f, f2, Math.min(0.0f, 1.0f), f2, this.mPaintGraph);
StringBuilder L2 = a.L("");
L2.append(((float) ((int) (((double) (((f2 - ((float) (i2 / 2))) * 100.0f) / ((float) (MotionLayout.this.getHeight() - i2)))) + 0.5d))) / 100.0f);
String sb2 = L2.toString();
getTextBounds(sb2, this.mTextPaint);
canvas.drawText(sb2, f + 5.0f, 0.0f - ((f2 / 2.0f) - ((float) (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(((float) i) / ((float) 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(-65536);
canvas.drawPath(this.mPath, this.mPaint);
}
private void drawTicks(Canvas canvas, int i, int i2, MotionController motionController) {
int i3;
int i4;
float f;
float f2;
int i5;
View view = motionController.mView;
if (view != null) {
i4 = view.getWidth();
i3 = motionController.mView.getHeight();
} else {
i4 = 0;
i3 = 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[] iArr = this.mPathMode;
if (iArr[i8] == 1) {
drawPathRelativeTicks(canvas, f3 - 0.0f, f4 - 0.0f);
} else if (iArr[i8] == 2) {
drawPathCartesianTicks(canvas, f3 - 0.0f, f4 - 0.0f);
} else if (iArr[i8] == 3) {
i5 = 3;
f2 = f4;
f = f3;
drawPathScreenTicks(canvas, f3 - 0.0f, f4 - 0.0f, i4, i3);
canvas.drawPath(this.mPath, this.mFillPaint);
}
f2 = f4;
f = f3;
i5 = 3;
canvas.drawPath(this.mPath, this.mFillPaint);
} else {
f2 = f4;
f = f3;
i5 = 3;
}
if (i == 2) {
drawPathRelativeTicks(canvas, f - 0.0f, f2 - 0.0f);
}
if (i == i5) {
drawPathCartesianTicks(canvas, f - 0.0f, f2 - 0.0f);
}
if (i == 6) {
drawPathScreenTicks(canvas, f - 0.0f, f2 - 0.0f, i4, i3);
}
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);
}
public void draw(Canvas canvas, HashMap<View, MotionController> hashMap, int i, int i2) {
if (!(hashMap == null || hashMap.size() == 0)) {
canvas.save();
if (!MotionLayout.this.isInEditMode() && (i2 & 1) == 2) {
String str = MotionLayout.this.getContext().getResources().getResourceName(MotionLayout.access$000(MotionLayout.this)) + ":" + MotionLayout.this.getProgress();
canvas.drawText(str, 10.0f, (float) (MotionLayout.this.getHeight() - 30), this.mTextPaint);
canvas.drawText(str, 11.0f, (float) (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((float) i4, (float) 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((float) (-i5), (float) (-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);
}
public void getTextBounds(String str, Paint paint) {
paint.getTextBounds(str, 0, str.length(), this.mBounds);
}
}
public class Model {
public ConstraintSet mEnd = null;
public int mEndId;
public ConstraintWidgetContainer mLayoutEnd = new ConstraintWidgetContainer();
public ConstraintWidgetContainer mLayoutStart = new ConstraintWidgetContainer();
public ConstraintSet mStart = null;
public int mStartId;
public Model() {
}
private void debugLayout(String str, ConstraintWidgetContainer constraintWidgetContainer) {
StringBuilder P = a.P(str, " ");
P.append(Debug.getName((View) constraintWidgetContainer.getCompanionWidget()));
String sb = P.toString();
Log.v("MotionLayout", sb + " ========= " + constraintWidgetContainer);
int size = constraintWidgetContainer.getChildren().size();
for (int i = 0; i < size; i++) {
String str2 = sb + "[" + i + "] ";
ConstraintWidget constraintWidget = constraintWidgetContainer.getChildren().get(i);
StringBuilder L = a.L("");
String str3 = "_";
L.append(constraintWidget.mTop.mTarget != null ? "T" : str3);
StringBuilder L2 = a.L(L.toString());
L2.append(constraintWidget.mBottom.mTarget != null ? "B" : str3);
StringBuilder L3 = a.L(L2.toString());
L3.append(constraintWidget.mLeft.mTarget != null ? "L" : str3);
StringBuilder L4 = a.L(L3.toString());
if (constraintWidget.mRight.mTarget != null) {
str3 = "R";
}
L4.append(str3);
String sb2 = L4.toString();
View view = (View) constraintWidget.getCompanionWidget();
String name = Debug.getName(view);
if (view instanceof TextView) {
StringBuilder P2 = a.P(name, "(");
P2.append((Object) ((TextView) view).getText());
P2.append(")");
name = P2.toString();
}
Log.v("MotionLayout", str2 + " " + name + " " + constraintWidget + " " + sb2);
}
Log.v("MotionLayout", sb + " done. ");
}
private void debugLayoutParam(String str, ConstraintLayout.LayoutParams layoutParams) {
StringBuilder L = a.L(" ");
L.append(layoutParams.startToStart != -1 ? "SS" : "__");
StringBuilder L2 = a.L(L.toString());
String str2 = "|__";
L2.append(layoutParams.startToEnd != -1 ? "|SE" : str2);
StringBuilder L3 = a.L(L2.toString());
L3.append(layoutParams.endToStart != -1 ? "|ES" : str2);
StringBuilder L4 = a.L(L3.toString());
L4.append(layoutParams.endToEnd != -1 ? "|EE" : str2);
StringBuilder L5 = a.L(L4.toString());
L5.append(layoutParams.leftToLeft != -1 ? "|LL" : str2);
StringBuilder L6 = a.L(L5.toString());
L6.append(layoutParams.leftToRight != -1 ? "|LR" : str2);
StringBuilder L7 = a.L(L6.toString());
L7.append(layoutParams.rightToLeft != -1 ? "|RL" : str2);
StringBuilder L8 = a.L(L7.toString());
L8.append(layoutParams.rightToRight != -1 ? "|RR" : str2);
StringBuilder L9 = a.L(L8.toString());
L9.append(layoutParams.topToTop != -1 ? "|TT" : str2);
StringBuilder L10 = a.L(L9.toString());
L10.append(layoutParams.topToBottom != -1 ? "|TB" : str2);
StringBuilder L11 = a.L(L10.toString());
L11.append(layoutParams.bottomToTop != -1 ? "|BT" : str2);
StringBuilder L12 = a.L(L11.toString());
if (layoutParams.bottomToBottom != -1) {
str2 = "|BB";
}
L12.append(str2);
String sb = L12.toString();
Log.v("MotionLayout", str + sb);
}
private void debugWidget(String str, ConstraintWidget constraintWidget) {
String str2;
String str3;
String str4;
StringBuilder L = a.L(" ");
String str5 = "B";
String str6 = "__";
if (constraintWidget.mTop.mTarget != null) {
StringBuilder L2 = a.L("T");
L2.append(constraintWidget.mTop.mTarget.mType == ConstraintAnchor.Type.TOP ? "T" : str5);
str2 = L2.toString();
} else {
str2 = str6;
}
L.append(str2);
StringBuilder L3 = a.L(L.toString());
if (constraintWidget.mBottom.mTarget != null) {
StringBuilder L4 = a.L(str5);
if (constraintWidget.mBottom.mTarget.mType == ConstraintAnchor.Type.TOP) {
str5 = "T";
}
L4.append(str5);
str3 = L4.toString();
} else {
str3 = str6;
}
L3.append(str3);
StringBuilder L5 = a.L(L3.toString());
String str7 = "R";
if (constraintWidget.mLeft.mTarget != null) {
StringBuilder L6 = a.L("L");
L6.append(constraintWidget.mLeft.mTarget.mType == ConstraintAnchor.Type.LEFT ? "L" : str7);
str4 = L6.toString();
} else {
str4 = str6;
}
L5.append(str4);
StringBuilder L7 = a.L(L5.toString());
if (constraintWidget.mRight.mTarget != null) {
StringBuilder L8 = a.L(str7);
if (constraintWidget.mRight.mTarget.mType == ConstraintAnchor.Type.LEFT) {
str7 = "L";
}
L8.append(str7);
str6 = L8.toString();
}
L7.append(str6);
String sb = L7.toString();
Log.v("MotionLayout", str + sb + " --- " + constraintWidget);
}
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 Barrier) {
((Barrier) view).validateParams();
}
}
layoutParams.resolveLayoutDirection(MotionLayout.this.getLayoutDirection());
MotionLayout.access$800(MotionLayout.this, 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) {
Helper helper = (Helper) next3;
((ConstraintHelper) next3.getCompanionWidget()).updatePreLayout(constraintWidgetContainer, helper, sparseArray);
((VirtualLayout) helper).captureWidgets();
}
}
}
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", 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", Debug.getLocation() + "no widget for " + Debug.getName(childAt2) + " (" + childAt2.getClass().getName() + ")");
}
}
}
}
}
public void copy(ConstraintWidgetContainer constraintWidgetContainer, ConstraintWidgetContainer constraintWidgetContainer2) {
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();
ConstraintWidget barrier = next instanceof androidx.constraintlayout.solver.widgets.Barrier ? new androidx.constraintlayout.solver.widgets.Barrier() : next instanceof Guideline ? new Guideline() : next instanceof Flow ? new Flow() : next instanceof Helper ? new HelperWidget() : new ConstraintWidget();
constraintWidgetContainer2.add(barrier);
hashMap.put(next, barrier);
}
Iterator<ConstraintWidget> it2 = children.iterator();
while (it2.hasNext()) {
ConstraintWidget next2 = it2.next();
hashMap.get(next2).copy(next2, hashMap);
}
}
public 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;
}
public 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.access$200(MotionLayout.this).getMeasurer());
this.mLayoutEnd.setMeasurer(MotionLayout.access$300(MotionLayout.this).getMeasurer());
this.mLayoutStart.removeAllChildren();
this.mLayoutEnd.removeAllChildren();
copy(MotionLayout.access$400(MotionLayout.this), this.mLayoutStart);
copy(MotionLayout.access$500(MotionLayout.this), this.mLayoutEnd);
if (((double) 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.access$600(MotionLayout.this));
this.mLayoutStart.updateHierarchy();
this.mLayoutEnd.setRtl(MotionLayout.access$700(MotionLayout.this));
this.mLayoutEnd.updateHierarchy();
ViewGroup.LayoutParams layoutParams = MotionLayout.this.getLayoutParams();
if (layoutParams != null) {
if (layoutParams.width == -2) {
ConstraintWidgetContainer constraintWidgetContainer2 = this.mLayoutStart;
ConstraintWidget.DimensionBehaviour dimensionBehaviour = ConstraintWidget.DimensionBehaviour.WRAP_CONTENT;
constraintWidgetContainer2.setHorizontalDimensionBehaviour(dimensionBehaviour);
this.mLayoutEnd.setHorizontalDimensionBehaviour(dimensionBehaviour);
}
if (layoutParams.height == -2) {
ConstraintWidgetContainer constraintWidgetContainer3 = this.mLayoutStart;
ConstraintWidget.DimensionBehaviour dimensionBehaviour2 = ConstraintWidget.DimensionBehaviour.WRAP_CONTENT;
constraintWidgetContainer3.setVerticalDimensionBehaviour(dimensionBehaviour2);
this.mLayoutEnd.setVerticalDimensionBehaviour(dimensionBehaviour2);
}
}
}
public boolean isNotConfiguredWith(int i, int i2) {
return (i == this.mStartId && i2 == this.mEndId) ? false : true;
}
public void measure(int i, int i2) {
int mode = View.MeasureSpec.getMode(i);
int mode2 = View.MeasureSpec.getMode(i2);
MotionLayout motionLayout = MotionLayout.this;
motionLayout.mWidthMeasureMode = mode;
motionLayout.mHeightMeasureMode = mode2;
int optimizationLevel = motionLayout.getOptimizationLevel();
MotionLayout motionLayout2 = MotionLayout.this;
if (motionLayout2.mCurrentState == motionLayout2.getStartState()) {
MotionLayout.access$1200(MotionLayout.this, this.mLayoutEnd, optimizationLevel, i, i2);
if (this.mStart != null) {
MotionLayout.access$1300(MotionLayout.this, this.mLayoutStart, optimizationLevel, i, i2);
}
} else {
if (this.mStart != null) {
MotionLayout.access$1400(MotionLayout.this, this.mLayoutStart, optimizationLevel, i, i2);
}
MotionLayout.access$1500(MotionLayout.this, this.mLayoutEnd, optimizationLevel, i, i2);
}
boolean z2 = false;
if (((MotionLayout.this.getParent() instanceof MotionLayout) && mode == 1073741824 && mode2 == 1073741824) ? false : true) {
MotionLayout motionLayout3 = MotionLayout.this;
motionLayout3.mWidthMeasureMode = mode;
motionLayout3.mHeightMeasureMode = mode2;
if (motionLayout3.mCurrentState == motionLayout3.getStartState()) {
MotionLayout.access$1600(MotionLayout.this, this.mLayoutEnd, optimizationLevel, i, i2);
if (this.mStart != null) {
MotionLayout.access$1700(MotionLayout.this, this.mLayoutStart, optimizationLevel, i, i2);
}
} else {
if (this.mStart != null) {
MotionLayout.access$1800(MotionLayout.this, this.mLayoutStart, optimizationLevel, i, i2);
}
MotionLayout.access$1900(MotionLayout.this, 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 motionLayout4 = MotionLayout.this;
motionLayout4.mMeasureDuringTransition = (motionLayout4.mStartWrapWidth == motionLayout4.mEndWrapWidth && motionLayout4.mStartWrapHeight == motionLayout4.mEndWrapHeight) ? false : true;
}
MotionLayout motionLayout5 = MotionLayout.this;
int i3 = motionLayout5.mStartWrapWidth;
int i4 = motionLayout5.mStartWrapHeight;
int i5 = motionLayout5.mWidthMeasureMode;
if (i5 == Integer.MIN_VALUE || i5 == 0) {
i3 = (int) ((motionLayout5.mPostInterpolationPosition * ((float) (motionLayout5.mEndWrapWidth - i3))) + ((float) i3));
}
int i6 = motionLayout5.mHeightMeasureMode;
if (i6 == Integer.MIN_VALUE || i6 == 0) {
i4 = (int) ((motionLayout5.mPostInterpolationPosition * ((float) (motionLayout5.mEndWrapHeight - i4))) + ((float) i4));
}
boolean z3 = this.mLayoutStart.isWidthMeasuredTooSmall() || this.mLayoutEnd.isWidthMeasuredTooSmall();
if (this.mLayoutStart.isHeightMeasuredTooSmall() || this.mLayoutEnd.isHeightMeasuredTooSmall()) {
z2 = true;
}
MotionLayout.access$2000(MotionLayout.this, i, i2, i3, i4, z3, z2);
}
public void reEvaluateState() {
measure(MotionLayout.access$900(MotionLayout.this), MotionLayout.access$1000(MotionLayout.this));
MotionLayout.access$1100(MotionLayout.this);
}
public void setMeasuredId(int i, int i2) {
this.mStartId = i;
this.mEndId = i2;
}
}
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();
}
public static class MyTracker implements MotionTracker {
/* renamed from: me reason: collision with root package name */
private static MyTracker f17me = new MyTracker();
public VelocityTracker tracker;
private MyTracker() {
}
public static MyTracker obtain() {
f17me.tracker = VelocityTracker.obtain();
return f17me;
}
@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 clear() {
VelocityTracker velocityTracker = this.tracker;
if (velocityTracker != null) {
velocityTracker.clear();
}
}
@Override // androidx.constraintlayout.motion.widget.MotionLayout.MotionTracker
public void computeCurrentVelocity(int i) {
VelocityTracker velocityTracker = this.tracker;
if (velocityTracker != null) {
velocityTracker.computeCurrentVelocity(i);
}
}
@Override // androidx.constraintlayout.motion.widget.MotionLayout.MotionTracker
public void computeCurrentVelocity(int i, float f) {
VelocityTracker velocityTracker = this.tracker;
if (velocityTracker != null) {
velocityTracker.computeCurrentVelocity(i, f);
}
}
@Override // androidx.constraintlayout.motion.widget.MotionLayout.MotionTracker
public float getXVelocity() {
VelocityTracker velocityTracker = this.tracker;
if (velocityTracker != null) {
return velocityTracker.getXVelocity();
}
return 0.0f;
}
@Override // androidx.constraintlayout.motion.widget.MotionLayout.MotionTracker
public float getXVelocity(int i) {
VelocityTracker velocityTracker = this.tracker;
if (velocityTracker != null) {
return velocityTracker.getXVelocity(i);
}
return 0.0f;
}
@Override // androidx.constraintlayout.motion.widget.MotionLayout.MotionTracker
public float getYVelocity() {
VelocityTracker velocityTracker = this.tracker;
if (velocityTracker != null) {
return velocityTracker.getYVelocity();
}
return 0.0f;
}
@Override // androidx.constraintlayout.motion.widget.MotionLayout.MotionTracker
public float getYVelocity(int i) {
if (this.tracker != null) {
return getYVelocity(i);
}
return 0.0f;
}
@Override // androidx.constraintlayout.motion.widget.MotionLayout.MotionTracker
public void recycle() {
VelocityTracker velocityTracker = this.tracker;
if (velocityTracker != null) {
velocityTracker.recycle();
this.tracker = null;
}
}
}
public class StateCache {
public final String KeyEndState = "motion.EndState";
public final String KeyProgress = "motion.progress";
public final String KeyStartState = "motion.StartState";
public final String KeyVelocity = "motion.velocity";
public int endState = -1;
public float mProgress = Float.NaN;
public float mVelocity = Float.NaN;
public int startState = -1;
public StateCache() {
}
public 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)) {
MotionLayout.this.setProgress(this.mProgress, this.mVelocity);
this.mProgress = Float.NaN;
this.mVelocity = Float.NaN;
this.startState = -1;
this.endState = -1;
} else if (!Float.isNaN(this.mProgress)) {
MotionLayout.this.setProgress(this.mProgress);
}
}
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 recordState() {
this.endState = MotionLayout.access$000(MotionLayout.this);
this.startState = MotionLayout.access$100(MotionLayout.this);
this.mVelocity = MotionLayout.this.getVelocity();
this.mProgress = MotionLayout.this.getProgress();
}
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 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 setVelocity(float f) {
this.mVelocity = f;
}
}
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 z2, float f);
}
public enum TransitionState {
UNDEFINED,
SETUP,
MOVING,
FINISHED
}
public MotionLayout(@NonNull Context context) {
super(context);
init(null);
}
public MotionLayout(@NonNull Context context, @Nullable AttributeSet attributeSet) {
super(context, attributeSet);
init(attributeSet);
}
public MotionLayout(@NonNull Context context, @Nullable AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
init(attributeSet);
}
public static /* synthetic */ int access$000(MotionLayout motionLayout) {
return motionLayout.mEndState;
}
public static /* synthetic */ int access$100(MotionLayout motionLayout) {
return motionLayout.mBeginState;
}
public static /* synthetic */ int access$1000(MotionLayout motionLayout) {
return motionLayout.mLastHeightMeasureSpec;
}
public static /* synthetic */ void access$1100(MotionLayout motionLayout) {
motionLayout.setupMotionViews();
}
public static /* synthetic */ void access$1200(MotionLayout motionLayout, ConstraintWidgetContainer constraintWidgetContainer, int i, int i2, int i3) {
motionLayout.resolveSystem(constraintWidgetContainer, i, i2, i3);
}
public static /* synthetic */ void access$1300(MotionLayout motionLayout, ConstraintWidgetContainer constraintWidgetContainer, int i, int i2, int i3) {
motionLayout.resolveSystem(constraintWidgetContainer, i, i2, i3);
}
public static /* synthetic */ void access$1400(MotionLayout motionLayout, ConstraintWidgetContainer constraintWidgetContainer, int i, int i2, int i3) {
motionLayout.resolveSystem(constraintWidgetContainer, i, i2, i3);
}
public static /* synthetic */ void access$1500(MotionLayout motionLayout, ConstraintWidgetContainer constraintWidgetContainer, int i, int i2, int i3) {
motionLayout.resolveSystem(constraintWidgetContainer, i, i2, i3);
}
public static /* synthetic */ void access$1600(MotionLayout motionLayout, ConstraintWidgetContainer constraintWidgetContainer, int i, int i2, int i3) {
motionLayout.resolveSystem(constraintWidgetContainer, i, i2, i3);
}
public static /* synthetic */ void access$1700(MotionLayout motionLayout, ConstraintWidgetContainer constraintWidgetContainer, int i, int i2, int i3) {
motionLayout.resolveSystem(constraintWidgetContainer, i, i2, i3);
}
public static /* synthetic */ void access$1800(MotionLayout motionLayout, ConstraintWidgetContainer constraintWidgetContainer, int i, int i2, int i3) {
motionLayout.resolveSystem(constraintWidgetContainer, i, i2, i3);
}
public static /* synthetic */ void access$1900(MotionLayout motionLayout, ConstraintWidgetContainer constraintWidgetContainer, int i, int i2, int i3) {
motionLayout.resolveSystem(constraintWidgetContainer, i, i2, i3);
}
public static /* synthetic */ ConstraintWidgetContainer access$200(MotionLayout motionLayout) {
return motionLayout.mLayoutWidget;
}
public static /* synthetic */ void access$2000(MotionLayout motionLayout, int i, int i2, int i3, int i4, boolean z2, boolean z3) {
motionLayout.resolveMeasuredDimension(i, i2, i3, i4, z2, z3);
}
public static /* synthetic */ ConstraintWidgetContainer access$300(MotionLayout motionLayout) {
return motionLayout.mLayoutWidget;
}
public static /* synthetic */ ConstraintWidgetContainer access$400(MotionLayout motionLayout) {
return motionLayout.mLayoutWidget;
}
public static /* synthetic */ ConstraintWidgetContainer access$500(MotionLayout motionLayout) {
return motionLayout.mLayoutWidget;
}
public static /* synthetic */ boolean access$600(MotionLayout motionLayout) {
return motionLayout.isRtl();
}
public static /* synthetic */ boolean access$700(MotionLayout motionLayout) {
return motionLayout.isRtl();
}
public static /* synthetic */ void access$800(MotionLayout motionLayout, boolean z2, View view, ConstraintWidget constraintWidget, ConstraintLayout.LayoutParams layoutParams, SparseArray sparseArray) {
motionLayout.applyConstraintsFromLayoutParams(z2, view, constraintWidget, layoutParams, sparseArray);
}
public static /* synthetic */ int access$900(MotionLayout motionLayout) {
return motionLayout.mLastWidthMeasureSpec;
}
private void checkStructure() {
MotionScene motionScene = this.mScene;
if (motionScene == null) {
Log.e("MotionLayout", "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("MotionLayout", "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("MotionLayout", "CHECK: two transitions with the same start and end " + name + "->" + name2);
}
if (sparseIntArray2.get(endConstraintSetId) == startConstraintSetId) {
Log.e("MotionLayout", "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("MotionLayout", " no such constraintSetStart " + name);
}
if (this.mScene.getConstraintSet(endConstraintSetId) == null) {
Log.e("MotionLayout", " 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 id2 = childAt.getId();
if (id2 == -1) {
StringBuilder Q = a.Q("CHECK: ", name, " ALL VIEWS SHOULD HAVE ID's ");
Q.append(childAt.getClass().getName());
Q.append(" does not!");
Log.w("MotionLayout", Q.toString());
}
if (constraintSet.getConstraint(id2) == null) {
StringBuilder Q2 = a.Q("CHECK: ", name, " NO CONSTRAINTS for ");
Q2.append(Debug.getName(childAt));
Log.w("MotionLayout", Q2.toString());
}
}
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("MotionLayout", "CHECK: " + name + " NO View matches id " + name2);
}
if (constraintSet.getHeight(i4) == -1) {
Log.w("MotionLayout", "CHECK: " + name + "(" + name2 + ") no LAYOUT_HEIGHT");
}
if (constraintSet.getWidth(i4) == -1) {
Log.w("MotionLayout", "CHECK: " + name + "(" + name2 + ") no LAYOUT_HEIGHT");
}
}
}
private void checkStructure(MotionScene.Transition transition) {
StringBuilder L = a.L("CHECK: transition = ");
L.append(transition.debugString(getContext()));
Log.v("MotionLayout", L.toString());
Log.v("MotionLayout", "CHECK: transition.setDuration = " + transition.getDuration());
if (transition.getStartConstraintSetId() == transition.getEndConstraintSetId()) {
Log.e("MotionLayout", "CHECK: start and end constraint set should not be the same!");
}
}
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);
}
}
}
private void debugPos() {
for (int i = 0; i < getChildCount(); i++) {
View childAt = getChildAt(i);
StringBuilder L = a.L(" ");
L.append(Debug.getLocation());
L.append(" ");
L.append(Debug.getName(this));
L.append(" ");
L.append(Debug.getName(getContext(), this.mCurrentState));
L.append(" ");
L.append(Debug.getName(childAt));
L.append(childAt.getLeft());
L.append(" ");
L.append(childAt.getTop());
Log.v("MotionLayout", L.toString());
}
}
private void evaluateLayout() {
boolean z2;
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;
}
int i = (signum > 0.0f ? 1 : (signum == 0.0f ? 0 : -1));
if ((i <= 0 || f < this.mTransitionGoalPosition) && (signum > 0.0f || f > this.mTransitionGoalPosition)) {
z2 = false;
} else {
f = this.mTransitionGoalPosition;
z2 = true;
}
if (interpolator != null && !z2) {
f = this.mTemporalInterpolator ? interpolator.getInterpolation(((float) (nanoTime - this.mAnimationStartTime)) * 1.0E-9f) : interpolator.getInterpolation(f);
}
if ((i > 0 && f >= this.mTransitionGoalPosition) || (signum <= 0.0f && f <= this.mTransitionGoalPosition)) {
f = this.mTransitionGoalPosition;
}
this.mPostInterpolationPosition = f;
int childCount = getChildCount();
long nanoTime2 = getNanoTime();
for (int i2 = 0; i2 < childCount; i2++) {
View childAt = getChildAt(i2);
MotionController motionController = this.mFrameArrayList.get(childAt);
if (motionController != null) {
motionController.interpolate(childAt, f, nanoTime2, this.mKeyCache);
}
}
if (this.mMeasureDuringTransition) {
requestLayout();
}
}
private void fireTransitionChange() {
ArrayList<TransitionListener> arrayList;
if ((this.mTransitionListener != null || ((arrayList = this.mTransitionListeners) != null && !arrayList.isEmpty())) && this.mListenerPosition != this.mTransitionPosition) {
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;
}
}
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);
}
}
}
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(((float) view.getLeft()) + f, ((float) view.getTop()) + f2, viewGroup.getChildAt(i), motionEvent)) {
return true;
}
}
}
this.mBoundsCheck.set(((float) view.getLeft()) + f, ((float) view.getTop()) + f2, f + ((float) view.getRight()), f2 + ((float) 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;
}
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 z2 = 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) {
z2 = obtainStyledAttributes.getBoolean(index, z2);
} 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("MotionLayout", "WARNING NO app:layoutDescription tag");
}
if (!z2) {
this.mScene = null;
}
}
if (this.mDebugPath != 0) {
checkStructure();
}
if (this.mCurrentState == -1 && (motionScene = this.mScene) != null) {
this.mCurrentState = motionScene.getStartId();
this.mBeginState = this.mScene.getStartId();
this.mEndState = this.mScene.getEndId();
}
}
private void processTransitionCompleted() {
ArrayList<TransitionListener> arrayList;
if (this.mTransitionListener != null || ((arrayList = this.mTransitionListeners) != null && !arrayList.isEmpty())) {
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();
}
}
private void setupMotionViews() {
int childCount = getChildCount();
this.mModel.build();
boolean z2 = true;
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 z3 = ((double) staggered) < 0.0d;
float abs = Math.abs(staggered);
float f = -3.4028235E38f;
float f2 = Float.MAX_VALUE;
int i4 = 0;
float f3 = Float.MAX_VALUE;
float f4 = -3.4028235E38f;
while (true) {
if (i4 >= childCount) {
z2 = false;
break;
}
MotionController motionController3 = this.mFrameArrayList.get(getChildAt(i4));
if (!Float.isNaN(motionController3.mMotionStagger)) {
break;
}
float finalX = motionController3.getFinalX();
float finalY = motionController3.getFinalY();
float f5 = z3 ? finalY - finalX : finalY + finalX;
f3 = Math.min(f3, f5);
f4 = Math.max(f4, f5);
i4++;
}
if (z2) {
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 (z3) {
motionController5.mStaggerOffset = abs - (((f - motionController5.mMotionStagger) / (f - f2)) * abs);
} else {
motionController5.mStaggerOffset = abs - (((motionController5.mMotionStagger - f2) * abs) / (f - f2));
}
}
i++;
}
return;
}
while (i < childCount) {
MotionController motionController6 = this.mFrameArrayList.get(getChildAt(i));
float finalX2 = motionController6.getFinalX();
float finalY2 = motionController6.getFinalY();
float f6 = z3 ? finalY2 - finalX2 : finalY2 + finalX2;
motionController6.mStaggerScale = 1.0f / (1.0f - abs);
motionController6.mStaggerOffset = abs - (((f6 - f3) * abs) / (f4 - f3));
i++;
}
}
}
private static boolean willJump(float f, float f2, float f3) {
if (f > 0.0f) {
float f4 = f / f3;
return ((f * f4) - (((f3 * f4) * f4) / 2.0f)) + f2 > 1.0f;
}
float f5 = (-f) / f3;
return ((((f3 * f5) * f5) / 2.0f) + (f * f5)) + f2 < 0.0f;
}
public void addTransitionListener(TransitionListener transitionListener) {
if (this.mTransitionListeners == null) {
this.mTransitionListeners = new ArrayList<>();
}
this.mTransitionListeners.add(transitionListener);
}
public void animateTo(float f) {
MotionScene motionScene = this.mScene;
if (motionScene != null) {
float f2 = this.mTransitionLastPosition;
float f3 = this.mTransitionPosition;
if (f2 != f3 && this.mTransitionInstantly) {
this.mTransitionLastPosition = f3;
}
float f4 = this.mTransitionLastPosition;
if (f4 != f) {
this.mTemporalInterpolator = false;
this.mTransitionGoalPosition = f;
this.mTransitionDuration = ((float) motionScene.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();
}
}
}
public void disableAutoTransition(boolean z2) {
MotionScene motionScene = this.mScene;
if (motionScene != null) {
motionScene.disableAutoTransition(z2);
}
}
@Override // androidx.constraintlayout.widget.ConstraintLayout, android.view.ViewGroup, android.view.View
public void dispatchDraw(Canvas canvas) {
evaluate(false);
super.dispatchDraw(canvas);
if (this.mScene != null) {
if ((this.mDebugPath & 1) == 1 && !isInEditMode()) {
this.mFrames++;
long nanoTime = getNanoTime();
long j = this.mLastDrawTime;
if (j != -1) {
long j2 = nanoTime - j;
if (j2 > 200000000) {
this.mLastFps = ((float) ((int) ((((float) this.mFrames) / (((float) j2) * 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 L = a.L(this.mLastFps + " fps " + Debug.getState(this, this.mBeginState) + " -> ");
L.append(Debug.getState(this, this.mEndState));
L.append(" (progress: ");
L.append(((float) ((int) (getProgress() * 1000.0f))) / 10.0f);
L.append(" ) state=");
int i = this.mCurrentState;
L.append(i == -1 ? "undefined" : Debug.getState(this, i));
String sb = L.toString();
paint.setColor(-16777216);
canvas.drawText(sb, 11.0f, (float) (getHeight() - 29), paint);
paint.setColor(-7864184);
canvas.drawText(sb, 10.0f, (float) (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);
}
}
}
public void enableTransition(int i, boolean z2) {
MotionScene.Transition transition = getTransition(i);
if (z2) {
transition.setEnable(true);
return;
}
MotionScene motionScene = this.mScene;
if (transition == motionScene.mCurrentTransition) {
Iterator<MotionScene.Transition> it = motionScene.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);
}
public void evaluate(boolean z2) {
float f;
boolean z3;
int i;
int i2;
float f2;
if (this.mTransitionLastTime == -1) {
this.mTransitionLastTime = getNanoTime();
}
float f3 = this.mTransitionLastPosition;
if (f3 > 0.0f && f3 < 1.0f) {
this.mCurrentState = -1;
}
boolean z4 = true;
boolean z5 = false;
if (this.mKeepAnimating || (this.mInTransition && (z2 || this.mTransitionGoalPosition != f3))) {
float signum = Math.signum(this.mTransitionGoalPosition - f3);
long nanoTime = getNanoTime();
Interpolator interpolator = this.mInterpolator;
if (!(interpolator instanceof MotionInterpolator)) {
f = ((((float) (nanoTime - this.mTransitionLastTime)) * signum) * 1.0E-9f) / this.mTransitionDuration;
this.mLastVelocity = f;
} else {
f = 0.0f;
}
float f4 = this.mTransitionLastPosition + f;
if (this.mTransitionInstantly) {
f4 = this.mTransitionGoalPosition;
}
int i3 = (signum > 0.0f ? 1 : (signum == 0.0f ? 0 : -1));
if ((i3 <= 0 || f4 < this.mTransitionGoalPosition) && (signum > 0.0f || f4 > this.mTransitionGoalPosition)) {
z3 = false;
} else {
f4 = this.mTransitionGoalPosition;
this.mInTransition = false;
z3 = true;
}
this.mTransitionLastPosition = f4;
this.mTransitionPosition = f4;
this.mTransitionLastTime = nanoTime;
if (interpolator != null && !z3) {
if (this.mTemporalInterpolator) {
f2 = interpolator.getInterpolation(((float) (nanoTime - this.mAnimationStartTime)) * 1.0E-9f);
this.mTransitionLastPosition = f2;
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 <= 1.0E-5f) {
this.mInTransition = false;
}
if (velocity > 0.0f && f2 >= 1.0f) {
this.mTransitionLastPosition = 1.0f;
this.mInTransition = false;
f2 = 1.0f;
}
if (velocity < 0.0f && f2 <= 0.0f) {
this.mTransitionLastPosition = 0.0f;
this.mInTransition = false;
f4 = 0.0f;
}
}
} else {
f2 = interpolator.getInterpolation(f4);
Interpolator interpolator3 = this.mInterpolator;
if (interpolator3 instanceof MotionInterpolator) {
this.mLastVelocity = ((MotionInterpolator) interpolator3).getVelocity();
} else {
this.mLastVelocity = ((interpolator3.getInterpolation(f4 + f) - f2) * signum) / f;
}
}
f4 = f2;
}
if (Math.abs(this.mLastVelocity) > 1.0E-5f) {
setState(TransitionState.MOVING);
}
if ((i3 > 0 && f4 >= this.mTransitionGoalPosition) || (signum <= 0.0f && f4 <= this.mTransitionGoalPosition)) {
f4 = this.mTransitionGoalPosition;
this.mInTransition = false;
}
int i4 = (f4 > 1.0f ? 1 : (f4 == 1.0f ? 0 : -1));
if (i4 >= 0 || f4 <= 0.0f) {
this.mInTransition = false;
setState(TransitionState.FINISHED);
}
int childCount = getChildCount();
this.mKeepAnimating = false;
long nanoTime2 = getNanoTime();
this.mPostInterpolationPosition = f4;
for (int i5 = 0; i5 < childCount; i5++) {
View childAt = getChildAt(i5);
MotionController motionController = this.mFrameArrayList.get(childAt);
if (motionController != null) {
this.mKeepAnimating = motionController.interpolate(childAt, f4, nanoTime2, this.mKeyCache) | this.mKeepAnimating;
}
}
boolean z6 = (i3 > 0 && f4 >= this.mTransitionGoalPosition) || (signum <= 0.0f && f4 <= this.mTransitionGoalPosition);
if (!this.mKeepAnimating && !this.mInTransition && z6) {
setState(TransitionState.FINISHED);
}
if (this.mMeasureDuringTransition) {
requestLayout();
}
this.mKeepAnimating = (!z6) | this.mKeepAnimating;
if (!(f4 > 0.0f || (i2 = this.mBeginState) == -1 || this.mCurrentState == i2)) {
this.mCurrentState = i2;
this.mScene.getConstraintSet(i2).applyCustomAttributes(this);
setState(TransitionState.FINISHED);
z5 = true;
}
if (((double) f4) >= 1.0d && this.mCurrentState != (i = this.mEndState)) {
this.mCurrentState = i;
this.mScene.getConstraintSet(i).applyCustomAttributes(this);
setState(TransitionState.FINISHED);
z5 = true;
}
if (this.mKeepAnimating || this.mInTransition) {
invalidate();
} else if ((i3 > 0 && i4 == 0) || (signum < 0.0f && f4 == 0.0f)) {
setState(TransitionState.FINISHED);
}
if ((!this.mKeepAnimating && this.mInTransition && i3 > 0 && i4 == 0) || (signum < 0.0f && f4 == 0.0f)) {
onNewStateAttachHandlers();
}
}
float f5 = this.mTransitionLastPosition;
if (f5 >= 1.0f) {
int i6 = this.mCurrentState;
int i7 = this.mEndState;
if (i6 == i7) {
z4 = z5;
}
this.mCurrentState = i7;
} else {
if (f5 <= 0.0f) {
int i8 = this.mCurrentState;
int i9 = this.mBeginState;
if (i8 == i9) {
z4 = z5;
}
this.mCurrentState = i9;
}
this.mNeedsFireTransitionCompleted |= z5;
if (z5 && !this.mInLayout) {
requestLayout();
}
this.mTransitionPosition = this.mTransitionLastPosition;
}
z5 = z4;
this.mNeedsFireTransitionCompleted |= z5;
requestLayout();
this.mTransitionPosition = this.mTransitionLastPosition;
}
public 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()) {
ArrayList<Integer> arrayList2 = this.mTransitionCompleted;
i = arrayList2.get(arrayList2.size() - 1).intValue();
} else {
i = -1;
}
int i2 = this.mCurrentState;
if (!(i == i2 || i2 == -1)) {
this.mTransitionCompleted.add(Integer.valueOf(i2));
}
}
processTransitionCompleted();
}
public void fireTrigger(int i, boolean z2, float f) {
TransitionListener transitionListener = this.mTransitionListener;
if (transitionListener != null) {
transitionListener.onTransitionTrigger(this, i, z2, f);
}
ArrayList<TransitionListener> arrayList = this.mTransitionListeners;
if (arrayList != null) {
Iterator<TransitionListener> it = arrayList.iterator();
while (it.hasNext()) {
it.next().onTransitionTrigger(this, i, z2, f);
}
}
}
public void getAnchorDpDt(int i, float f, float f2, float f3, float[] fArr) {
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 y2 = viewById.getY();
this.lastPos = f;
this.lastY = y2;
return;
}
a.h0("WARNING could not find view id ", viewById == null ? a.k("", i) : viewById.getContext().getResources().getResourceName(i), "MotionLayout");
}
public ConstraintSet getConstraintSet(int i) {
MotionScene motionScene = this.mScene;
if (motionScene == null) {
return null;
}
return motionScene.getConstraintSet(i);
}
public int[] getConstraintSetIds() {
MotionScene motionScene = this.mScene;
if (motionScene == null) {
return null;
}
return motionScene.getConstraintSetIds();
}
public String getConstraintSetNames(int i) {
MotionScene motionScene = this.mScene;
if (motionScene == null) {
return null;
}
return motionScene.lookUpConstraintName(i);
}
public int getCurrentState() {
return this.mCurrentState;
}
public void getDebugMode(boolean z2) {
this.mDebugPath = z2 ? 2 : 1;
invalidate();
}
public ArrayList<MotionScene.Transition> getDefinedTransitions() {
MotionScene motionScene = this.mScene;
if (motionScene == null) {
return null;
}
return motionScene.getDefinedTransitions();
}
public DesignTool getDesignTool() {
if (this.mDesignTool == null) {
this.mDesignTool = new DesignTool(this);
}
return this.mDesignTool;
}
public int getEndState() {
return this.mEndState;
}
public long getNanoTime() {
return System.nanoTime();
}
public float getProgress() {
return this.mTransitionLastPosition;
}
public int getStartState() {
return this.mBeginState;
}
public float getTargetPosition() {
return this.mTransitionGoalPosition;
}
public MotionScene.Transition getTransition(int i) {
return this.mScene.getTransitionById(i);
}
public Bundle getTransitionState() {
if (this.mStateCache == null) {
this.mStateCache = new StateCache();
}
this.mStateCache.recordState();
return this.mStateCache.getTransitionState();
}
public long getTransitionTimeMs() {
MotionScene motionScene = this.mScene;
if (motionScene != null) {
this.mTransitionDuration = ((float) motionScene.getDuration()) / 1000.0f;
}
return (long) (this.mTransitionDuration * 1000.0f);
}
public float getVelocity() {
return this.mLastVelocity;
}
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 + 1.0E-5f);
float interpolation2 = this.mInterpolator.getInterpolation(this.mTransitionLastPosition);
f4 = (((interpolation - interpolation2) / 1.0E-5f) * signum) / this.mTransitionDuration;
f3 = interpolation2;
} 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;
}
}
@Override // android.view.View
public boolean isAttachedToWindow() {
return super.isAttachedToWindow();
}
public boolean isInteractionEnabled() {
return this.mInteractionEnabled;
}
@Override // androidx.constraintlayout.widget.ConstraintLayout
public void loadLayoutDescription(int i) {
if (i != 0) {
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);
}
} else {
this.mScene = null;
}
}
public int lookUpConstraintId(String str) {
MotionScene motionScene = this.mScene;
if (motionScene == null) {
return 0;
}
return motionScene.lookUpConstraintId(str);
}
public MotionTracker obtainVelocityTracker() {
return MyTracker.obtain();
}
@Override // android.view.ViewGroup, android.view.View
public void onAttachedToWindow() {
MotionScene.Transition transition;
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();
return;
}
MotionScene motionScene2 = this.mScene;
if (motionScene2 != null && (transition = motionScene2.mCurrentTransition) != null && transition.getAutoTransition() == 4) {
transitionToEnd();
setState(TransitionState.SETUP);
setState(TransitionState.MOVING);
}
}
@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);
}
View view2 = this.mRegionView;
if (view2 != null) {
this.mBoundsCheck.set((float) view2.getLeft(), (float) this.mRegionView.getTop(), (float) this.mRegionView.getRight(), (float) 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 // androidx.constraintlayout.widget.ConstraintLayout, android.view.ViewGroup, android.view.View
public void onLayout(boolean z2, int i, int i2, int i3, int i4) {
this.mInLayout = true;
boolean z3 = false;
try {
if (this.mScene == null) {
super.onLayout(z2, 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;
this.mInLayout = false;
} finally {
this.mInLayout = z3;
}
}
@Override // androidx.constraintlayout.widget.ConstraintLayout, android.view.View
public void onMeasure(int i, int i2) {
if (this.mScene == null) {
super.onMeasure(i, i2);
return;
}
boolean z2 = false;
boolean z3 = (this.mLastWidthMeasureSpec == i && this.mLastHeightMeasureSpec == i2) ? false : true;
if (this.mNeedsFireTransitionCompleted) {
this.mNeedsFireTransitionCompleted = false;
onNewStateAttachHandlers();
processTransitionCompleted();
z3 = true;
}
if (this.mDirtyHierarchy) {
z3 = true;
}
this.mLastWidthMeasureSpec = i;
this.mLastHeightMeasureSpec = i2;
int startId = this.mScene.getStartId();
int endId = this.mScene.getEndId();
if ((z3 || 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 {
z2 = true;
}
if (this.mMeasureDuringTransition || z2) {
int paddingBottom = getPaddingBottom() + getPaddingTop();
int width = this.mLayoutWidget.getWidth() + getPaddingRight() + getPaddingLeft();
int height = this.mLayoutWidget.getHeight() + paddingBottom;
int i3 = this.mWidthMeasureMode;
if (i3 == Integer.MIN_VALUE || i3 == 0) {
int i4 = this.mStartWrapWidth;
width = (int) ((this.mPostInterpolationPosition * ((float) (this.mEndWrapWidth - i4))) + ((float) i4));
requestLayout();
}
int i5 = this.mHeightMeasureMode;
if (i5 == Integer.MIN_VALUE || i5 == 0) {
int i6 = this.mStartWrapHeight;
height = (int) ((this.mPostInterpolationPosition * ((float) (this.mEndWrapHeight - i6))) + ((float) i6));
requestLayout();
}
setMeasuredDimension(width, height);
}
evaluateLayout();
}
@Override // android.view.ViewGroup, android.view.ViewParent, androidx.core.view.NestedScrollingParent
public boolean onNestedFling(View view, float f, float f2, boolean z2) {
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 onNestedPreScroll(View view, int i, int i2, int[] iArr, int i3) {
MotionScene.Transition transition;
TouchResponse touchResponse;
int touchRegionId;
MotionScene motionScene = this.mScene;
if (motionScene != null && (transition = motionScene.mCurrentTransition) != null && transition.isEnabled()) {
MotionScene.Transition transition2 = this.mScene.mCurrentTransition;
if (transition2 == null || !transition2.isEnabled() || (touchResponse = transition2.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 (!(transition2.getTouchResponse() == null || (this.mScene.mCurrentTransition.getTouchResponse().getFlags() & 1) == 0)) {
float progressDirection = this.mScene.getProgressDirection((float) i, (float) i2);
float f2 = this.mTransitionLastPosition;
if ((f2 <= 0.0f && progressDirection < 0.0f) || (f2 >= 1.0f && progressDirection > 0.0f)) {
view.setNestedScrollingEnabled(false);
view.post(new AnonymousClass1(view));
return;
}
}
float f3 = this.mTransitionPosition;
long nanoTime = getNanoTime();
float f4 = (float) i;
this.mScrollTargetDX = f4;
float f5 = (float) i2;
this.mScrollTargetDY = f5;
this.mScrollTargetDT = (float) (((double) (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) {
this.mUndergoingMotion = true;
}
}
}
}
@Override // androidx.core.view.NestedScrollingParent2
public void onNestedScroll(View view, int i, int i2, int i3, int i4, int i5) {
}
@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 onNestedScrollAccepted(View view, View view2, int i, int i2) {
}
public void onNewStateAttachHandlers() {
MotionScene motionScene = this.mScene;
if (motionScene != null) {
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();
}
}
}
@Override // android.view.View
public void onRtlPropertiesChanged(int i) {
MotionScene motionScene = this.mScene;
if (motionScene != null) {
motionScene.setRtl(isRtl());
}
}
@Override // androidx.core.view.NestedScrollingParent2
public boolean onStartNestedScroll(View view, View view2, int i, int i2) {
MotionScene.Transition transition;
MotionScene motionScene = this.mScene;
return (motionScene == null || (transition = motionScene.mCurrentTransition) == null || transition.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) {
float f = this.mScrollTargetDX;
float f2 = this.mScrollTargetDT;
motionScene.processScrollUp(f / f2, this.mScrollTargetDY / f2);
}
}
@Override // android.view.View
public boolean onTouchEvent(MotionEvent motionEvent) {
MotionScene motionScene = this.mScene;
if (motionScene == null || !this.mInteractionEnabled || !motionScene.supportTouch()) {
return super.onTouchEvent(motionEvent);
}
MotionScene.Transition transition = this.mScene.mCurrentTransition;
if (transition != null && !transition.isEnabled()) {
return super.onTouchEvent(motionEvent);
}
this.mScene.processTouchEvent(motionEvent, getCurrentState(), this);
return true;
}
@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);
}
}
@Override // androidx.constraintlayout.widget.ConstraintLayout
public void parseLayoutDescription(int i) {
this.mConstraintLayoutSpec = null;
}
@Deprecated
public void rebuildMotion() {
Log.e("MotionLayout", "This method is deprecated. Please call rebuildScene() instead.");
rebuildScene();
}
public void rebuildScene() {
this.mModel.reEvaluateState();
invalidate();
}
public boolean removeTransitionListener(TransitionListener transitionListener) {
ArrayList<TransitionListener> arrayList = this.mTransitionListeners;
if (arrayList == null) {
return false;
}
return arrayList.remove(transitionListener);
}
@Override // androidx.constraintlayout.widget.ConstraintLayout, android.view.ViewParent, android.view.View
public void requestLayout() {
MotionScene motionScene;
MotionScene.Transition transition;
if (this.mMeasureDuringTransition || this.mCurrentState != -1 || (motionScene = this.mScene) == null || (transition = motionScene.mCurrentTransition) == null || transition.getLayoutDuringTransition() != 0) {
super.requestLayout();
}
}
public void setDebugMode(int i) {
this.mDebugPath = i;
invalidate();
}
public void setInteractionEnabled(boolean z2) {
this.mInteractionEnabled = z2;
}
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 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 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 setProgress(float f) {
int i = (f > 0.0f ? 1 : (f == 0.0f ? 0 : -1));
if (i < 0 || f > 1.0f) {
Log.w("MotionLayout", "Warning! Progress is defined for values between 0.0 and 1.0 inclusive");
}
if (!isAttachedToWindow()) {
if (this.mStateCache == null) {
this.mStateCache = new StateCache();
}
this.mStateCache.setProgress(f);
return;
}
if (i <= 0) {
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) {
this.mTransitionInstantly = true;
this.mTransitionGoalPosition = f;
this.mTransitionPosition = f;
this.mTransitionLastTime = -1;
this.mAnimationStartTime = -1;
this.mInterpolator = null;
this.mInTransition = true;
invalidate();
}
}
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);
}
public void setScene(MotionScene motionScene) {
this.mScene = motionScene;
motionScene.setRtl(isRtl());
rebuildScene();
}
@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;
ConstraintLayoutStates constraintLayoutStates = this.mConstraintLayoutSpec;
if (constraintLayoutStates != null) {
constraintLayoutStates.updateConstraints(i, (float) i2, (float) i3);
return;
}
MotionScene motionScene = this.mScene;
if (motionScene != null) {
motionScene.getConstraintSet(i).applyTo(this);
}
}
public void setState(TransitionState transitionState) {
TransitionState transitionState2 = TransitionState.FINISHED;
if (transitionState != transitionState2 || this.mCurrentState != -1) {
TransitionState transitionState3 = this.mTransitionState;
this.mTransitionState = transitionState;
TransitionState transitionState4 = TransitionState.MOVING;
if (transitionState3 == transitionState4 && transitionState == transitionState4) {
fireTransitionChange();
}
int ordinal = transitionState3.ordinal();
if (ordinal == 0 || ordinal == 1) {
if (transitionState == transitionState4) {
fireTransitionChange();
}
if (transitionState == transitionState2) {
fireTransitionCompleted();
}
} else if (ordinal == 2 && transitionState == transitionState2) {
fireTransitionCompleted();
}
}
}
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;
}
float f = Float.NaN;
int i2 = this.mCurrentState;
float f2 = 0.0f;
if (i2 == this.mBeginState) {
f = 0.0f;
} else if (i2 == this.mEndState) {
f = 1.0f;
}
this.mScene.setTransition(transition);
this.mModel.initFrom(this.mLayoutWidget, this.mScene.getConstraintSet(this.mBeginState), this.mScene.getConstraintSet(this.mEndState));
rebuildScene();
if (!Float.isNaN(f)) {
f2 = f;
}
this.mTransitionLastPosition = f2;
if (Float.isNaN(f)) {
Log.v("MotionLayout", Debug.getLocation() + " transitionToStart ");
transitionToStart();
return;
}
setProgress(f);
}
}
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(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) ? -1 : getNanoTime();
int startId = this.mScene.getStartId();
int endId = this.mScene.getEndId();
if (startId != this.mBeginState || endId != this.mEndState) {
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();
}
}
public void setTransitionDuration(int i) {
MotionScene motionScene = this.mScene;
if (motionScene == null) {
Log.e("MotionLayout", "MotionScene not defined");
} else {
motionScene.setDuration(i);
}
}
public void setTransitionListener(TransitionListener transitionListener) {
this.mTransitionListener = transitionListener;
}
public void setTransitionState(Bundle bundle) {
if (this.mStateCache == null) {
this.mStateCache = new StateCache();
}
this.mStateCache.setTransitionState(bundle);
if (isAttachedToWindow()) {
this.mStateCache.apply();
}
}
@Override // android.view.View, java.lang.Object
public String toString() {
Context context = getContext();
return Debug.getName(context, this.mBeginState) + "->" + Debug.getName(context, this.mEndState) + " (pos:" + this.mTransitionLastPosition + " Dpos/Dt:" + this.mLastVelocity;
}
public void touchAnimateTo(int i, float f, float f2) {
if (this.mScene != null && this.mTransitionLastPosition != f) {
this.mTemporalInterpolator = true;
this.mAnimationStartTime = getNanoTime();
float duration = ((float) 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();
}
}
public void transitionToEnd() {
animateTo(1.0f);
}
public void transitionToStart() {
animateTo(0.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) {
StateSet stateSet;
int convertToConstraintSet;
MotionScene motionScene = this.mScene;
if (!(motionScene == null || (stateSet = motionScene.mStateSet) == null || (convertToConstraintSet = stateSet.convertToConstraintSet(this.mCurrentState, i, (float) i2, (float) i3)) == -1)) {
i = convertToConstraintSet;
}
int i4 = this.mCurrentState;
if (i4 != i) {
if (this.mBeginState == i) {
animateTo(0.0f);
} else if (this.mEndState == i) {
animateTo(1.0f);
} else {
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 = ((float) 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 updateState() {
this.mModel.initFrom(this.mLayoutWidget, this.mScene.getConstraintSet(this.mBeginState), this.mScene.getConstraintSet(this.mEndState));
rebuildScene();
}
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);
}
}
}