Added value animator button

Summary: This is usefull to make sure the ui debugger sees changes from value animators

Reviewed By: lblasa

Differential Revision: D40021838

fbshipit-source-id: 1fe18b79a89b43f286aa4e90aa6e850db3e887a5
This commit is contained in:
Luke De Feo
2022-10-10 04:13:06 -07:00
committed by Facebook GitHub Bot
parent 1fd1029a3d
commit 23ab1e9127
2 changed files with 42 additions and 3 deletions

View File

@@ -7,19 +7,21 @@
package com.facebook.flipper.sample; package com.facebook.flipper.sample;
import android.animation.ValueAnimator;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.view.animation.Animation; import android.view.animation.Animation;
import android.view.animation.AnimationUtils; import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.widget.Button; import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
public class AnimationsActivity extends Activity { public class AnimationsActivity extends Activity {
Button btnBlink, btnRotate, btnMove, btnBounce, btnSequential; Button btnBlink, btnRotate, btnMove, btnBounce, btnSequential, btnValueAnimator;
Animation animBlink, animRotate, animMove, animBounce, animSequential; Animation animBlink, animRotate, animMove, animBounce, animSequential;
TextView txtBlink, txtRotate, txtMove, txtBounce, txtSeq; TextView txtBlink, txtRotate, txtMove, txtBounce, txtSeq, txtValueAnimator;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@@ -27,17 +29,29 @@ public class AnimationsActivity extends Activity {
setContentView(R.layout.activity_animations); setContentView(R.layout.activity_animations);
btnBlink = findViewById(R.id.btnBlink); btnBlink = findViewById(R.id.btnBlink);
btnBlink.setTranslationX(500);
btnRotate = findViewById(R.id.btnRotate); btnRotate = findViewById(R.id.btnRotate);
btnMove = findViewById(R.id.btnMove); btnMove = findViewById(R.id.btnMove);
btnBounce = findViewById(R.id.btnBounce); btnBounce = findViewById(R.id.btnBounce);
btnSequential = findViewById(R.id.btnSequential); btnSequential = findViewById(R.id.btnSequential);
btnValueAnimator = findViewById(R.id.btnValueAnimator);
txtBlink = findViewById(R.id.txt_blink); txtBlink = findViewById(R.id.txt_blink);
txtRotate = findViewById(R.id.txt_rotate); txtRotate = findViewById(R.id.txt_rotate);
txtMove = findViewById(R.id.txt_move); txtMove = findViewById(R.id.txt_move);
txtBounce = findViewById(R.id.txt_bounce); txtBounce = findViewById(R.id.txt_bounce);
txtSeq = findViewById(R.id.txt_seq); txtSeq = findViewById(R.id.txt_seq);
txtValueAnimator = findViewById(R.id.txtValueAnimator);
btnValueAnimator.setOnClickListener(
b -> {
ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 300);
valueAnimator.addUpdateListener(
animator -> txtValueAnimator.setTranslationX((Float) animator.getAnimatedValue()));
valueAnimator.setInterpolator(new LinearInterpolator());
valueAnimator.setDuration(10000);
valueAnimator.start();
});
animBlink = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink);
btnBlink.setOnClickListener( btnBlink.setOnClickListener(
v -> { v -> {
txtBlink.setVisibility(View.VISIBLE); txtBlink.setVisibility(View.VISIBLE);

View File

@@ -12,6 +12,7 @@
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<LinearLayout <LinearLayout
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -103,6 +104,30 @@
android:id="@+id/txt_rotate" android:id="@+id/txt_rotate"
/> />
</LinearLayout> </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<Button
android:id="@+id/btnValueAnimator"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Value animator"
/>
<TextView
android:id="@+id/txtValueAnimator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Value Animator"
/>
</LinearLayout>
</LinearLayout> </LinearLayout>