LoginSignup
0
0

More than 5 years have passed since last update.

Animation.AnimationListenerでいちいち3つもメソッドをimplするのは面倒くさい

Posted at

interface Animation.AnimationListener をimplementsすると onAnimationStart(), onAnimationRepeat(), onAnimationEnd() の3つのメソッドを実装しないといけないわけですが、このなかでよく使うのは onAnimationEnd() じゃないですか。
そこで以下の様な abstract class を定義して onAnimationEnd() だけ実装すればいいようにしているんですが、こんなもんですか。他にいい方法はありませんか。

import android.view.animation.Animation;

/**
 * The same as AnimationListener but only onAnimationEnd(Animation) is required to implement.
 */
public abstract class AnimationEndListener implements Animation.AnimationListener {

    abstract public void onAnimationEnd(Animation animation);

    @Override
    public void onAnimationRepeat(Animation animation) {
        // do nothing
    }

    @Override
    public void onAnimationStart(Animation animation) {
        // do nothing
    }
}
0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0