Skip to content
This repository has been archived by the owner on Dec 27, 2024. It is now read-only.

Commit

Permalink
fix setProgress(p, v) (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
jafu888 authored Nov 11, 2021
1 parent 1295ca9 commit 3b6031b
Show file tree
Hide file tree
Showing 6 changed files with 237 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<activity android:name=".CheckSetStates" />
<activity android:name=".Bug010" />
<activity android:name=".FullScreenActivity" />
<activity android:name=".CheckSetProgress" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -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);
}
}
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 = "";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/motionLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutDescription="@xml/verification_scene_800"
app:motionDebug="SHOW_PATH"

android:background="#FF003b60">



<ImageView
android:id="@+id/earth"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/earth"
app:layout_constraintVertical_bias="0.5"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"

/>

<androidx.constraintlayout.utils.widget.ImageFilterView
android:id="@+id/moon"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/moon"

app:layout_constraintCircleRadius="30dp"
app:layout_constraintCircleAngle="0"
app:layout_constraintCircle="@id/earth"
/>

<Button
android:id="@+id/b1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="35dp"
android:layout_marginLeft="35dp"
android:layout_marginTop="48dp"
android:text="progressP0"
android:onClick="progressP0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />


<Button
android:id="@+id/b2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="progressP1"
android:onClick="progressP1"
app:layout_constraintStart_toStartOf="@+id/b1"
app:layout_constraintTop_toBottomOf="@+id/b1" />
<Button
android:id="@+id/b3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="progressP0V0"
android:onClick="progressP0V0"
app:layout_constraintStart_toStartOf="@+id/b2"
app:layout_constraintTop_toBottomOf="@+id/b2" />

<Button
android:id="@+id/b4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="progressP0V1"
android:onClick="progressP0V1"
app:layout_constraintStart_toStartOf="@+id/b3"
app:layout_constraintTop_toBottomOf="@+id/b3" />

<Button
android:id="@+id/b5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="progressP1V0"
android:onClick="progressP1V0"
app:layout_constraintStart_toStartOf="@+id/b4"
app:layout_constraintTop_toBottomOf="@+id/b4" />

<Button
android:id="@+id/b6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="progressP1V_1"
android:onClick="progressP1V_1"
app:layout_constraintStart_toStartOf="@+id/b5"
app:layout_constraintTop_toBottomOf="@+id/b5" />

<Button
android:id="@+id/b7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="progressP5V1"
android:onClick="progressP5V1"
app:layout_constraintStart_toStartOf="@+id/b6"
app:layout_constraintTop_toBottomOf="@+id/b6" />

<Button
android:id="@+id/b8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="progressP5V_1"
android:onClick="progressP5V_1"
app:layout_constraintStart_toStartOf="@+id/b7"
app:layout_constraintTop_toBottomOf="@+id/b7" />

<Button
android:id="@+id/b9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="progressP5"
android:onClick="progressP5"
app:layout_constraintStart_toStartOf="@+id/b8"
app:layout_constraintTop_toBottomOf="@+id/b8" />



</androidx.constraintlayout.motion.widget.MotionLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto"
motion:defaultDuration="2000">


<ConstraintSet
android:id="@+id/end" >
<ConstraintOverride android:id="@+id/moon" motion:layout_constraintCircleRadius="300dp"/>

</ConstraintSet>

<ConstraintSet android:id="@+id/start">

</ConstraintSet>



<Transition
motion:constraintSetEnd="@+id/end"
motion:constraintSetStart="@+id/start"
motion:duration="1000"
motion:motionInterpolator="linear"
>
<OnSwipe />


</Transition>



</MotionScene>

0 comments on commit 3b6031b

Please sign in to comment.