code: private long getDuration(@NonNull final View animatedView,
                               @NonNull final DialogAnimation animation) {
          double scale = 1;
  
          if (animatedView.getAnimation() != null) {
              scale = (double) (System.currentTimeMillis() -
                      animatedView.getAnimation().getStartTime()) /
                      (double) animatedView.getAnimation().getDuration();
              animatedView.getAnimation().cancel();
          }
  
          return Math.round(animation.getDuration() * scale);
      }
docs: Returns the duration, which should be used for an animation, depending on whether a previous
  animation is still running, or not.
  
  @param animatedView
  The animated view as an instance of the class {@link View}. The view may not be null
  @param animation
  The animation as an instance of the class {@link DialogAnimation}. The animation may
  not be null
  @return The duration, which used for the given animation, in milliseconds as a {@link Long}
  value