Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,8 @@ public class MotionLayout extends ConstraintLayout implements
private boolean mInLayout = false;
private StateCache mStateCache;
private Runnable mOnComplete = null;
private int[]mScheduledTransitionTo = null;
int mScheduledTransitions = 0;

MotionController getMotionController(int mTouchAnchorId) {
return mFrameArrayList.get(findViewById(mTouchAnchorId));
Expand Down Expand Up @@ -4002,6 +4004,11 @@ protected void fireTransitionCompleted() {
mOnComplete.run();
}

if (mScheduledTransitionTo != null && mScheduledTransitions > 0) {
transitionToState(mScheduledTransitionTo[0]);
System.arraycopy(mScheduledTransitionTo,1,mScheduledTransitionTo,0,mScheduledTransitionTo.length-1);
mScheduledTransitions--;
}
}

private void processTransitionCompleted() {
Expand Down Expand Up @@ -4205,6 +4212,25 @@ public void updateStateAnimate(int stateId, ConstraintSet set, int duration) {
}
}

/**
* on completing the current transition, transition to this state.
*
* @param id
*/
public void scheduleTransitionTo(int id) {
if (getCurrentState() == -1) {
transitionToState(id);
} else {
if (mScheduledTransitionTo == null) {
mScheduledTransitionTo = new int[4];
} else if (mScheduledTransitionTo.length <= mScheduledTransitions) {
mScheduledTransitionTo =
Arrays.copyOf(mScheduledTransitionTo, mScheduledTransitionTo.length * 2);
}
mScheduledTransitionTo[mScheduledTransitions++] = id;
}
}

/**
* Not sure we want this
* @hide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ public class VerificationActivity extends AppCompatActivity implements View.OnCl
String s = AppCompatActivity.class.getName();

private static boolean REVERSE = false;


private final String RUN_FIRST = "verification_309";
private final String LAYOUTS_MATCHES = "verification_\\d+";

private static String SHOW_FIRST = "";
MotionLayout mMotionLayout;
private Flow mFlow;
Expand Down Expand Up @@ -541,14 +541,19 @@ public void addToFlow2(View view) {
* @param view
*/
public void twistViews(View view) {
rotate ++;
rotate++;
int current = mMotionLayout.getCurrentState();
ConstraintSet cset = mMotionLayout.cloneConstraintSet(current);
int[] id = {R.id.button1, R.id.button2, R.id.button3, R.id.button4, R.id.button5, R.id.button6};
for (int i : id) {
cset.setRotation(i, ((rotate &1)==0) ? 90 : 0);
cset.setRotation(i, ((rotate & 1) == 0) ? 90 : 0);
}
int r = (rotate + 1);
String str = (((r & 1) == 0) ? "rot 90 " : "rot 0 ") +
(((r & 2) == 0) ? "then start" : "then end");
((Button) view).setText(str);
mMotionLayout.updateStateAnimate(current, cset, 200);
mMotionLayout.scheduleTransitionTo(((rotate & 2) == 0) ? R.id.start : R.id.end);
}

interface Test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2"
android:layout_marginTop="50dp"
app:layout_constraintStart_toStartOf="@id/button1"
app:layout_constraintTop_toBottomOf="@id/button1" />

Expand All @@ -31,6 +32,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3"
android:layout_marginTop="50dp"
app:layout_constraintStart_toStartOf="@id/button2"
app:layout_constraintTop_toBottomOf="@id/button2" />

Expand All @@ -39,6 +41,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4"
android:layout_marginTop="50dp"
app:layout_constraintStart_toStartOf="@id/button3"
app:layout_constraintTop_toBottomOf="@id/button3" />

Expand All @@ -47,22 +50,22 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5"
app:layout_constraintStart_toStartOf="@id/button4"
app:layout_constraintStart_toEndOf="@id/button4"
app:layout_constraintTop_toBottomOf="@id/button4" />

<Button
android:id="@+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6"
app:layout_constraintStart_toStartOf="@id/button5"
app:layout_constraintStart_toEndOf="@id/button5"
app:layout_constraintTop_toBottomOf="@id/button5" />

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="animatedChange"
android:text="test updateStateAnimate and scheduleTransitionTo"
android:onClick="twistViews"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down