3165 lines
131 KiB
Java
3165 lines
131 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.Matrix;
|
|
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.SparseBooleanArray;
|
|
import android.util.SparseIntArray;
|
|
import android.view.Display;
|
|
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.core.motion.utils.KeyCache;
|
|
import androidx.constraintlayout.core.widgets.Barrier;
|
|
import androidx.constraintlayout.core.widgets.ConstraintAnchor;
|
|
import androidx.constraintlayout.core.widgets.ConstraintWidget;
|
|
import androidx.constraintlayout.core.widgets.ConstraintWidgetContainer;
|
|
import androidx.constraintlayout.core.widgets.Flow;
|
|
import androidx.constraintlayout.core.widgets.Guideline;
|
|
import androidx.constraintlayout.core.widgets.Helper;
|
|
import androidx.constraintlayout.core.widgets.HelperWidget;
|
|
import androidx.constraintlayout.core.widgets.Placeholder;
|
|
import androidx.constraintlayout.core.widgets.VirtualLayout;
|
|
import androidx.constraintlayout.core.widgets.analyzer.BasicMeasure;
|
|
import androidx.constraintlayout.motion.utils.StopLogic;
|
|
import androidx.constraintlayout.motion.utils.ViewState;
|
|
import androidx.constraintlayout.motion.widget.MotionScene;
|
|
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 java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.concurrent.CopyOnWriteArrayList;
|
|
|
|
/* 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_NEVER_TO_END = 7;
|
|
public static final int TOUCH_UP_NEVER_TO_START = 6;
|
|
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 ArrayList<MotionHelper> mDecoratorsHelpers;
|
|
private boolean mDelayedApply;
|
|
private DesignTool mDesignTool;
|
|
DevModeDraw mDevModeDraw;
|
|
private int mEndState;
|
|
int mEndWrapHeight;
|
|
int mEndWrapWidth;
|
|
HashMap<View, MotionController> mFrameArrayList;
|
|
private int mFrames;
|
|
int mHeightMeasureMode;
|
|
private boolean mInLayout;
|
|
private boolean mInRotation;
|
|
boolean mInTransition;
|
|
boolean mIndirectTransition;
|
|
private boolean mInteractionEnabled;
|
|
Interpolator mInterpolator;
|
|
private Matrix mInverseMatrix;
|
|
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 Runnable mOnComplete;
|
|
private ArrayList<MotionHelper> mOnHideHelpers;
|
|
private ArrayList<MotionHelper> mOnShowHelpers;
|
|
float mPostInterpolationPosition;
|
|
HashMap<View, ViewState> mPreRotate;
|
|
private int mPreRotateHeight;
|
|
private int mPreRotateWidth;
|
|
private int mPreviouseRotation;
|
|
Interpolator mProgressInterpolator;
|
|
private View mRegionView;
|
|
int mRotatMode;
|
|
MotionScene mScene;
|
|
private int[] mScheduledTransitionTo;
|
|
int mScheduledTransitions;
|
|
float mScrollTargetDT;
|
|
float mScrollTargetDX;
|
|
float mScrollTargetDY;
|
|
long mScrollTargetTime;
|
|
int mStartWrapHeight;
|
|
int mStartWrapWidth;
|
|
private StateCache mStateCache;
|
|
private StopLogic mStopLogic;
|
|
Rect mTempRect;
|
|
private boolean mTemporalInterpolator;
|
|
ArrayList<Integer> mTransitionCompleted;
|
|
private float mTransitionDuration;
|
|
float mTransitionGoalPosition;
|
|
private boolean mTransitionInstantly;
|
|
float mTransitionLastPosition;
|
|
private long mTransitionLastTime;
|
|
private TransitionListener mTransitionListener;
|
|
private CopyOnWriteArrayList<TransitionListener> mTransitionListeners;
|
|
float mTransitionPosition;
|
|
TransitionState mTransitionState;
|
|
boolean mUndergoingMotion;
|
|
int mWidthMeasureMode;
|
|
|
|
protected interface MotionTracker {
|
|
void addMovement(MotionEvent event);
|
|
|
|
void clear();
|
|
|
|
void computeCurrentVelocity(int units);
|
|
|
|
void computeCurrentVelocity(int units, float maxVelocity);
|
|
|
|
float getXVelocity();
|
|
|
|
float getXVelocity(int id);
|
|
|
|
float getYVelocity();
|
|
|
|
float getYVelocity(int id);
|
|
|
|
void recycle();
|
|
}
|
|
|
|
public interface TransitionListener {
|
|
void onTransitionChange(MotionLayout motionLayout, int startId, int endId, float progress);
|
|
|
|
void onTransitionCompleted(MotionLayout motionLayout, int currentId);
|
|
|
|
void onTransitionStarted(MotionLayout motionLayout, int startId, int endId);
|
|
|
|
void onTransitionTrigger(MotionLayout motionLayout, int triggerId, boolean positive, float progress);
|
|
}
|
|
|
|
enum TransitionState {
|
|
UNDEFINED,
|
|
SETUP,
|
|
MOVING,
|
|
FINISHED
|
|
}
|
|
|
|
private static boolean willJump(float velocity, float position, float maxAcceleration) {
|
|
if (velocity > 0.0f) {
|
|
float f = velocity / maxAcceleration;
|
|
return position + ((velocity * f) - (((maxAcceleration * f) * f) / 2.0f)) > 1.0f;
|
|
}
|
|
float f2 = (-velocity) / maxAcceleration;
|
|
return position + ((velocity * f2) + (((maxAcceleration * f2) * f2) / 2.0f)) < 0.0f;
|
|
}
|
|
|
|
public int getCurrentState() {
|
|
return this.mCurrentState;
|
|
}
|
|
|
|
public int getEndState() {
|
|
return this.mEndState;
|
|
}
|
|
|
|
public float getProgress() {
|
|
return this.mTransitionLastPosition;
|
|
}
|
|
|
|
public MotionScene getScene() {
|
|
return this.mScene;
|
|
}
|
|
|
|
public int getStartState() {
|
|
return this.mBeginState;
|
|
}
|
|
|
|
public float getTargetPosition() {
|
|
return this.mTransitionGoalPosition;
|
|
}
|
|
|
|
public float getVelocity() {
|
|
return this.mLastVelocity;
|
|
}
|
|
|
|
public boolean isDelayedApplicationOfInitialState() {
|
|
return this.mDelayedApply;
|
|
}
|
|
|
|
public boolean isInRotation() {
|
|
return this.mInRotation;
|
|
}
|
|
|
|
public boolean isInteractionEnabled() {
|
|
return this.mInteractionEnabled;
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.ViewParent, androidx.core.view.NestedScrollingParent
|
|
public boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed) {
|
|
return false;
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.ViewParent, androidx.core.view.NestedScrollingParent
|
|
public boolean onNestedPreFling(View target, float velocityX, float velocityY) {
|
|
return false;
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingParent2
|
|
public void onNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type) {
|
|
}
|
|
|
|
public void setDelayedApplicationOfInitialState(boolean delayedApply) {
|
|
this.mDelayedApply = delayedApply;
|
|
}
|
|
|
|
public void setInteractionEnabled(boolean enabled) {
|
|
this.mInteractionEnabled = enabled;
|
|
}
|
|
|
|
public void setTransitionListener(TransitionListener listener) {
|
|
this.mTransitionListener = listener;
|
|
}
|
|
|
|
MotionController getMotionController(int mTouchAnchorId) {
|
|
return this.mFrameArrayList.get(findViewById(mTouchAnchorId));
|
|
}
|
|
|
|
public MotionLayout(Context context) {
|
|
super(context);
|
|
this.mProgressInterpolator = null;
|
|
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.mDecoratorsHelpers = 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.mOnComplete = null;
|
|
this.mScheduledTransitionTo = null;
|
|
this.mScheduledTransitions = 0;
|
|
this.mInRotation = false;
|
|
this.mRotatMode = 0;
|
|
this.mPreRotate = new HashMap<>();
|
|
this.mTempRect = new Rect();
|
|
this.mDelayedApply = false;
|
|
this.mTransitionState = TransitionState.UNDEFINED;
|
|
this.mModel = new Model();
|
|
this.mNeedsFireTransitionCompleted = false;
|
|
this.mBoundsCheck = new RectF();
|
|
this.mRegionView = null;
|
|
this.mInverseMatrix = null;
|
|
this.mTransitionCompleted = new ArrayList<>();
|
|
init(null);
|
|
}
|
|
|
|
public MotionLayout(Context context, AttributeSet attrs) {
|
|
super(context, attrs);
|
|
this.mProgressInterpolator = null;
|
|
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.mDecoratorsHelpers = 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.mOnComplete = null;
|
|
this.mScheduledTransitionTo = null;
|
|
this.mScheduledTransitions = 0;
|
|
this.mInRotation = false;
|
|
this.mRotatMode = 0;
|
|
this.mPreRotate = new HashMap<>();
|
|
this.mTempRect = new Rect();
|
|
this.mDelayedApply = false;
|
|
this.mTransitionState = TransitionState.UNDEFINED;
|
|
this.mModel = new Model();
|
|
this.mNeedsFireTransitionCompleted = false;
|
|
this.mBoundsCheck = new RectF();
|
|
this.mRegionView = null;
|
|
this.mInverseMatrix = null;
|
|
this.mTransitionCompleted = new ArrayList<>();
|
|
init(attrs);
|
|
}
|
|
|
|
public MotionLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
|
super(context, attrs, defStyleAttr);
|
|
this.mProgressInterpolator = null;
|
|
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.mDecoratorsHelpers = 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.mOnComplete = null;
|
|
this.mScheduledTransitionTo = null;
|
|
this.mScheduledTransitions = 0;
|
|
this.mInRotation = false;
|
|
this.mRotatMode = 0;
|
|
this.mPreRotate = new HashMap<>();
|
|
this.mTempRect = new Rect();
|
|
this.mDelayedApply = false;
|
|
this.mTransitionState = TransitionState.UNDEFINED;
|
|
this.mModel = new Model();
|
|
this.mNeedsFireTransitionCompleted = false;
|
|
this.mBoundsCheck = new RectF();
|
|
this.mRegionView = null;
|
|
this.mInverseMatrix = null;
|
|
this.mTransitionCompleted = new ArrayList<>();
|
|
init(attrs);
|
|
}
|
|
|
|
protected long getNanoTime() {
|
|
return System.nanoTime();
|
|
}
|
|
|
|
protected MotionTracker obtainVelocityTracker() {
|
|
return MyTracker.obtain();
|
|
}
|
|
|
|
public void enableTransition(int transitionID, boolean enable) {
|
|
MotionScene.Transition transition = getTransition(transitionID);
|
|
if (enable) {
|
|
transition.setEnabled(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.setEnabled(false);
|
|
}
|
|
|
|
void setState(TransitionState newState) {
|
|
if (newState == TransitionState.FINISHED && this.mCurrentState == -1) {
|
|
return;
|
|
}
|
|
TransitionState transitionState = this.mTransitionState;
|
|
this.mTransitionState = newState;
|
|
if (transitionState == TransitionState.MOVING && newState == TransitionState.MOVING) {
|
|
fireTransitionChange();
|
|
}
|
|
int i = AnonymousClass5.$SwitchMap$androidx$constraintlayout$motion$widget$MotionLayout$TransitionState[transitionState.ordinal()];
|
|
if (i == 1 || i == 2) {
|
|
if (newState == TransitionState.MOVING) {
|
|
fireTransitionChange();
|
|
}
|
|
if (newState == TransitionState.FINISHED) {
|
|
fireTransitionCompleted();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
if (i == 3 && newState == TransitionState.FINISHED) {
|
|
fireTransitionCompleted();
|
|
}
|
|
}
|
|
|
|
/* renamed from: androidx.constraintlayout.motion.widget.MotionLayout$5, reason: invalid class name */
|
|
static /* synthetic */ class AnonymousClass5 {
|
|
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) {
|
|
}
|
|
}
|
|
}
|
|
|
|
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() {
|
|
VelocityTracker velocityTracker = this.tracker;
|
|
if (velocityTracker != null) {
|
|
velocityTracker.recycle();
|
|
this.tracker = null;
|
|
}
|
|
}
|
|
|
|
@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 addMovement(MotionEvent event) {
|
|
VelocityTracker velocityTracker = this.tracker;
|
|
if (velocityTracker != null) {
|
|
velocityTracker.addMovement(event);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.MotionLayout.MotionTracker
|
|
public void computeCurrentVelocity(int units) {
|
|
VelocityTracker velocityTracker = this.tracker;
|
|
if (velocityTracker != null) {
|
|
velocityTracker.computeCurrentVelocity(units);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.MotionLayout.MotionTracker
|
|
public void computeCurrentVelocity(int units, float maxVelocity) {
|
|
VelocityTracker velocityTracker = this.tracker;
|
|
if (velocityTracker != null) {
|
|
velocityTracker.computeCurrentVelocity(units, maxVelocity);
|
|
}
|
|
}
|
|
|
|
@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 getYVelocity() {
|
|
VelocityTracker velocityTracker = this.tracker;
|
|
if (velocityTracker != null) {
|
|
return velocityTracker.getYVelocity();
|
|
}
|
|
return 0.0f;
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.MotionLayout.MotionTracker
|
|
public float getXVelocity(int id) {
|
|
VelocityTracker velocityTracker = this.tracker;
|
|
if (velocityTracker != null) {
|
|
return velocityTracker.getXVelocity(id);
|
|
}
|
|
return 0.0f;
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.MotionLayout.MotionTracker
|
|
public float getYVelocity(int id) {
|
|
if (this.tracker != null) {
|
|
return getYVelocity(id);
|
|
}
|
|
return 0.0f;
|
|
}
|
|
}
|
|
|
|
void setStartState(int beginId) {
|
|
if (isAttachedToWindow()) {
|
|
this.mCurrentState = beginId;
|
|
return;
|
|
}
|
|
if (this.mStateCache == null) {
|
|
this.mStateCache = new StateCache();
|
|
}
|
|
this.mStateCache.setStartState(beginId);
|
|
this.mStateCache.setEndState(beginId);
|
|
}
|
|
|
|
public void setTransition(int beginId, int endId) {
|
|
if (!isAttachedToWindow()) {
|
|
if (this.mStateCache == null) {
|
|
this.mStateCache = new StateCache();
|
|
}
|
|
this.mStateCache.setStartState(beginId);
|
|
this.mStateCache.setEndState(endId);
|
|
return;
|
|
}
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene != null) {
|
|
this.mBeginState = beginId;
|
|
this.mEndState = endId;
|
|
motionScene.setTransition(beginId, endId);
|
|
this.mModel.initFrom(this.mLayoutWidget, this.mScene.getConstraintSet(beginId), this.mScene.getConstraintSet(endId));
|
|
rebuildScene();
|
|
this.mTransitionLastPosition = 0.0f;
|
|
transitionToStart();
|
|
}
|
|
}
|
|
|
|
public void setTransition(int transitionId) {
|
|
if (this.mScene != null) {
|
|
MotionScene.Transition transition = getTransition(transitionId);
|
|
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 i = this.mCurrentState;
|
|
float f = i == this.mBeginState ? 0.0f : i == 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();
|
|
if (this.mTransitionLastPosition != f) {
|
|
if (f == 0.0f) {
|
|
endTrigger(true);
|
|
this.mScene.getConstraintSet(this.mBeginState).applyTo(this);
|
|
} else if (f == 1.0f) {
|
|
endTrigger(false);
|
|
this.mScene.getConstraintSet(this.mEndState).applyTo(this);
|
|
}
|
|
}
|
|
this.mTransitionLastPosition = Float.isNaN(f) ? 0.0f : f;
|
|
if (Float.isNaN(f)) {
|
|
Log.v(TAG, Debug.getLocation() + " transitionToStart ");
|
|
transitionToStart();
|
|
return;
|
|
}
|
|
setProgress(f);
|
|
}
|
|
}
|
|
|
|
protected 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 motionScene) {
|
|
if (motionScene == 0) {
|
|
this.mScene = null;
|
|
return;
|
|
}
|
|
try {
|
|
MotionScene motionScene2 = new MotionScene(getContext(), this, motionScene);
|
|
this.mScene = motionScene2;
|
|
if (this.mCurrentState == -1) {
|
|
this.mCurrentState = motionScene2.getStartId();
|
|
this.mBeginState = this.mScene.getStartId();
|
|
this.mEndState = this.mScene.getEndId();
|
|
}
|
|
if (!isAttachedToWindow()) {
|
|
this.mScene = null;
|
|
return;
|
|
}
|
|
try {
|
|
Display display = getDisplay();
|
|
this.mPreviouseRotation = display == null ? 0 : display.getRotation();
|
|
MotionScene motionScene3 = this.mScene;
|
|
if (motionScene3 != null) {
|
|
ConstraintSet constraintSet = motionScene3.getConstraintSet(this.mCurrentState);
|
|
this.mScene.readFallback(this);
|
|
ArrayList<MotionHelper> arrayList = this.mDecoratorsHelpers;
|
|
if (arrayList != null) {
|
|
Iterator<MotionHelper> it = arrayList.iterator();
|
|
while (it.hasNext()) {
|
|
it.next().onFinishedMotionScene(this);
|
|
}
|
|
}
|
|
if (constraintSet != null) {
|
|
constraintSet.applyTo(this);
|
|
}
|
|
this.mBeginState = this.mCurrentState;
|
|
}
|
|
onNewStateAttachHandlers();
|
|
StateCache stateCache = this.mStateCache;
|
|
if (stateCache != null) {
|
|
if (this.mDelayedApply) {
|
|
post(new Runnable() { // from class: androidx.constraintlayout.motion.widget.MotionLayout.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
MotionLayout.this.mStateCache.apply();
|
|
}
|
|
});
|
|
return;
|
|
} else {
|
|
stateCache.apply();
|
|
return;
|
|
}
|
|
}
|
|
MotionScene motionScene4 = this.mScene;
|
|
if (motionScene4 == null || motionScene4.mCurrentTransition == null || this.mScene.mCurrentTransition.getAutoTransition() != 4) {
|
|
return;
|
|
}
|
|
transitionToEnd();
|
|
setState(TransitionState.SETUP);
|
|
setState(TransitionState.MOVING);
|
|
} catch (Exception e) {
|
|
throw new IllegalArgumentException("unable to parse MotionScene file", e);
|
|
}
|
|
} catch (Exception e2) {
|
|
throw new IllegalArgumentException("unable to parse MotionScene file", e2);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public boolean isAttachedToWindow() {
|
|
return super.isAttachedToWindow();
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.widget.ConstraintLayout
|
|
public void setState(int id, int screenWidth, int screenHeight) {
|
|
setState(TransitionState.SETUP);
|
|
this.mCurrentState = id;
|
|
this.mBeginState = -1;
|
|
this.mEndState = -1;
|
|
if (this.mConstraintLayoutSpec != null) {
|
|
this.mConstraintLayoutSpec.updateConstraints(id, screenWidth, screenHeight);
|
|
return;
|
|
}
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene != null) {
|
|
motionScene.getConstraintSet(id).applyTo(this);
|
|
}
|
|
}
|
|
|
|
public void setInterpolatedProgress(float pos) {
|
|
if (this.mScene != null) {
|
|
setState(TransitionState.MOVING);
|
|
Interpolator interpolator = this.mScene.getInterpolator();
|
|
if (interpolator != null) {
|
|
setProgress(interpolator.getInterpolation(pos));
|
|
return;
|
|
}
|
|
}
|
|
setProgress(pos);
|
|
}
|
|
|
|
public void setProgress(float pos, float velocity) {
|
|
if (!isAttachedToWindow()) {
|
|
if (this.mStateCache == null) {
|
|
this.mStateCache = new StateCache();
|
|
}
|
|
this.mStateCache.setProgress(pos);
|
|
this.mStateCache.setVelocity(velocity);
|
|
return;
|
|
}
|
|
setProgress(pos);
|
|
setState(TransitionState.MOVING);
|
|
this.mLastVelocity = velocity;
|
|
if (velocity != 0.0f) {
|
|
animateTo(velocity <= 0.0f ? 0.0f : 1.0f);
|
|
} else {
|
|
if (pos == 0.0f || pos == 1.0f) {
|
|
return;
|
|
}
|
|
animateTo(pos <= 0.5f ? 0.0f : 1.0f);
|
|
}
|
|
}
|
|
|
|
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 endState) {
|
|
this.endState = endState;
|
|
}
|
|
|
|
public void setProgress(float progress) {
|
|
this.mProgress = progress;
|
|
}
|
|
|
|
public void setStartState(int startState) {
|
|
this.startState = startState;
|
|
}
|
|
|
|
public void setVelocity(float mVelocity) {
|
|
this.mVelocity = mVelocity;
|
|
}
|
|
|
|
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 pos) {
|
|
if (pos < 0.0f || pos > 1.0f) {
|
|
Log.w(TAG, "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(pos);
|
|
return;
|
|
}
|
|
if (pos <= 0.0f) {
|
|
if (this.mTransitionLastPosition == 1.0f && this.mCurrentState == this.mEndState) {
|
|
setState(TransitionState.MOVING);
|
|
}
|
|
this.mCurrentState = this.mBeginState;
|
|
if (this.mTransitionLastPosition == 0.0f) {
|
|
setState(TransitionState.FINISHED);
|
|
}
|
|
} else if (pos >= 1.0f) {
|
|
if (this.mTransitionLastPosition == 0.0f && this.mCurrentState == this.mBeginState) {
|
|
setState(TransitionState.MOVING);
|
|
}
|
|
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 = pos;
|
|
this.mTransitionPosition = pos;
|
|
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;
|
|
SparseArray sparseArray = new SparseArray();
|
|
int i = 0;
|
|
for (int i2 = 0; i2 < childCount; i2++) {
|
|
View childAt = getChildAt(i2);
|
|
sparseArray.put(childAt.getId(), this.mFrameArrayList.get(childAt));
|
|
}
|
|
int width = getWidth();
|
|
int height = getHeight();
|
|
int gatPathMotionArc = this.mScene.gatPathMotionArc();
|
|
if (gatPathMotionArc != -1) {
|
|
for (int i3 = 0; i3 < childCount; i3++) {
|
|
MotionController motionController = this.mFrameArrayList.get(getChildAt(i3));
|
|
if (motionController != null) {
|
|
motionController.setPathMotionArc(gatPathMotionArc);
|
|
}
|
|
}
|
|
}
|
|
SparseBooleanArray sparseBooleanArray = new SparseBooleanArray();
|
|
int[] iArr = new int[this.mFrameArrayList.size()];
|
|
int i4 = 0;
|
|
for (int i5 = 0; i5 < childCount; i5++) {
|
|
MotionController motionController2 = this.mFrameArrayList.get(getChildAt(i5));
|
|
if (motionController2.getAnimateRelativeTo() != -1) {
|
|
sparseBooleanArray.put(motionController2.getAnimateRelativeTo(), true);
|
|
iArr[i4] = motionController2.getAnimateRelativeTo();
|
|
i4++;
|
|
}
|
|
}
|
|
if (this.mDecoratorsHelpers != null) {
|
|
for (int i6 = 0; i6 < i4; i6++) {
|
|
MotionController motionController3 = this.mFrameArrayList.get(findViewById(iArr[i6]));
|
|
if (motionController3 != null) {
|
|
this.mScene.getKeyFrames(motionController3);
|
|
}
|
|
}
|
|
Iterator<MotionHelper> it = this.mDecoratorsHelpers.iterator();
|
|
while (it.hasNext()) {
|
|
it.next().onPreSetup(this, this.mFrameArrayList);
|
|
}
|
|
for (int i7 = 0; i7 < i4; i7++) {
|
|
MotionController motionController4 = this.mFrameArrayList.get(findViewById(iArr[i7]));
|
|
if (motionController4 != null) {
|
|
motionController4.setup(width, height, this.mTransitionDuration, getNanoTime());
|
|
}
|
|
}
|
|
} else {
|
|
for (int i8 = 0; i8 < i4; i8++) {
|
|
MotionController motionController5 = this.mFrameArrayList.get(findViewById(iArr[i8]));
|
|
if (motionController5 != null) {
|
|
this.mScene.getKeyFrames(motionController5);
|
|
motionController5.setup(width, height, this.mTransitionDuration, getNanoTime());
|
|
}
|
|
}
|
|
}
|
|
for (int i9 = 0; i9 < childCount; i9++) {
|
|
View childAt2 = getChildAt(i9);
|
|
MotionController motionController6 = this.mFrameArrayList.get(childAt2);
|
|
if (!sparseBooleanArray.get(childAt2.getId()) && motionController6 != null) {
|
|
this.mScene.getKeyFrames(motionController6);
|
|
motionController6.setup(width, height, this.mTransitionDuration, getNanoTime());
|
|
}
|
|
}
|
|
float staggered = this.mScene.getStaggered();
|
|
if (staggered != 0.0f) {
|
|
boolean z = ((double) staggered) < 0.0d;
|
|
float abs = Math.abs(staggered);
|
|
float f = -3.4028235E38f;
|
|
float f2 = Float.MAX_VALUE;
|
|
float f3 = Float.MAX_VALUE;
|
|
float f4 = -3.4028235E38f;
|
|
for (int i10 = 0; i10 < childCount; i10++) {
|
|
MotionController motionController7 = this.mFrameArrayList.get(getChildAt(i10));
|
|
if (!Float.isNaN(motionController7.mMotionStagger)) {
|
|
for (int i11 = 0; i11 < childCount; i11++) {
|
|
MotionController motionController8 = this.mFrameArrayList.get(getChildAt(i11));
|
|
if (!Float.isNaN(motionController8.mMotionStagger)) {
|
|
f2 = Math.min(f2, motionController8.mMotionStagger);
|
|
f = Math.max(f, motionController8.mMotionStagger);
|
|
}
|
|
}
|
|
while (i < childCount) {
|
|
MotionController motionController9 = this.mFrameArrayList.get(getChildAt(i));
|
|
if (!Float.isNaN(motionController9.mMotionStagger)) {
|
|
motionController9.mStaggerScale = 1.0f / (1.0f - abs);
|
|
if (z) {
|
|
motionController9.mStaggerOffset = abs - (((f - motionController9.mMotionStagger) / (f - f2)) * abs);
|
|
} else {
|
|
motionController9.mStaggerOffset = abs - (((motionController9.mMotionStagger - f2) * abs) / (f - f2));
|
|
}
|
|
}
|
|
i++;
|
|
}
|
|
return;
|
|
}
|
|
float finalX = motionController7.getFinalX();
|
|
float finalY = motionController7.getFinalY();
|
|
float f5 = z ? finalY - finalX : finalY + finalX;
|
|
f3 = Math.min(f3, f5);
|
|
f4 = Math.max(f4, f5);
|
|
}
|
|
while (i < childCount) {
|
|
MotionController motionController10 = this.mFrameArrayList.get(getChildAt(i));
|
|
float finalX2 = motionController10.getFinalX();
|
|
float finalY2 = motionController10.getFinalY();
|
|
float f6 = z ? finalY2 - finalX2 : finalY2 + finalX2;
|
|
motionController10.mStaggerScale = 1.0f / (1.0f - abs);
|
|
motionController10.mStaggerOffset = abs - (((f6 - f3) * abs) / (f4 - f3));
|
|
i++;
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:17:0x0037, code lost:
|
|
|
|
if (r10 != 7) goto L36;
|
|
*/
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public void touchAnimateTo(int r10, float r11, float r12) {
|
|
/*
|
|
Method dump skipped, instructions count: 254
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.constraintlayout.motion.widget.MotionLayout.touchAnimateTo(int, float, float):void");
|
|
}
|
|
|
|
public void touchSpringTo(float position, float currentVelocity) {
|
|
if (this.mScene == null || this.mTransitionLastPosition == position) {
|
|
return;
|
|
}
|
|
this.mTemporalInterpolator = true;
|
|
this.mAnimationStartTime = getNanoTime();
|
|
this.mTransitionDuration = this.mScene.getDuration() / 1000.0f;
|
|
this.mTransitionGoalPosition = position;
|
|
this.mInTransition = true;
|
|
this.mStopLogic.springConfig(this.mTransitionLastPosition, position, currentVelocity, this.mScene.getSpringMass(), this.mScene.getSpringStiffiness(), this.mScene.getSpringDamping(), this.mScene.getSpringStopThreshold(), this.mScene.getSpringBoundary());
|
|
int i = this.mCurrentState;
|
|
this.mTransitionGoalPosition = position;
|
|
this.mCurrentState = i;
|
|
this.mInterpolator = this.mStopLogic;
|
|
this.mTransitionInstantly = false;
|
|
this.mAnimationStartTime = getNanoTime();
|
|
invalidate();
|
|
}
|
|
|
|
class DecelerateInterpolator extends MotionInterpolator {
|
|
float maxA;
|
|
float initalV = 0.0f;
|
|
float currentP = 0.0f;
|
|
|
|
public void config(float velocity, float position, float maxAcceleration) {
|
|
this.initalV = velocity;
|
|
this.currentP = position;
|
|
this.maxA = maxAcceleration;
|
|
}
|
|
|
|
DecelerateInterpolator() {
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.MotionInterpolator, android.animation.TimeInterpolator
|
|
public float getInterpolation(float time) {
|
|
float f;
|
|
float f2;
|
|
float f3 = this.initalV;
|
|
if (f3 > 0.0f) {
|
|
float f4 = this.maxA;
|
|
if (f3 / f4 < time) {
|
|
time = f3 / f4;
|
|
}
|
|
MotionLayout.this.mLastVelocity = f3 - (f4 * time);
|
|
f = (this.initalV * time) - (((this.maxA * time) * time) / 2.0f);
|
|
f2 = this.currentP;
|
|
} else {
|
|
float f5 = this.maxA;
|
|
if ((-f3) / f5 < time) {
|
|
time = (-f3) / f5;
|
|
}
|
|
MotionLayout.this.mLastVelocity = f3 + (f5 * time);
|
|
f = (this.initalV * time) + (((this.maxA * time) * time) / 2.0f);
|
|
f2 = this.currentP;
|
|
}
|
|
return f + f2;
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.motion.widget.MotionInterpolator
|
|
public float getVelocity() {
|
|
return MotionLayout.this.mLastVelocity;
|
|
}
|
|
}
|
|
|
|
void animateTo(float position) {
|
|
if (this.mScene == null) {
|
|
return;
|
|
}
|
|
float f = this.mTransitionLastPosition;
|
|
float f2 = this.mTransitionPosition;
|
|
if (f != f2 && this.mTransitionInstantly) {
|
|
this.mTransitionLastPosition = f2;
|
|
}
|
|
float f3 = this.mTransitionLastPosition;
|
|
if (f3 == position) {
|
|
return;
|
|
}
|
|
this.mTemporalInterpolator = false;
|
|
this.mTransitionGoalPosition = position;
|
|
this.mTransitionDuration = r0.getDuration() / 1000.0f;
|
|
setProgress(this.mTransitionGoalPosition);
|
|
this.mInterpolator = null;
|
|
this.mProgressInterpolator = this.mScene.getInterpolator();
|
|
this.mTransitionInstantly = false;
|
|
this.mAnimationStartTime = getNanoTime();
|
|
this.mInTransition = true;
|
|
this.mTransitionPosition = f3;
|
|
this.mTransitionLastPosition = f3;
|
|
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);
|
|
this.mOnComplete = null;
|
|
}
|
|
|
|
public void transitionToEnd(Runnable onComplete) {
|
|
animateTo(1.0f);
|
|
this.mOnComplete = onComplete;
|
|
}
|
|
|
|
public void transitionToState(int id) {
|
|
if (!isAttachedToWindow()) {
|
|
if (this.mStateCache == null) {
|
|
this.mStateCache = new StateCache();
|
|
}
|
|
this.mStateCache.setEndState(id);
|
|
return;
|
|
}
|
|
transitionToState(id, -1, -1);
|
|
}
|
|
|
|
public void transitionToState(int id, int duration) {
|
|
if (!isAttachedToWindow()) {
|
|
if (this.mStateCache == null) {
|
|
this.mStateCache = new StateCache();
|
|
}
|
|
this.mStateCache.setEndState(id);
|
|
return;
|
|
}
|
|
transitionToState(id, -1, -1, duration);
|
|
}
|
|
|
|
public void transitionToState(int id, int screenWidth, int screenHeight) {
|
|
transitionToState(id, screenWidth, screenHeight, -1);
|
|
}
|
|
|
|
public void rotateTo(int id, int duration) {
|
|
this.mInRotation = true;
|
|
this.mPreRotateWidth = getWidth();
|
|
this.mPreRotateHeight = getHeight();
|
|
int rotation = getDisplay().getRotation();
|
|
this.mRotatMode = (rotation + 1) % 4 <= (this.mPreviouseRotation + 1) % 4 ? 2 : 1;
|
|
this.mPreviouseRotation = rotation;
|
|
int childCount = getChildCount();
|
|
for (int i = 0; i < childCount; i++) {
|
|
View childAt = getChildAt(i);
|
|
ViewState viewState = this.mPreRotate.get(childAt);
|
|
if (viewState == null) {
|
|
viewState = new ViewState();
|
|
this.mPreRotate.put(childAt, viewState);
|
|
}
|
|
viewState.getState(childAt);
|
|
}
|
|
this.mBeginState = -1;
|
|
this.mEndState = id;
|
|
this.mScene.setTransition(-1, id);
|
|
this.mModel.initFrom(this.mLayoutWidget, null, this.mScene.getConstraintSet(this.mEndState));
|
|
this.mTransitionPosition = 0.0f;
|
|
this.mTransitionLastPosition = 0.0f;
|
|
invalidate();
|
|
transitionToEnd(new Runnable() { // from class: androidx.constraintlayout.motion.widget.MotionLayout.2
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
MotionLayout.this.mInRotation = false;
|
|
}
|
|
});
|
|
if (duration > 0) {
|
|
this.mTransitionDuration = duration / 1000.0f;
|
|
}
|
|
}
|
|
|
|
public void jumpToState(int id) {
|
|
if (!isAttachedToWindow()) {
|
|
this.mCurrentState = id;
|
|
}
|
|
if (this.mBeginState == id) {
|
|
setProgress(0.0f);
|
|
} else if (this.mEndState == id) {
|
|
setProgress(1.0f);
|
|
} else {
|
|
setTransition(id, id);
|
|
}
|
|
}
|
|
|
|
public void transitionToState(int id, int screenWidth, int screenHeight, int duration) {
|
|
int convertToConstraintSet;
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene != null && motionScene.mStateSet != null && (convertToConstraintSet = this.mScene.mStateSet.convertToConstraintSet(this.mCurrentState, id, screenWidth, screenHeight)) != -1) {
|
|
id = convertToConstraintSet;
|
|
}
|
|
int i = this.mCurrentState;
|
|
if (i == id) {
|
|
return;
|
|
}
|
|
if (this.mBeginState == id) {
|
|
animateTo(0.0f);
|
|
if (duration > 0) {
|
|
this.mTransitionDuration = duration / 1000.0f;
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
if (this.mEndState == id) {
|
|
animateTo(1.0f);
|
|
if (duration > 0) {
|
|
this.mTransitionDuration = duration / 1000.0f;
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
this.mEndState = id;
|
|
if (i != -1) {
|
|
setTransition(i, id);
|
|
animateTo(1.0f);
|
|
this.mTransitionLastPosition = 0.0f;
|
|
transitionToEnd();
|
|
if (duration > 0) {
|
|
this.mTransitionDuration = duration / 1000.0f;
|
|
return;
|
|
}
|
|
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;
|
|
if (duration == -1) {
|
|
this.mTransitionDuration = this.mScene.getDuration() / 1000.0f;
|
|
}
|
|
this.mBeginState = -1;
|
|
this.mScene.setTransition(-1, this.mEndState);
|
|
SparseArray sparseArray = new SparseArray();
|
|
if (duration == 0) {
|
|
this.mTransitionDuration = this.mScene.getDuration() / 1000.0f;
|
|
} else if (duration > 0) {
|
|
this.mTransitionDuration = duration / 1000.0f;
|
|
}
|
|
int childCount = getChildCount();
|
|
this.mFrameArrayList.clear();
|
|
for (int i2 = 0; i2 < childCount; i2++) {
|
|
View childAt = getChildAt(i2);
|
|
this.mFrameArrayList.put(childAt, new MotionController(childAt));
|
|
sparseArray.put(childAt.getId(), this.mFrameArrayList.get(childAt));
|
|
}
|
|
this.mInTransition = true;
|
|
this.mModel.initFrom(this.mLayoutWidget, null, this.mScene.getConstraintSet(id));
|
|
rebuildScene();
|
|
this.mModel.build();
|
|
computeCurrentPositions();
|
|
int width = getWidth();
|
|
int height = getHeight();
|
|
if (this.mDecoratorsHelpers != null) {
|
|
for (int i3 = 0; i3 < childCount; i3++) {
|
|
MotionController motionController = this.mFrameArrayList.get(getChildAt(i3));
|
|
if (motionController != null) {
|
|
this.mScene.getKeyFrames(motionController);
|
|
}
|
|
}
|
|
Iterator<MotionHelper> it = this.mDecoratorsHelpers.iterator();
|
|
while (it.hasNext()) {
|
|
it.next().onPreSetup(this, this.mFrameArrayList);
|
|
}
|
|
for (int i4 = 0; i4 < childCount; i4++) {
|
|
MotionController motionController2 = this.mFrameArrayList.get(getChildAt(i4));
|
|
if (motionController2 != null) {
|
|
motionController2.setup(width, height, this.mTransitionDuration, getNanoTime());
|
|
}
|
|
}
|
|
} else {
|
|
for (int i5 = 0; i5 < childCount; i5++) {
|
|
MotionController motionController3 = this.mFrameArrayList.get(getChildAt(i5));
|
|
if (motionController3 != null) {
|
|
this.mScene.getKeyFrames(motionController3);
|
|
motionController3.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 i6 = 0; i6 < childCount; i6++) {
|
|
MotionController motionController4 = this.mFrameArrayList.get(getChildAt(i6));
|
|
float finalY = motionController4.getFinalY() + motionController4.getFinalX();
|
|
f = Math.min(f, finalY);
|
|
f2 = Math.max(f2, finalY);
|
|
}
|
|
for (int i7 = 0; i7 < childCount; i7++) {
|
|
MotionController motionController5 = this.mFrameArrayList.get(getChildAt(i7));
|
|
float finalX = motionController5.getFinalX();
|
|
float finalY2 = motionController5.getFinalY();
|
|
motionController5.mStaggerScale = 1.0f / (1.0f - staggered);
|
|
motionController5.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 posOnViewX, float posOnViewY, float[] returnVelocity, int type) {
|
|
float f;
|
|
float f2 = this.mLastVelocity;
|
|
float f3 = this.mTransitionLastPosition;
|
|
if (this.mInterpolator != null) {
|
|
float signum = Math.signum(this.mTransitionGoalPosition - f3);
|
|
float interpolation = this.mInterpolator.getInterpolation(this.mTransitionLastPosition + EPSILON);
|
|
f = this.mInterpolator.getInterpolation(this.mTransitionLastPosition);
|
|
f2 = (signum * ((interpolation - f) / EPSILON)) / this.mTransitionDuration;
|
|
} else {
|
|
f = f3;
|
|
}
|
|
Interpolator interpolator = this.mInterpolator;
|
|
if (interpolator instanceof MotionInterpolator) {
|
|
f2 = ((MotionInterpolator) interpolator).getVelocity();
|
|
}
|
|
MotionController motionController = this.mFrameArrayList.get(view);
|
|
if ((type & 1) == 0) {
|
|
motionController.getPostLayoutDvDp(f, view.getWidth(), view.getHeight(), posOnViewX, posOnViewY, returnVelocity);
|
|
} else {
|
|
motionController.getDpDt(f, posOnViewX, posOnViewY, returnVelocity);
|
|
}
|
|
if (type < 2) {
|
|
returnVelocity[0] = returnVelocity[0] * f2;
|
|
returnVelocity[1] = returnVelocity[1] * f2;
|
|
}
|
|
}
|
|
|
|
class Model {
|
|
int mEndId;
|
|
int mStartId;
|
|
ConstraintWidgetContainer mLayoutStart = new ConstraintWidgetContainer();
|
|
ConstraintWidgetContainer mLayoutEnd = new ConstraintWidgetContainer();
|
|
ConstraintSet mStart = null;
|
|
ConstraintSet mEnd = null;
|
|
|
|
public boolean isNotConfiguredWith(int startId, int endId) {
|
|
return (startId == this.mStartId && endId == this.mEndId) ? false : true;
|
|
}
|
|
|
|
public void setMeasuredId(int startId, int endId) {
|
|
this.mStartId = startId;
|
|
this.mEndId = endId;
|
|
}
|
|
|
|
Model() {
|
|
}
|
|
|
|
void copy(ConstraintWidgetContainer src, ConstraintWidgetContainer dest) {
|
|
ConstraintWidget constraintWidget;
|
|
ArrayList<ConstraintWidget> children = src.getChildren();
|
|
HashMap<ConstraintWidget, ConstraintWidget> hashMap = new HashMap<>();
|
|
hashMap.put(src, dest);
|
|
dest.getChildren().clear();
|
|
dest.copy(src, 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 Placeholder) {
|
|
constraintWidget = new Placeholder();
|
|
} else if (next instanceof Helper) {
|
|
constraintWidget = new HelperWidget();
|
|
} else {
|
|
constraintWidget = new ConstraintWidget();
|
|
}
|
|
dest.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 baseLayout, ConstraintSet start, ConstraintSet end) {
|
|
this.mStart = start;
|
|
this.mEnd = end;
|
|
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 (start != null) {
|
|
setupConstraintWidget(this.mLayoutStart, start);
|
|
}
|
|
setupConstraintWidget(this.mLayoutEnd, end);
|
|
} else {
|
|
setupConstraintWidget(this.mLayoutEnd, end);
|
|
if (start != null) {
|
|
setupConstraintWidget(this.mLayoutStart, start);
|
|
}
|
|
}
|
|
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 base, ConstraintSet cSet) {
|
|
SparseArray<ConstraintWidget> sparseArray = new SparseArray<>();
|
|
Constraints.LayoutParams layoutParams = new Constraints.LayoutParams(-2, -2);
|
|
sparseArray.clear();
|
|
sparseArray.put(0, base);
|
|
sparseArray.put(MotionLayout.this.getId(), base);
|
|
if (cSet != null && cSet.mRotate != 0) {
|
|
MotionLayout motionLayout = MotionLayout.this;
|
|
motionLayout.resolveSystem(this.mLayoutEnd, motionLayout.getOptimizationLevel(), View.MeasureSpec.makeMeasureSpec(MotionLayout.this.getHeight(), BasicMeasure.EXACTLY), View.MeasureSpec.makeMeasureSpec(MotionLayout.this.getWidth(), BasicMeasure.EXACTLY));
|
|
}
|
|
Iterator<ConstraintWidget> it = base.getChildren().iterator();
|
|
while (it.hasNext()) {
|
|
ConstraintWidget next = it.next();
|
|
next.setAnimated(true);
|
|
sparseArray.put(((View) next.getCompanionWidget()).getId(), next);
|
|
}
|
|
Iterator<ConstraintWidget> it2 = base.getChildren().iterator();
|
|
while (it2.hasNext()) {
|
|
ConstraintWidget next2 = it2.next();
|
|
View view = (View) next2.getCompanionWidget();
|
|
cSet.applyToLayoutParams(view.getId(), layoutParams);
|
|
next2.setWidth(cSet.getWidth(view.getId()));
|
|
next2.setHeight(cSet.getHeight(view.getId()));
|
|
if (view instanceof ConstraintHelper) {
|
|
cSet.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 (cSet.getVisibilityMode(view.getId()) == 1) {
|
|
next2.setVisibility(view.getVisibility());
|
|
} else {
|
|
next2.setVisibility(cSet.getVisibility(view.getId()));
|
|
}
|
|
}
|
|
Iterator<ConstraintWidget> it3 = base.getChildren().iterator();
|
|
while (it3.hasNext()) {
|
|
ConstraintWidget next3 = it3.next();
|
|
if (next3 instanceof VirtualLayout) {
|
|
ConstraintHelper constraintHelper = (ConstraintHelper) next3.getCompanionWidget();
|
|
Helper helper = (Helper) next3;
|
|
constraintHelper.updatePreLayout(base, helper, sparseArray);
|
|
((VirtualLayout) helper).captureWidgets();
|
|
}
|
|
}
|
|
}
|
|
|
|
ConstraintWidget getWidget(ConstraintWidgetContainer container, View view) {
|
|
if (container.getCompanionWidget() == view) {
|
|
return container;
|
|
}
|
|
ArrayList<ConstraintWidget> children = container.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 params) {
|
|
String concat = " ".concat(params.startToStart != -1 ? "SS" : "__");
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(concat);
|
|
sb.append(params.startToEnd != -1 ? "|SE" : "|__");
|
|
String sb2 = sb.toString();
|
|
StringBuilder sb3 = new StringBuilder();
|
|
sb3.append(sb2);
|
|
sb3.append(params.endToStart != -1 ? "|ES" : "|__");
|
|
String sb4 = sb3.toString();
|
|
StringBuilder sb5 = new StringBuilder();
|
|
sb5.append(sb4);
|
|
sb5.append(params.endToEnd != -1 ? "|EE" : "|__");
|
|
String sb6 = sb5.toString();
|
|
StringBuilder sb7 = new StringBuilder();
|
|
sb7.append(sb6);
|
|
sb7.append(params.leftToLeft != -1 ? "|LL" : "|__");
|
|
String sb8 = sb7.toString();
|
|
StringBuilder sb9 = new StringBuilder();
|
|
sb9.append(sb8);
|
|
sb9.append(params.leftToRight != -1 ? "|LR" : "|__");
|
|
String sb10 = sb9.toString();
|
|
StringBuilder sb11 = new StringBuilder();
|
|
sb11.append(sb10);
|
|
sb11.append(params.rightToLeft != -1 ? "|RL" : "|__");
|
|
String sb12 = sb11.toString();
|
|
StringBuilder sb13 = new StringBuilder();
|
|
sb13.append(sb12);
|
|
sb13.append(params.rightToRight != -1 ? "|RR" : "|__");
|
|
String sb14 = sb13.toString();
|
|
StringBuilder sb15 = new StringBuilder();
|
|
sb15.append(sb14);
|
|
sb15.append(params.topToTop != -1 ? "|TT" : "|__");
|
|
String sb16 = sb15.toString();
|
|
StringBuilder sb17 = new StringBuilder();
|
|
sb17.append(sb16);
|
|
sb17.append(params.topToBottom != -1 ? "|TB" : "|__");
|
|
String sb18 = sb17.toString();
|
|
StringBuilder sb19 = new StringBuilder();
|
|
sb19.append(sb18);
|
|
sb19.append(params.bottomToTop != -1 ? "|BT" : "|__");
|
|
String sb20 = sb19.toString();
|
|
StringBuilder sb21 = new StringBuilder();
|
|
sb21.append(sb20);
|
|
sb21.append(params.bottomToBottom != -1 ? "|BB" : "|__");
|
|
Log.v(MotionLayout.TAG, str + sb21.toString());
|
|
}
|
|
|
|
private void debugWidget(String str, ConstraintWidget child) {
|
|
String str2;
|
|
String str3;
|
|
String str4;
|
|
StringBuilder sb = new StringBuilder(" ");
|
|
String str5 = "__";
|
|
if (child.mTop.mTarget != null) {
|
|
str2 = "T".concat(child.mTop.mTarget.mType == ConstraintAnchor.Type.TOP ? "T" : "B");
|
|
} else {
|
|
str2 = "__";
|
|
}
|
|
sb.append(str2);
|
|
String sb2 = sb.toString();
|
|
StringBuilder sb3 = new StringBuilder();
|
|
sb3.append(sb2);
|
|
if (child.mBottom.mTarget != null) {
|
|
str3 = "B".concat(child.mBottom.mTarget.mType != ConstraintAnchor.Type.TOP ? "B" : "T");
|
|
} else {
|
|
str3 = "__";
|
|
}
|
|
sb3.append(str3);
|
|
String sb4 = sb3.toString();
|
|
StringBuilder sb5 = new StringBuilder();
|
|
sb5.append(sb4);
|
|
if (child.mLeft.mTarget != null) {
|
|
str4 = "L".concat(child.mLeft.mTarget.mType == ConstraintAnchor.Type.LEFT ? "L" : "R");
|
|
} else {
|
|
str4 = "__";
|
|
}
|
|
sb5.append(str4);
|
|
String sb6 = sb5.toString();
|
|
StringBuilder sb7 = new StringBuilder();
|
|
sb7.append(sb6);
|
|
if (child.mRight.mTarget != null) {
|
|
str5 = "R".concat(child.mRight.mTarget.mType != ConstraintAnchor.Type.LEFT ? "R" : "L");
|
|
}
|
|
sb7.append(str5);
|
|
Log.v(MotionLayout.TAG, str + sb7.toString() + " --- " + child);
|
|
}
|
|
|
|
private void debugLayout(String title, ConstraintWidgetContainer c) {
|
|
String str = title + " " + Debug.getName((View) c.getCompanionWidget());
|
|
Log.v(MotionLayout.TAG, str + " ========= " + c);
|
|
int size = c.getChildren().size();
|
|
for (int i = 0; i < size; i++) {
|
|
String str2 = str + "[" + i + "] ";
|
|
ConstraintWidget constraintWidget = c.getChildren().get(i);
|
|
String str3 = constraintWidget.mTop.mTarget != null ? "T" : "_";
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(str3);
|
|
sb.append(constraintWidget.mBottom.mTarget != null ? "B" : "_");
|
|
String sb2 = sb.toString();
|
|
StringBuilder sb3 = new StringBuilder();
|
|
sb3.append(sb2);
|
|
sb3.append(constraintWidget.mLeft.mTarget != null ? "L" : "_");
|
|
String sb4 = sb3.toString();
|
|
StringBuilder sb5 = new StringBuilder();
|
|
sb5.append(sb4);
|
|
sb5.append(constraintWidget.mRight.mTarget != null ? "R" : "_");
|
|
String sb6 = sb5.toString();
|
|
View view = (View) constraintWidget.getCompanionWidget();
|
|
String name = Debug.getName(view);
|
|
if (view instanceof TextView) {
|
|
name = name + "(" + ((Object) ((TextView) view).getText()) + ")";
|
|
}
|
|
Log.v(MotionLayout.TAG, str2 + " " + name + " " + constraintWidget + " " + sb6);
|
|
}
|
|
Log.v(MotionLayout.TAG, str + " done. ");
|
|
}
|
|
|
|
public void reEvaluateState() {
|
|
measure(MotionLayout.this.mLastWidthMeasureSpec, MotionLayout.this.mLastHeightMeasureSpec);
|
|
MotionLayout.this.setupMotionViews();
|
|
}
|
|
|
|
public void measure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
int mode = View.MeasureSpec.getMode(widthMeasureSpec);
|
|
int mode2 = View.MeasureSpec.getMode(heightMeasureSpec);
|
|
MotionLayout.this.mWidthMeasureMode = mode;
|
|
MotionLayout.this.mHeightMeasureMode = mode2;
|
|
MotionLayout.this.getOptimizationLevel();
|
|
computeStartEndSize(widthMeasureSpec, heightMeasureSpec);
|
|
if (!(MotionLayout.this.getParent() instanceof MotionLayout) || mode != 1073741824 || mode2 != 1073741824) {
|
|
computeStartEndSize(widthMeasureSpec, heightMeasureSpec);
|
|
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 i = MotionLayout.this.mStartWrapWidth;
|
|
int i2 = MotionLayout.this.mStartWrapHeight;
|
|
if (MotionLayout.this.mWidthMeasureMode == Integer.MIN_VALUE || MotionLayout.this.mWidthMeasureMode == 0) {
|
|
i = (int) (MotionLayout.this.mStartWrapWidth + (MotionLayout.this.mPostInterpolationPosition * (MotionLayout.this.mEndWrapWidth - MotionLayout.this.mStartWrapWidth)));
|
|
}
|
|
int i3 = i;
|
|
if (MotionLayout.this.mHeightMeasureMode == Integer.MIN_VALUE || MotionLayout.this.mHeightMeasureMode == 0) {
|
|
i2 = (int) (MotionLayout.this.mStartWrapHeight + (MotionLayout.this.mPostInterpolationPosition * (MotionLayout.this.mEndWrapHeight - MotionLayout.this.mStartWrapHeight)));
|
|
}
|
|
MotionLayout.this.resolveMeasuredDimension(widthMeasureSpec, heightMeasureSpec, i3, i2, this.mLayoutStart.isWidthMeasuredTooSmall() || this.mLayoutEnd.isWidthMeasuredTooSmall(), this.mLayoutStart.isHeightMeasuredTooSmall() || this.mLayoutEnd.isHeightMeasuredTooSmall());
|
|
}
|
|
|
|
private void computeStartEndSize(int widthMeasureSpec, int heightMeasureSpec) {
|
|
int optimizationLevel = MotionLayout.this.getOptimizationLevel();
|
|
if (MotionLayout.this.mCurrentState == MotionLayout.this.getStartState()) {
|
|
MotionLayout motionLayout = MotionLayout.this;
|
|
ConstraintWidgetContainer constraintWidgetContainer = this.mLayoutEnd;
|
|
ConstraintSet constraintSet = this.mEnd;
|
|
int i = (constraintSet == null || constraintSet.mRotate == 0) ? widthMeasureSpec : heightMeasureSpec;
|
|
ConstraintSet constraintSet2 = this.mEnd;
|
|
motionLayout.resolveSystem(constraintWidgetContainer, optimizationLevel, i, (constraintSet2 == null || constraintSet2.mRotate == 0) ? heightMeasureSpec : widthMeasureSpec);
|
|
ConstraintSet constraintSet3 = this.mStart;
|
|
if (constraintSet3 != null) {
|
|
MotionLayout motionLayout2 = MotionLayout.this;
|
|
ConstraintWidgetContainer constraintWidgetContainer2 = this.mLayoutStart;
|
|
int i2 = constraintSet3.mRotate == 0 ? widthMeasureSpec : heightMeasureSpec;
|
|
if (this.mStart.mRotate == 0) {
|
|
widthMeasureSpec = heightMeasureSpec;
|
|
}
|
|
motionLayout2.resolveSystem(constraintWidgetContainer2, optimizationLevel, i2, widthMeasureSpec);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
ConstraintSet constraintSet4 = this.mStart;
|
|
if (constraintSet4 != null) {
|
|
MotionLayout.this.resolveSystem(this.mLayoutStart, optimizationLevel, constraintSet4.mRotate == 0 ? widthMeasureSpec : heightMeasureSpec, this.mStart.mRotate == 0 ? heightMeasureSpec : widthMeasureSpec);
|
|
}
|
|
MotionLayout motionLayout3 = MotionLayout.this;
|
|
ConstraintWidgetContainer constraintWidgetContainer3 = this.mLayoutEnd;
|
|
ConstraintSet constraintSet5 = this.mEnd;
|
|
int i3 = (constraintSet5 == null || constraintSet5.mRotate == 0) ? widthMeasureSpec : heightMeasureSpec;
|
|
ConstraintSet constraintSet6 = this.mEnd;
|
|
if (constraintSet6 == null || constraintSet6.mRotate == 0) {
|
|
widthMeasureSpec = heightMeasureSpec;
|
|
}
|
|
motionLayout3.resolveSystem(constraintWidgetContainer3, optimizationLevel, i3, widthMeasureSpec);
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:20:0x00eb */
|
|
/* JADX WARN: Removed duplicated region for block: B:29:0x013f A[SYNTHETIC] */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public void build() {
|
|
/*
|
|
Method dump skipped, instructions count: 362
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.constraintlayout.motion.widget.MotionLayout.Model.build():void");
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public Rect toRect(ConstraintWidget cw) {
|
|
this.mTempRect.top = cw.getY();
|
|
this.mTempRect.left = cw.getX();
|
|
this.mTempRect.right = cw.getWidth() + this.mTempRect.left;
|
|
this.mTempRect.bottom = cw.getHeight() + this.mTempRect.top;
|
|
return this.mTempRect;
|
|
}
|
|
|
|
@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) {
|
|
int layoutDuringTransition = this.mScene.mCurrentTransition.getLayoutDuringTransition();
|
|
if (layoutDuringTransition == 0) {
|
|
return;
|
|
}
|
|
if (layoutDuringTransition == 2) {
|
|
int childCount = getChildCount();
|
|
for (int i = 0; i < childCount; i++) {
|
|
this.mFrameArrayList.get(getChildAt(i)).remeasure();
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
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 widthMeasureSpec, int heightMeasureSpec) {
|
|
if (this.mScene == null) {
|
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
return;
|
|
}
|
|
boolean z = false;
|
|
boolean z2 = (this.mLastWidthMeasureSpec == widthMeasureSpec && this.mLastHeightMeasureSpec == heightMeasureSpec) ? false : true;
|
|
if (this.mNeedsFireTransitionCompleted) {
|
|
this.mNeedsFireTransitionCompleted = false;
|
|
onNewStateAttachHandlers();
|
|
processTransitionCompleted();
|
|
z2 = true;
|
|
}
|
|
if (this.mDirtyHierarchy) {
|
|
z2 = true;
|
|
}
|
|
this.mLastWidthMeasureSpec = widthMeasureSpec;
|
|
this.mLastHeightMeasureSpec = heightMeasureSpec;
|
|
int startId = this.mScene.getStartId();
|
|
int endId = this.mScene.getEndId();
|
|
if ((z2 || this.mModel.isNotConfiguredWith(startId, endId)) && this.mBeginState != -1) {
|
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
this.mModel.initFrom(this.mLayoutWidget, this.mScene.getConstraintSet(startId), this.mScene.getConstraintSet(endId));
|
|
this.mModel.reEvaluateState();
|
|
this.mModel.setMeasuredId(startId, endId);
|
|
} else {
|
|
if (z2) {
|
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
}
|
|
z = true;
|
|
}
|
|
if (this.mMeasureDuringTransition || z) {
|
|
int paddingTop = getPaddingTop() + getPaddingBottom();
|
|
int width = this.mLayoutWidget.getWidth() + getPaddingLeft() + getPaddingRight();
|
|
int height = this.mLayoutWidget.getHeight() + paddingTop;
|
|
int i = this.mWidthMeasureMode;
|
|
if (i == Integer.MIN_VALUE || i == 0) {
|
|
width = (int) (this.mStartWrapWidth + (this.mPostInterpolationPosition * (this.mEndWrapWidth - r8)));
|
|
requestLayout();
|
|
}
|
|
int i2 = this.mHeightMeasureMode;
|
|
if (i2 == Integer.MIN_VALUE || i2 == 0) {
|
|
height = (int) (this.mStartWrapHeight + (this.mPostInterpolationPosition * (this.mEndWrapHeight - r8)));
|
|
requestLayout();
|
|
}
|
|
setMeasuredDimension(width, height);
|
|
}
|
|
evaluateLayout();
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingParent2
|
|
public boolean onStartNestedScroll(View child, View target, int axes, int type) {
|
|
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 onNestedScrollAccepted(View child, View target, int axes, int type) {
|
|
this.mScrollTargetTime = getNanoTime();
|
|
this.mScrollTargetDT = 0.0f;
|
|
this.mScrollTargetDX = 0.0f;
|
|
this.mScrollTargetDY = 0.0f;
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingParent2
|
|
public void onStopNestedScroll(View target, int type) {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene != null) {
|
|
float f = this.mScrollTargetDT;
|
|
if (f == 0.0f) {
|
|
return;
|
|
}
|
|
motionScene.processScrollUp(this.mScrollTargetDX / f, this.mScrollTargetDY / f);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingParent3
|
|
public void onNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int type, int[] consumed) {
|
|
if (this.mUndergoingMotion || dxConsumed != 0 || dyConsumed != 0) {
|
|
consumed[0] = consumed[0] + dxUnconsumed;
|
|
consumed[1] = consumed[1] + dyUnconsumed;
|
|
}
|
|
this.mUndergoingMotion = false;
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingParent2
|
|
public void onNestedPreScroll(final View target, int dx, int dy, int[] consumed, int type) {
|
|
MotionScene.Transition transition;
|
|
TouchResponse touchResponse;
|
|
int touchRegionId;
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene == null || (transition = motionScene.mCurrentTransition) == null || !transition.isEnabled()) {
|
|
return;
|
|
}
|
|
int i = -1;
|
|
if (!transition.isEnabled() || (touchResponse = transition.getTouchResponse()) == null || (touchRegionId = touchResponse.getTouchRegionId()) == -1 || target.getId() == touchRegionId) {
|
|
if (motionScene.getMoveWhenScrollAtTop()) {
|
|
TouchResponse touchResponse2 = transition.getTouchResponse();
|
|
if (touchResponse2 != null && (touchResponse2.getFlags() & 4) != 0) {
|
|
i = dy;
|
|
}
|
|
float f = this.mTransitionPosition;
|
|
if ((f == 1.0f || f == 0.0f) && target.canScrollVertically(i)) {
|
|
return;
|
|
}
|
|
}
|
|
if (transition.getTouchResponse() != null && (transition.getTouchResponse().getFlags() & 1) != 0) {
|
|
float progressDirection = motionScene.getProgressDirection(dx, dy);
|
|
float f2 = this.mTransitionLastPosition;
|
|
if ((f2 <= 0.0f && progressDirection < 0.0f) || (f2 >= 1.0f && progressDirection > 0.0f)) {
|
|
target.setNestedScrollingEnabled(false);
|
|
target.post(new Runnable(this) { // from class: androidx.constraintlayout.motion.widget.MotionLayout.3
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
target.setNestedScrollingEnabled(true);
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
}
|
|
float f3 = this.mTransitionPosition;
|
|
long nanoTime = getNanoTime();
|
|
float f4 = dx;
|
|
this.mScrollTargetDX = f4;
|
|
float f5 = dy;
|
|
this.mScrollTargetDY = f5;
|
|
this.mScrollTargetDT = (float) ((nanoTime - this.mScrollTargetTime) * 1.0E-9d);
|
|
this.mScrollTargetTime = nanoTime;
|
|
motionScene.processScrollMove(f4, f5);
|
|
if (f3 != this.mTransitionPosition) {
|
|
consumed[0] = dx;
|
|
consumed[1] = dy;
|
|
}
|
|
evaluate(false);
|
|
if (consumed[0] == 0 && consumed[1] == 0) {
|
|
return;
|
|
}
|
|
this.mUndergoingMotion = true;
|
|
}
|
|
}
|
|
|
|
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> frameArrayList, int duration, int debugPath) {
|
|
if (frameArrayList == null || frameArrayList.size() == 0) {
|
|
return;
|
|
}
|
|
canvas.save();
|
|
if (!MotionLayout.this.isInEditMode() && (debugPath & 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 : frameArrayList.values()) {
|
|
int drawPath = motionController.getDrawPath();
|
|
if (debugPath > 0 && drawPath == 0) {
|
|
drawPath = 1;
|
|
}
|
|
if (drawPath != 0) {
|
|
this.mKeyFrameCount = motionController.buildKeyFrames(this.mKeyFramePoints, this.mPathMode);
|
|
if (drawPath >= 1) {
|
|
int i = duration / 16;
|
|
float[] fArr = this.mPoints;
|
|
if (fArr == null || fArr.length != i * 2) {
|
|
this.mPoints = new float[i * 2];
|
|
this.mPath = new Path();
|
|
}
|
|
int i2 = this.mShadowTranslate;
|
|
canvas.translate(i2, i2);
|
|
this.mPaint.setColor(1996488704);
|
|
this.mFillPaint.setColor(1996488704);
|
|
this.mPaintKeyframes.setColor(1996488704);
|
|
this.mPaintGraph.setColor(1996488704);
|
|
motionController.buildPath(this.mPoints, i);
|
|
drawAll(canvas, drawPath, this.mKeyFrameCount, motionController);
|
|
this.mPaint.setColor(-21965);
|
|
this.mPaintKeyframes.setColor(-2067046);
|
|
this.mFillPaint.setColor(-2067046);
|
|
this.mPaintGraph.setColor(-13391360);
|
|
int i3 = this.mShadowTranslate;
|
|
canvas.translate(-i3, -i3);
|
|
drawAll(canvas, drawPath, this.mKeyFrameCount, motionController);
|
|
if (drawPath == 5) {
|
|
drawRectangle(canvas, motionController);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
canvas.restore();
|
|
}
|
|
|
|
public void drawAll(Canvas canvas, int mode, int keyFrames, MotionController motionController) {
|
|
if (mode == 4) {
|
|
drawPathAsConfigured(canvas);
|
|
}
|
|
if (mode == 2) {
|
|
drawPathRelative(canvas);
|
|
}
|
|
if (mode == 3) {
|
|
drawPathCartesian(canvas);
|
|
}
|
|
drawBasicPath(canvas);
|
|
drawTicks(canvas, mode, keyFrames, motionController);
|
|
}
|
|
|
|
private void drawBasicPath(Canvas canvas) {
|
|
canvas.drawLines(this.mPoints, this.mPaint);
|
|
}
|
|
|
|
private void drawTicks(Canvas canvas, int mode, int keyFrames, MotionController motionController) {
|
|
int i;
|
|
int i2;
|
|
float f;
|
|
float f2;
|
|
if (motionController.mView != null) {
|
|
i = motionController.mView.getWidth();
|
|
i2 = motionController.mView.getHeight();
|
|
} else {
|
|
i = 0;
|
|
i2 = 0;
|
|
}
|
|
for (int i3 = 1; i3 < keyFrames - 1; i3++) {
|
|
if (mode != 4 || this.mPathMode[i3 - 1] != 0) {
|
|
float[] fArr = this.mKeyFramePoints;
|
|
int i4 = i3 * 2;
|
|
float f3 = fArr[i4];
|
|
float f4 = fArr[i4 + 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 i5 = i3 - 1;
|
|
motionController.getKeyFrame(i5);
|
|
if (mode == 4) {
|
|
int i6 = this.mPathMode[i5];
|
|
if (i6 == 1) {
|
|
drawPathRelativeTicks(canvas, f3 - 0.0f, f4 - 0.0f);
|
|
} else if (i6 == 0) {
|
|
drawPathCartesianTicks(canvas, f3 - 0.0f, f4 - 0.0f);
|
|
} else if (i6 == 2) {
|
|
f = f4;
|
|
f2 = f3;
|
|
drawPathScreenTicks(canvas, f3 - 0.0f, f4 - 0.0f, i, i2);
|
|
canvas.drawPath(this.mPath, this.mFillPaint);
|
|
}
|
|
f = f4;
|
|
f2 = f3;
|
|
canvas.drawPath(this.mPath, this.mFillPaint);
|
|
} else {
|
|
f = f4;
|
|
f2 = f3;
|
|
}
|
|
if (mode == 2) {
|
|
drawPathRelativeTicks(canvas, f2 - 0.0f, f - 0.0f);
|
|
}
|
|
if (mode == 3) {
|
|
drawPathCartesianTicks(canvas, f2 - 0.0f, f - 0.0f);
|
|
}
|
|
if (mode == 6) {
|
|
drawPathScreenTicks(canvas, f2 - 0.0f, f - 0.0f, i, i2);
|
|
}
|
|
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 x1, float y1, float x2, float y2) {
|
|
canvas.drawRect(x1, y1, x2, y2, this.mPaintGraph);
|
|
canvas.drawLine(x1, y1, x2, y2, 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 == 0) {
|
|
z2 = true;
|
|
}
|
|
}
|
|
if (z) {
|
|
drawPathRelative(canvas);
|
|
}
|
|
if (z2) {
|
|
drawPathCartesian(canvas);
|
|
}
|
|
}
|
|
|
|
private void drawPathRelativeTicks(Canvas canvas, float x, float y) {
|
|
float[] fArr = this.mPoints;
|
|
float f = fArr[0];
|
|
float f2 = fArr[1];
|
|
float f3 = fArr[fArr.length - 2];
|
|
float f4 = fArr[fArr.length - 1];
|
|
float hypot = (float) Math.hypot(f - f3, f2 - f4);
|
|
float f5 = f3 - f;
|
|
float f6 = f4 - f2;
|
|
float f7 = (((x - f) * f5) + ((y - f2) * f6)) / (hypot * hypot);
|
|
float f8 = f + (f5 * f7);
|
|
float f9 = f2 + (f7 * f6);
|
|
Path path = new Path();
|
|
path.moveTo(x, y);
|
|
path.lineTo(f8, f9);
|
|
float hypot2 = (float) Math.hypot(f8 - x, f9 - y);
|
|
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(x, y, f8, f9, this.mPaintGraph);
|
|
}
|
|
|
|
void getTextBounds(String text, Paint paint) {
|
|
paint.getTextBounds(text, 0, text.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 x, float y) {
|
|
float[] fArr = this.mPoints;
|
|
float f = fArr[0];
|
|
float f2 = fArr[1];
|
|
float f3 = fArr[fArr.length - 2];
|
|
float f4 = fArr[fArr.length - 1];
|
|
float min = Math.min(f, f3);
|
|
float max = Math.max(f2, f4);
|
|
float min2 = x - Math.min(f, f3);
|
|
float max2 = Math.max(f2, f4) - y;
|
|
String str = "" + (((int) (((min2 * 100.0f) / Math.abs(f3 - f)) + 0.5d)) / 100.0f);
|
|
getTextBounds(str, this.mTextPaint);
|
|
canvas.drawText(str, ((min2 / 2.0f) - (this.mBounds.width() / 2)) + min, y - 20.0f, this.mTextPaint);
|
|
canvas.drawLine(x, y, Math.min(f, f3), y, this.mPaintGraph);
|
|
String str2 = "" + (((int) (((max2 * 100.0f) / Math.abs(f4 - f2)) + 0.5d)) / 100.0f);
|
|
getTextBounds(str2, this.mTextPaint);
|
|
canvas.drawText(str2, x + 5.0f, max - ((max2 / 2.0f) - (this.mBounds.height() / 2)), this.mTextPaint);
|
|
canvas.drawLine(x, y, x, Math.max(f2, f4), this.mPaintGraph);
|
|
}
|
|
|
|
private void drawPathScreenTicks(Canvas canvas, float x, float y, int viewWidth, int viewHeight) {
|
|
String str = "" + (((int) ((((x - (viewWidth / 2)) * 100.0f) / (MotionLayout.this.getWidth() - viewWidth)) + 0.5d)) / 100.0f);
|
|
getTextBounds(str, this.mTextPaint);
|
|
canvas.drawText(str, ((x / 2.0f) - (this.mBounds.width() / 2)) + 0.0f, y - 20.0f, this.mTextPaint);
|
|
canvas.drawLine(x, y, Math.min(0.0f, 1.0f), y, this.mPaintGraph);
|
|
String str2 = "" + (((int) ((((y - (viewHeight / 2)) * 100.0f) / (MotionLayout.this.getHeight() - viewHeight)) + 0.5d)) / 100.0f);
|
|
getTextBounds(str2, this.mTextPaint);
|
|
canvas.drawText(str2, x + 5.0f, 0.0f - ((y / 2.0f) - (this.mBounds.height() / 2)), this.mTextPaint);
|
|
canvas.drawLine(x, y, x, 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) {
|
|
ArrayList<MotionHelper> arrayList = this.mDecoratorsHelpers;
|
|
if (arrayList != null) {
|
|
Iterator<MotionHelper> it = arrayList.iterator();
|
|
while (it.hasNext()) {
|
|
it.next().onPreDraw(canvas);
|
|
}
|
|
}
|
|
evaluate(false);
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene != null && motionScene.mViewTransitionController != null) {
|
|
this.mScene.mViewTransitionController.animate();
|
|
}
|
|
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 / (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);
|
|
String str = this.mLastFps + " fps " + Debug.getState(this, this.mBeginState) + " -> ";
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(str);
|
|
sb.append(Debug.getState(this, this.mEndState));
|
|
sb.append(" (progress: ");
|
|
sb.append(((int) (getProgress() * 1000.0f)) / 10.0f);
|
|
sb.append(" ) state=");
|
|
int i = this.mCurrentState;
|
|
sb.append(i == -1 ? "undefined" : Debug.getState(this, i));
|
|
String sb2 = sb.toString();
|
|
paint.setColor(ViewCompat.MEASURED_STATE_MASK);
|
|
canvas.drawText(sb2, 11.0f, getHeight() - 29, paint);
|
|
paint.setColor(-7864184);
|
|
canvas.drawText(sb2, 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);
|
|
}
|
|
ArrayList<MotionHelper> arrayList2 = this.mDecoratorsHelpers;
|
|
if (arrayList2 != null) {
|
|
Iterator<MotionHelper> it2 = arrayList2.iterator();
|
|
while (it2.hasNext()) {
|
|
it2.next().onPostDraw(canvas);
|
|
}
|
|
}
|
|
}
|
|
|
|
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) ? (((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((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();
|
|
Interpolator interpolator2 = this.mProgressInterpolator;
|
|
if (interpolator2 != null) {
|
|
f = interpolator2.getInterpolation(f);
|
|
}
|
|
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();
|
|
}
|
|
}
|
|
|
|
void endTrigger(boolean start) {
|
|
int childCount = getChildCount();
|
|
for (int i = 0; i < childCount; i++) {
|
|
MotionController motionController = this.mFrameArrayList.get(getChildAt(i));
|
|
if (motionController != null) {
|
|
motionController.endTrigger(start);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:107:0x019c */
|
|
/* JADX WARN: Removed duplicated region for block: B:112:0x01b3 */
|
|
/* JADX WARN: Removed duplicated region for block: B:118:0x01c2 */
|
|
/* JADX WARN: Removed duplicated region for block: B:121:0x01cf */
|
|
/* JADX WARN: Removed duplicated region for block: B:128:0x01f0 */
|
|
/* JADX WARN: Removed duplicated region for block: B:133:0x020b */
|
|
/* JADX WARN: Removed duplicated region for block: B:141:0x022d */
|
|
/* JADX WARN: Removed duplicated region for block: B:161:0x0155 */
|
|
/* JADX WARN: Removed duplicated region for block: B:76:0x0115 */
|
|
/* JADX WARN: Removed duplicated region for block: B:78:0x011c */
|
|
/* JADX WARN: Removed duplicated region for block: B:93:0x0153 */
|
|
/* JADX WARN: Removed duplicated region for block: B:96:0x015d */
|
|
/* JADX WARN: Removed duplicated region for block: B:99:0x0174 */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
void evaluate(boolean r23) {
|
|
/*
|
|
Method dump skipped, instructions count: 634
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: androidx.constraintlayout.motion.widget.MotionLayout.evaluate(boolean):void");
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.widget.ConstraintLayout, android.view.ViewGroup, android.view.View
|
|
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
|
this.mInLayout = true;
|
|
try {
|
|
if (this.mScene == null) {
|
|
super.onLayout(changed, left, top, right, bottom);
|
|
return;
|
|
}
|
|
int i = right - left;
|
|
int i2 = bottom - top;
|
|
if (this.mLastLayoutWidth != i || this.mLastLayoutHeight != i2) {
|
|
rebuildScene();
|
|
evaluate(true);
|
|
}
|
|
this.mLastLayoutWidth = i;
|
|
this.mLastLayoutHeight = i2;
|
|
this.mOldWidth = i;
|
|
this.mOldHeight = i2;
|
|
} finally {
|
|
this.mInLayout = false;
|
|
}
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.widget.ConstraintLayout
|
|
protected void parseLayoutDescription(int id) {
|
|
this.mConstraintLayoutSpec = null;
|
|
}
|
|
|
|
private void init(AttributeSet attrs) {
|
|
MotionScene motionScene;
|
|
IS_IN_EDIT_MODE = isInEditMode();
|
|
if (attrs != null) {
|
|
TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attrs, 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 scene) {
|
|
this.mScene = scene;
|
|
scene.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 csetId, ConstraintSet set) {
|
|
String name = Debug.getName(getContext(), csetId);
|
|
int childCount = getChildCount();
|
|
for (int i = 0; i < childCount; i++) {
|
|
View childAt = getChildAt(i);
|
|
int id = childAt.getId();
|
|
if (id == -1) {
|
|
Log.w(TAG, "CHECK: " + name + " ALL VIEWS SHOULD HAVE ID's " + childAt.getClass().getName() + " does not!");
|
|
}
|
|
if (set.getConstraint(id) == null) {
|
|
Log.w(TAG, "CHECK: " + name + " NO CONSTRAINTS for " + Debug.getName(childAt));
|
|
}
|
|
}
|
|
int[] knownIds = set.getKnownIds();
|
|
for (int i2 = 0; i2 < knownIds.length; i2++) {
|
|
int i3 = knownIds[i2];
|
|
String name2 = Debug.getName(getContext(), i3);
|
|
if (findViewById(knownIds[i2]) == null) {
|
|
Log.w(TAG, "CHECK: " + name + " NO View matches id " + name2);
|
|
}
|
|
if (set.getHeight(i3) == -1) {
|
|
Log.w(TAG, "CHECK: " + name + "(" + name2 + ") no LAYOUT_HEIGHT");
|
|
}
|
|
if (set.getWidth(i3) == -1) {
|
|
Log.w(TAG, "CHECK: " + name + "(" + name2 + ") no LAYOUT_HEIGHT");
|
|
}
|
|
}
|
|
}
|
|
|
|
private void checkStructure(MotionScene.Transition transition) {
|
|
if (transition.getStartConstraintSetId() == transition.getEndConstraintSetId()) {
|
|
Log.e(TAG, "CHECK: start and end constraint set should not be the same!");
|
|
}
|
|
}
|
|
|
|
public void setDebugMode(int debugMode) {
|
|
this.mDebugPath = debugMode;
|
|
invalidate();
|
|
}
|
|
|
|
public void getDebugMode(boolean showPaths) {
|
|
this.mDebugPath = showPaths ? 2 : 1;
|
|
invalidate();
|
|
}
|
|
|
|
private boolean callTransformedTouchEvent(View view, MotionEvent event, float offsetX, float offsetY) {
|
|
Matrix matrix = view.getMatrix();
|
|
if (matrix.isIdentity()) {
|
|
event.offsetLocation(offsetX, offsetY);
|
|
boolean onTouchEvent = view.onTouchEvent(event);
|
|
event.offsetLocation(-offsetX, -offsetY);
|
|
return onTouchEvent;
|
|
}
|
|
MotionEvent obtain = MotionEvent.obtain(event);
|
|
obtain.offsetLocation(offsetX, offsetY);
|
|
if (this.mInverseMatrix == null) {
|
|
this.mInverseMatrix = new Matrix();
|
|
}
|
|
matrix.invert(this.mInverseMatrix);
|
|
obtain.transform(this.mInverseMatrix);
|
|
boolean onTouchEvent2 = view.onTouchEvent(obtain);
|
|
obtain.recycle();
|
|
return onTouchEvent2;
|
|
}
|
|
|
|
private boolean handlesTouchEvent(float x, float y, View view, MotionEvent event) {
|
|
boolean z;
|
|
if (view instanceof ViewGroup) {
|
|
ViewGroup viewGroup = (ViewGroup) view;
|
|
for (int childCount = viewGroup.getChildCount() - 1; childCount >= 0; childCount--) {
|
|
if (handlesTouchEvent((r3.getLeft() + x) - view.getScrollX(), (r3.getTop() + y) - view.getScrollY(), viewGroup.getChildAt(childCount), event)) {
|
|
z = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
z = false;
|
|
if (!z) {
|
|
this.mBoundsCheck.set(x, y, (view.getRight() + x) - view.getLeft(), (view.getBottom() + y) - view.getTop());
|
|
if ((event.getAction() != 0 || this.mBoundsCheck.contains(event.getX(), event.getY())) && callTransformedTouchEvent(view, event, -x, -y)) {
|
|
return true;
|
|
}
|
|
}
|
|
return z;
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public boolean onInterceptTouchEvent(MotionEvent event) {
|
|
TouchResponse touchResponse;
|
|
int touchRegionId;
|
|
RectF touchRegion;
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene != null && this.mInteractionEnabled) {
|
|
if (motionScene.mViewTransitionController != null) {
|
|
this.mScene.mViewTransitionController.touchEvent(event);
|
|
}
|
|
MotionScene.Transition transition = this.mScene.mCurrentTransition;
|
|
if (transition != null && transition.isEnabled() && (touchResponse = transition.getTouchResponse()) != null && ((event.getAction() != 0 || (touchRegion = touchResponse.getTouchRegion(this, new RectF())) == null || touchRegion.contains(event.getX(), event.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(event.getX(), event.getY()) && !handlesTouchEvent(this.mRegionView.getLeft(), this.mRegionView.getTop(), this.mRegionView, event)) {
|
|
return onTouchEvent(event);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public boolean onTouchEvent(MotionEvent event) {
|
|
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(event);
|
|
}
|
|
this.mScene.processTouchEvent(event, getCurrentState(), this);
|
|
if (this.mScene.mCurrentTransition.isTransitionFlag(4)) {
|
|
return this.mScene.mCurrentTransition.getTouchResponse().isDragStarted();
|
|
}
|
|
return true;
|
|
}
|
|
return super.onTouchEvent(event);
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
protected void onAttachedToWindow() {
|
|
int i;
|
|
super.onAttachedToWindow();
|
|
Display display = getDisplay();
|
|
if (display != null) {
|
|
this.mPreviouseRotation = display.getRotation();
|
|
}
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene != null && (i = this.mCurrentState) != -1) {
|
|
ConstraintSet constraintSet = motionScene.getConstraintSet(i);
|
|
this.mScene.readFallback(this);
|
|
ArrayList<MotionHelper> arrayList = this.mDecoratorsHelpers;
|
|
if (arrayList != null) {
|
|
Iterator<MotionHelper> it = arrayList.iterator();
|
|
while (it.hasNext()) {
|
|
it.next().onFinishedMotionScene(this);
|
|
}
|
|
}
|
|
if (constraintSet != null) {
|
|
constraintSet.applyTo(this);
|
|
}
|
|
this.mBeginState = this.mCurrentState;
|
|
}
|
|
onNewStateAttachHandlers();
|
|
StateCache stateCache = this.mStateCache;
|
|
if (stateCache != null) {
|
|
if (this.mDelayedApply) {
|
|
post(new Runnable() { // from class: androidx.constraintlayout.motion.widget.MotionLayout.4
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
MotionLayout.this.mStateCache.apply();
|
|
}
|
|
});
|
|
return;
|
|
} else {
|
|
stateCache.apply();
|
|
return;
|
|
}
|
|
}
|
|
MotionScene motionScene2 = this.mScene;
|
|
if (motionScene2 == null || motionScene2.mCurrentTransition == null || this.mScene.mCurrentTransition.getAutoTransition() != 4) {
|
|
return;
|
|
}
|
|
transitionToEnd();
|
|
setState(TransitionState.SETUP);
|
|
setState(TransitionState.MOVING);
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onRtlPropertiesChanged(int layoutDirection) {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene != null) {
|
|
motionScene.setRtl(isRtl());
|
|
}
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
void getAnchorDpDt(int mTouchAnchorId, float pos, float locationX, float locationY, float[] mAnchorDpDt) {
|
|
String resourceName;
|
|
HashMap<View, MotionController> hashMap = this.mFrameArrayList;
|
|
View viewById = getViewById(mTouchAnchorId);
|
|
MotionController motionController = hashMap.get(viewById);
|
|
if (motionController != null) {
|
|
motionController.getDpDt(pos, locationX, locationY, mAnchorDpDt);
|
|
float y = viewById.getY();
|
|
this.lastPos = pos;
|
|
this.lastY = y;
|
|
return;
|
|
}
|
|
if (viewById == null) {
|
|
resourceName = "" + mTouchAnchorId;
|
|
} else {
|
|
resourceName = viewById.getContext().getResources().getResourceName(mTouchAnchorId);
|
|
}
|
|
Log.w(TAG, "WARNING could not find view id " + resourceName);
|
|
}
|
|
|
|
public long getTransitionTimeMs() {
|
|
if (this.mScene != null) {
|
|
this.mTransitionDuration = r0.getDuration() / 1000.0f;
|
|
}
|
|
return (long) (this.mTransitionDuration * 1000.0f);
|
|
}
|
|
|
|
public void addTransitionListener(TransitionListener listener) {
|
|
if (this.mTransitionListeners == null) {
|
|
this.mTransitionListeners = new CopyOnWriteArrayList<>();
|
|
}
|
|
this.mTransitionListeners.add(listener);
|
|
}
|
|
|
|
public boolean removeTransitionListener(TransitionListener listener) {
|
|
CopyOnWriteArrayList<TransitionListener> copyOnWriteArrayList = this.mTransitionListeners;
|
|
if (copyOnWriteArrayList == null) {
|
|
return false;
|
|
}
|
|
return copyOnWriteArrayList.remove(listener);
|
|
}
|
|
|
|
public void fireTrigger(int triggerId, boolean positive, float progress) {
|
|
TransitionListener transitionListener = this.mTransitionListener;
|
|
if (transitionListener != null) {
|
|
transitionListener.onTransitionTrigger(this, triggerId, positive, progress);
|
|
}
|
|
CopyOnWriteArrayList<TransitionListener> copyOnWriteArrayList = this.mTransitionListeners;
|
|
if (copyOnWriteArrayList != null) {
|
|
Iterator<TransitionListener> it = copyOnWriteArrayList.iterator();
|
|
while (it.hasNext()) {
|
|
it.next().onTransitionTrigger(this, triggerId, positive, progress);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void fireTransitionChange() {
|
|
CopyOnWriteArrayList<TransitionListener> copyOnWriteArrayList;
|
|
if ((this.mTransitionListener == null && ((copyOnWriteArrayList = this.mTransitionListeners) == null || copyOnWriteArrayList.isEmpty())) || this.mListenerPosition == this.mTransitionPosition) {
|
|
return;
|
|
}
|
|
if (this.mListenerState != -1) {
|
|
TransitionListener transitionListener = this.mTransitionListener;
|
|
if (transitionListener != null) {
|
|
transitionListener.onTransitionStarted(this, this.mBeginState, this.mEndState);
|
|
}
|
|
CopyOnWriteArrayList<TransitionListener> copyOnWriteArrayList2 = this.mTransitionListeners;
|
|
if (copyOnWriteArrayList2 != null) {
|
|
Iterator<TransitionListener> it = copyOnWriteArrayList2.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);
|
|
}
|
|
CopyOnWriteArrayList<TransitionListener> copyOnWriteArrayList3 = this.mTransitionListeners;
|
|
if (copyOnWriteArrayList3 != null) {
|
|
Iterator<TransitionListener> it2 = copyOnWriteArrayList3.iterator();
|
|
while (it2.hasNext()) {
|
|
it2.next().onTransitionChange(this, this.mBeginState, this.mEndState, this.mTransitionPosition);
|
|
}
|
|
}
|
|
this.mIsAnimating = true;
|
|
}
|
|
|
|
protected void fireTransitionCompleted() {
|
|
int i;
|
|
CopyOnWriteArrayList<TransitionListener> copyOnWriteArrayList;
|
|
if ((this.mTransitionListener != null || ((copyOnWriteArrayList = this.mTransitionListeners) != null && !copyOnWriteArrayList.isEmpty())) && this.mListenerState == -1) {
|
|
this.mListenerState = this.mCurrentState;
|
|
if (this.mTransitionCompleted.isEmpty()) {
|
|
i = -1;
|
|
} else {
|
|
ArrayList<Integer> arrayList = this.mTransitionCompleted;
|
|
i = arrayList.get(arrayList.size() - 1).intValue();
|
|
}
|
|
int i2 = this.mCurrentState;
|
|
if (i != i2 && i2 != -1) {
|
|
this.mTransitionCompleted.add(Integer.valueOf(i2));
|
|
}
|
|
}
|
|
processTransitionCompleted();
|
|
Runnable runnable = this.mOnComplete;
|
|
if (runnable != null) {
|
|
runnable.run();
|
|
}
|
|
int[] iArr = this.mScheduledTransitionTo;
|
|
if (iArr == null || this.mScheduledTransitions <= 0) {
|
|
return;
|
|
}
|
|
transitionToState(iArr[0]);
|
|
int[] iArr2 = this.mScheduledTransitionTo;
|
|
System.arraycopy(iArr2, 1, iArr2, 0, iArr2.length - 1);
|
|
this.mScheduledTransitions--;
|
|
}
|
|
|
|
private void processTransitionCompleted() {
|
|
CopyOnWriteArrayList<TransitionListener> copyOnWriteArrayList;
|
|
if (this.mTransitionListener == null && ((copyOnWriteArrayList = this.mTransitionListeners) == null || copyOnWriteArrayList.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());
|
|
}
|
|
CopyOnWriteArrayList<TransitionListener> copyOnWriteArrayList2 = this.mTransitionListeners;
|
|
if (copyOnWriteArrayList2 != null) {
|
|
Iterator<TransitionListener> it2 = copyOnWriteArrayList2.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 CopyOnWriteArrayList<>();
|
|
}
|
|
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);
|
|
}
|
|
if (motionHelper.isDecorator()) {
|
|
if (this.mDecoratorsHelpers == null) {
|
|
this.mDecoratorsHelpers = new ArrayList<>();
|
|
}
|
|
this.mDecoratorsHelpers.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 progress) {
|
|
ArrayList<MotionHelper> arrayList = this.mOnShowHelpers;
|
|
if (arrayList != null) {
|
|
int size = arrayList.size();
|
|
for (int i = 0; i < size; i++) {
|
|
this.mOnShowHelpers.get(i).setProgress(progress);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setOnHide(float progress) {
|
|
ArrayList<MotionHelper> arrayList = this.mOnHideHelpers;
|
|
if (arrayList != null) {
|
|
int size = arrayList.size();
|
|
for (int i = 0; i < size; i++) {
|
|
this.mOnHideHelpers.get(i).setProgress(progress);
|
|
}
|
|
}
|
|
}
|
|
|
|
public int[] getConstraintSetIds() {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene == null) {
|
|
return null;
|
|
}
|
|
return motionScene.getConstraintSetIds();
|
|
}
|
|
|
|
public ConstraintSet getConstraintSet(int id) {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene == null) {
|
|
return null;
|
|
}
|
|
return motionScene.getConstraintSet(id);
|
|
}
|
|
|
|
public ConstraintSet cloneConstraintSet(int id) {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene == null) {
|
|
return null;
|
|
}
|
|
ConstraintSet constraintSet = motionScene.getConstraintSet(id);
|
|
ConstraintSet constraintSet2 = new ConstraintSet();
|
|
constraintSet2.clone(constraintSet);
|
|
return constraintSet2;
|
|
}
|
|
|
|
@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 stateId, ConstraintSet set) {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene != null) {
|
|
motionScene.setConstraintSet(stateId, set);
|
|
}
|
|
updateState();
|
|
if (this.mCurrentState == stateId) {
|
|
set.applyTo(this);
|
|
}
|
|
}
|
|
|
|
public void updateStateAnimate(int stateId, ConstraintSet set, int duration) {
|
|
if (this.mScene != null && this.mCurrentState == stateId) {
|
|
updateState(R.id.view_transition, getConstraintSet(stateId));
|
|
setState(R.id.view_transition, -1, -1);
|
|
updateState(stateId, set);
|
|
MotionScene.Transition transition = new MotionScene.Transition(-1, this.mScene, R.id.view_transition, stateId);
|
|
transition.setDuration(duration);
|
|
setTransition(transition);
|
|
transitionToEnd();
|
|
}
|
|
}
|
|
|
|
public void scheduleTransitionTo(int id) {
|
|
if (getCurrentState() == -1) {
|
|
transitionToState(id);
|
|
return;
|
|
}
|
|
int[] iArr = this.mScheduledTransitionTo;
|
|
if (iArr == null) {
|
|
this.mScheduledTransitionTo = new int[4];
|
|
} else if (iArr.length <= this.mScheduledTransitions) {
|
|
this.mScheduledTransitionTo = Arrays.copyOf(iArr, iArr.length * 2);
|
|
}
|
|
int[] iArr2 = this.mScheduledTransitionTo;
|
|
int i = this.mScheduledTransitions;
|
|
this.mScheduledTransitions = i + 1;
|
|
iArr2[i] = id;
|
|
}
|
|
|
|
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 milliseconds) {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene == null) {
|
|
Log.e(TAG, "MotionScene not defined");
|
|
} else {
|
|
motionScene.setDuration(milliseconds);
|
|
}
|
|
}
|
|
|
|
public MotionScene.Transition getTransition(int id) {
|
|
return this.mScene.getTransitionById(id);
|
|
}
|
|
|
|
int lookUpConstraintId(String id) {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene == null) {
|
|
return 0;
|
|
}
|
|
return motionScene.lookUpConstraintId(id);
|
|
}
|
|
|
|
String getConstraintSetNames(int id) {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene == null) {
|
|
return null;
|
|
}
|
|
return motionScene.lookUpConstraintName(id);
|
|
}
|
|
|
|
void disableAutoTransition(boolean disable) {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene == null) {
|
|
return;
|
|
}
|
|
motionScene.disableAutoTransition(disable);
|
|
}
|
|
|
|
private void fireTransitionStarted(MotionLayout motionLayout, int mBeginState, int mEndState) {
|
|
TransitionListener transitionListener = this.mTransitionListener;
|
|
if (transitionListener != null) {
|
|
transitionListener.onTransitionStarted(this, mBeginState, mEndState);
|
|
}
|
|
CopyOnWriteArrayList<TransitionListener> copyOnWriteArrayList = this.mTransitionListeners;
|
|
if (copyOnWriteArrayList != null) {
|
|
Iterator<TransitionListener> it = copyOnWriteArrayList.iterator();
|
|
while (it.hasNext()) {
|
|
it.next().onTransitionStarted(motionLayout, mBeginState, mEndState);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void viewTransition(int viewTransitionId, View... view) {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene != null) {
|
|
motionScene.viewTransition(viewTransitionId, view);
|
|
} else {
|
|
Log.e(TAG, " no motionScene");
|
|
}
|
|
}
|
|
|
|
public void enableViewTransition(int viewTransitionId, boolean enable) {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene != null) {
|
|
motionScene.enableViewTransition(viewTransitionId, enable);
|
|
}
|
|
}
|
|
|
|
public boolean isViewTransitionEnabled(int viewTransitionId) {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene != null) {
|
|
return motionScene.isViewTransitionEnabled(viewTransitionId);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public boolean applyViewTransition(int viewTransitionId, MotionController motionController) {
|
|
MotionScene motionScene = this.mScene;
|
|
if (motionScene != null) {
|
|
return motionScene.applyViewTransition(viewTransitionId, motionController);
|
|
}
|
|
return false;
|
|
}
|
|
}
|