This repository was archived by the owner on Dec 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 173
fix relative motion support #632
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,8 @@ | |
import androidx.constraintlayout.core.motion.utils.KeyCache; | ||
import androidx.constraintlayout.core.motion.utils.KeyCycleOscillator; | ||
import androidx.constraintlayout.core.motion.utils.KeyFrameArray; | ||
import androidx.constraintlayout.core.motion.utils.NonNull; | ||
import androidx.constraintlayout.core.motion.utils.Nullable; | ||
import androidx.constraintlayout.core.motion.utils.Rect; | ||
import androidx.constraintlayout.core.motion.utils.SplineSet; | ||
import androidx.constraintlayout.core.motion.utils.TimeCycleSplineSet; | ||
|
@@ -78,9 +80,9 @@ public class Motion implements TypedValues { | |
private static final boolean DEBUG = false; | ||
private static final boolean FAVOR_FIXED_SIZE_VIEWS = false; | ||
MotionWidget mView; | ||
int mId; | ||
public String mId; | ||
String mConstraintTag; | ||
private int mCurveFitType = UNSET; | ||
private int mCurveFitType = CurveFit.SPLINE; | ||
private MotionPaths mStartMotionPath = new MotionPaths(); | ||
private MotionPaths mEndMotionPath = new MotionPaths(); | ||
|
||
|
@@ -125,7 +127,7 @@ public class Motion implements TypedValues { | |
private float mQuantizeMotionPhase = Float.NaN; | ||
private DifferentialInterpolator mQuantizeMotionInterpolator = null; | ||
private boolean mNoMovement = false; | ||
|
||
Motion mRelativeMotion; | ||
/** | ||
* Get the view to pivot around | ||
* | ||
|
@@ -237,16 +239,23 @@ public float getFinalHeight() { | |
* | ||
* @return the view id of the view this is in polar mode to or -1 if not in polar | ||
*/ | ||
public int getAnimateRelativeTo() { | ||
@Nullable | ||
public String getAnimateRelativeTo() { | ||
return mStartMotionPath.mAnimateRelativeTo; | ||
} | ||
|
||
/** | ||
* @TODO: add description | ||
* set up the motion to be relative to this other motionController | ||
*/ | ||
public void setupRelative(Motion motionController) { | ||
mStartMotionPath.setupRelative(motionController, motionController.mStartMotionPath); | ||
mEndMotionPath.setupRelative(motionController, motionController.mEndMotionPath); | ||
mRelativeMotion = motionController; | ||
} | ||
private void setupRelative() { | ||
if (mRelativeMotion == null) { | ||
return; | ||
} | ||
mStartMotionPath.setupRelative(mRelativeMotion, mRelativeMotion.mStartMotionPath); | ||
mEndMotionPath.setupRelative(mRelativeMotion, mRelativeMotion.mEndMotionPath); | ||
} | ||
|
||
public float getCenterX() { | ||
|
@@ -673,6 +682,8 @@ public void setup(int parentWidth, | |
HashSet<String> cycleAttributes = new HashSet<>(); // attributes we need to oscillate | ||
HashMap<String, Integer> interpolation = new HashMap<>(); | ||
ArrayList<MotionKeyTrigger> triggerList = null; | ||
|
||
setupRelative(); | ||
if (DEBUG) { | ||
if (mKeyList == null) { | ||
Utils.log(TAG, ">>>>>>>>>>>>>>> mKeyList==null"); | ||
|
@@ -934,6 +945,7 @@ public void setup(int parentWidth, | |
mSpline[i + 1] = CurveFit.get(mCurveFitType, timePoints, splinePoints); | ||
} | ||
|
||
// Spline for positions | ||
mSpline[0] = CurveFit.get(mCurveFitType, timePoint, splineData); | ||
// --------------------------- SUPPORT ARC MODE -------------- | ||
if (points[0].mPathMotionArc != UNSET) { | ||
|
@@ -1722,7 +1734,10 @@ public boolean setValue(int id, String value) { | |
mQuantizeMotionInterpolator = getInterpolator(SPLINE_STRING, value, 0); | ||
return true; | ||
} | ||
|
||
if ( MotionType.TYPE_ANIMATE_RELATIVE_TO == id) { | ||
jafu888 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
mStartMotionPath.mAnimateRelativeTo = value; | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
|
@@ -1763,4 +1778,9 @@ public void setStaggerOffset(float staggerOffset) { | |
public float getMotionStagger() { | ||
return mMotionStagger; | ||
} | ||
|
||
public void setIdString(String stringId) { | ||
mId = stringId; | ||
mStartMotionPath.mId = mId; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about |
||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.