2023-08-22 14:41:01 +02:00
|
|
|
package android.view;
|
|
|
|
|
|
2023-08-23 09:16:45 +02:00
|
|
|
import android.animation.Animator;
|
2023-08-22 14:41:01 +02:00
|
|
|
import android.animation.TimeInterpolator;
|
2025-02-10 18:15:38 +01:00
|
|
|
import android.animation.ValueAnimator;
|
2024-05-06 06:29:47 +02:00
|
|
|
import android.os.Handler;
|
2023-08-22 14:41:01 +02:00
|
|
|
|
|
|
|
|
public class ViewPropertyAnimator {
|
|
|
|
|
|
2023-10-08 17:51:41 +02:00
|
|
|
private View view;
|
2024-05-06 06:29:47 +02:00
|
|
|
private Animator.AnimatorListener listener;
|
|
|
|
|
private long startDelay;
|
|
|
|
|
private long duration;
|
2023-10-08 17:51:41 +02:00
|
|
|
|
|
|
|
|
public ViewPropertyAnimator(View view) {
|
|
|
|
|
this.view = view;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-22 14:41:01 +02:00
|
|
|
public void cancel() {}
|
|
|
|
|
|
|
|
|
|
public ViewPropertyAnimator setInterpolator(TimeInterpolator interpolator) {
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2023-08-23 09:16:45 +02:00
|
|
|
|
|
|
|
|
public ViewPropertyAnimator setListener(Animator.AnimatorListener listener) {
|
2024-05-06 06:29:47 +02:00
|
|
|
this.listener = listener;
|
2023-08-23 09:16:45 +02:00
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ViewPropertyAnimator alpha(float alpha) {
|
2023-10-08 17:51:41 +02:00
|
|
|
view.setAlpha(alpha);
|
2023-08-23 09:16:45 +02:00
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ViewPropertyAnimator setDuration(long duration) {
|
2024-05-06 06:29:47 +02:00
|
|
|
this.duration = duration;
|
2023-08-23 09:16:45 +02:00
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-06 06:29:47 +02:00
|
|
|
public ViewPropertyAnimator setStartDelay(long startDelay) {
|
|
|
|
|
this.startDelay = startDelay;
|
2023-08-23 09:16:45 +02:00
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-15 21:34:37 +01:00
|
|
|
public ViewPropertyAnimator x(float rotation) {
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ViewPropertyAnimator y(float rotation) {
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-01 12:30:27 +02:00
|
|
|
public ViewPropertyAnimator rotation(float rotation) {
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ViewPropertyAnimator translationX(float translationX) {
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ViewPropertyAnimator translationY(float translationY) {
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-21 22:49:36 +02:00
|
|
|
public ViewPropertyAnimator scaleX(float scaleX) {
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ViewPropertyAnimator scaleY(float scaleY) {
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-12 10:42:51 +01:00
|
|
|
public ViewPropertyAnimator translationXBy(float translationX) {
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-06 06:29:47 +02:00
|
|
|
public void start() {
|
|
|
|
|
new Handler().postDelayed(new Runnable() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
if (listener != null)
|
2025-02-10 18:15:38 +01:00
|
|
|
listener.onAnimationEnd(new ValueAnimator());
|
2024-05-06 06:29:47 +02:00
|
|
|
}
|
|
|
|
|
}, startDelay+duration);
|
|
|
|
|
}
|
2023-08-22 14:41:01 +02:00
|
|
|
}
|