title: Is creating a custom animation class for controlling animations a good practice?
body: <pre><code>Android studio 3.4.1
  </code></pre>
  
  <p>Creating a custom animation class for controlling animations</p>
  
  <p>I have the following interface for starting, stopping, and checking if the animation is running</p>
  
  <pre><code>interface AnimationController {
      fun start()
      fun isRunning(): Boolean
      fun stop()
  }
  </code></pre>
  
  <p>The implemetation</p>
  
  <pre><code>class AnimationControllerImp : AnimationController {
  
      private companion object {
          const val START_DELAY = 500L
          const val DURATION = 400L
      }
  
      private val animationSet by lazy {
          AnimatorSet()
      }
  
      override fun isRunning() = animationSet.isRunning
  
      override fun stop() {
          animationSet.end()
      }
  
      override fun start() {
          val textAnimator = ValueAnimator.ofObject(ArgbEvaluatorCompat(), 0, 1)
          textAnimator.addUpdateListener { animation -&gt;
              /* do some animation here */
          }
  
          val backgroundAnimator = ValueAnimator.ofFloat(0, 1)
          backgroundAnimator.addUpdateListener { animation -&gt;
              /* do some animation here */
          }
  
          animationSet.startDelay = START_DELAY
          animationSet.duration = DURATION
          animationSet.interpolator = AccelerateInterpolator()
          animationSet.playTogether(textAnimator, backgroundAnimator)
          animationSet.start()
          animationSet.addListener(object: Animator.AnimatorListener {
              override fun onAnimationRepeat(animation: Animator?) {}
  
              override fun onAnimationEnd(animation: Animator?) {
  
              }
  
              override fun onAnimationCancel(animation: Animator?) {
  
              }
  
              override fun onAnimationStart(animation: Animator?) {
  
              }    
          })
      }
  }
  </code></pre>
  
  <p>Then a client could use this class as follows</p>
  
  <pre><code>fun startPlayTogether() {
      val animationController: AnimationController = AnimationControllerImp()
      if(animationController.isRunning) {
          animationController.stop()    
      }
      else {
          animationController.start()
      }
  }
  </code></pre>
  
  <p>Is this is a good design for a custom animation class?</p>