diff --git a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/MotionLayout.java b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/MotionLayout.java index aa956fdfb..43b681301 100644 --- a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/MotionLayout.java +++ b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/MotionLayout.java @@ -38,6 +38,7 @@ import android.view.VelocityTracker; import android.view.View; import android.view.ViewGroup; +import android.view.animation.DecelerateInterpolator; import android.view.animation.Interpolator; import android.widget.TextView; @@ -1590,7 +1591,9 @@ public void setProgress(float pos, float velocity) { setProgress(pos); setState(TransitionState.MOVING); mLastVelocity = velocity; - animateTo(1); + if (velocity != 0.0f) { + animateTo(velocity>0?1:0); + } } /////////////////////// use to cache the state diff --git a/projects/MotionLayoutVerification/app/src/main/AndroidManifest.xml b/projects/MotionLayoutVerification/app/src/main/AndroidManifest.xml index b46c6814b..1b8d4b634 100644 --- a/projects/MotionLayoutVerification/app/src/main/AndroidManifest.xml +++ b/projects/MotionLayoutVerification/app/src/main/AndroidManifest.xml @@ -42,6 +42,7 @@ + diff --git a/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/CheckSetProgress.java b/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/CheckSetProgress.java new file mode 100644 index 000000000..ac6d07c12 --- /dev/null +++ b/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/CheckSetProgress.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.support.constraint.app; + +import android.content.Context; +import android.os.Bundle; +import android.util.Log; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.constraintlayout.motion.widget.Debug; +import androidx.constraintlayout.motion.widget.MotionLayout; +import androidx.constraintlayout.motion.widget.TransitionAdapter; + +/** + * Test transitionToState bug + */ +public class OnCreateTransiton extends AppCompatActivity { + private static final String TAG = "CustomSwipeClick"; + String layout_name; + MotionLayout mMotionLayout; + + @Override + protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Bundle extra = getIntent().getExtras(); + String prelayout = extra.getString(Utils.KEY); + layout_name = prelayout; + Context ctx = getApplicationContext(); + int id = ctx.getResources().getIdentifier(prelayout, "layout", ctx.getPackageName()); + setContentView(id); + mMotionLayout = Utils.findMotionLayout(this); + mMotionLayout.transitionToState(R.id.end); + mMotionLayout.setTransitionListener(new TransitionAdapter() { + @Override + public void onTransitionCompleted(MotionLayout motionLayout, int currentId) { + Log.v(TAG, Debug.getLoc()+" "); + } + + @Override + public void onTransitionTrigger(MotionLayout motionLayout, int triggerId, boolean positive, float progress) { + Log.v(TAG, Debug.getLoc()+" "+progress); + if (progress <= 0.001 || progress >= 0.999) { + Debug.logStack(TAG, "",19); + } + } + }); + } + +} diff --git a/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/VerificationActivity.java b/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/VerificationActivity.java index 71211f291..2f5a4f8fb 100644 --- a/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/VerificationActivity.java +++ b/projects/MotionLayoutVerification/app/src/main/java/android/support/constraint/app/VerificationActivity.java @@ -96,6 +96,7 @@ public class VerificationActivity extends AppCompatActivity implements View.OnCl activity_map.put("bug_004", OnCreateTransiton.class); activity_map.put("verification_503", FullScreenActivity.class); activity_map.put("v_000", ParseLayouts.class); + activity_map.put("verification_800", CheckSetProgress.class); // activity_map.put("verification_037", RotationToolbar.class); @@ -107,7 +108,7 @@ public class VerificationActivity extends AppCompatActivity implements View.OnCl private static boolean REVERSE = false; - private static final String RUN_FIRST = (true) ? "verification_131" : "bug_005"; + private static final String RUN_FIRST = (true) ? "verification_800" : "bug_005"; private final String LAYOUTS_MATCHES = "v.*_.*"; private static String SHOW_FIRST = ""; diff --git a/projects/MotionLayoutVerification/app/src/main/res/layout/verification_800.xml b/projects/MotionLayoutVerification/app/src/main/res/layout/verification_800.xml new file mode 100644 index 000000000..33c65616e --- /dev/null +++ b/projects/MotionLayoutVerification/app/src/main/res/layout/verification_800.xml @@ -0,0 +1,134 @@ + + + + + + + + + +