package io.doist.recyclerviewext.flippers;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.view.View;

class DefaultFlipperAnimator extends FlipperAnimator {
    private boolean mAnimating = false;

    @Override
    public void animateFlip(final View outView, final View inView) {
        if (mAnimating) {
            outView.animate().cancel();
            inView.animate().cancel();
        }

        outView.animate()
               .alpha(0f)
               .setDuration(getFlipDuration())
               .setListener(new AnimatorListenerAdapter() {
                   @Override
                   public void onAnimationStart(Animator animation) {
                       outView.setVisibility(View.VISIBLE);
                       outView.setAlpha(1f);
                   }

                   @Override
                   public void onAnimationEnd(Animator animation) {
                       outView.setVisibility(View.GONE);
                       outView.setAlpha(1f);
                   }
               })
               .withLayer();

        inView.animate()
              .alpha(1f)
              .setDuration(getFlipDuration())
              .setListener(new AnimatorListenerAdapter() {
                  @Override
                  public void onAnimationStart(Animator animation) {
                      inView.setVisibility(View.VISIBLE);
                      inView.setAlpha(0f);
                  }

                  @Override
                  public void onAnimationEnd(Animator animation) {
                      inView.setAlpha(1f);
                      mAnimating = false;
                  }
              })
              .withLayer();

        mAnimating = true;
    }

    @Override
    public boolean isAnimating() {
        return mAnimating;
    }
}

@@ -436,32 +436,107 @@
 l();%0A        %7D%0A%0A
+        outView.setVisibility(View.VISIBLE);%0A        outView.setAlpha(1f);%0A
         outView.
@@ -537,32 +537,32 @@
 tView.animate()%0A
-
                .
@@ -682,234 +682,8 @@
 ) %7B%0A
-                   @Override%0A                   public void onAnimationStart(Animator animation) %7B%0A                       outView.setVisibility(View.VISIBLE);%0A                       outView.setAlpha(1f);%0A                   %7D%0A%0A
     
@@ -938,32 +938,105 @@
  .withLayer();%0A%0A
+        inView.setVisibility(View.VISIBLE);%0A        inView.setAlpha(0f);%0A
         inView.a
@@ -1107,32 +1107,32 @@
 FlipDuration())%0A
+
               .s
@@ -1178,227 +1178,8 @@
 ) %7B%0A
-                  @Override%0A                  public void onAnimationStart(Animator animation) %7B%0A                      inView.setVisibility(View.VISIBLE);%0A                      inView.setAlpha(0f);%0A                  %7D%0A%0A
     

Fix default flipper animations