title: Fragment flashes after removal and animation ends
body: <p>I've been trying to get a fragment to be inserted and removed from my activity with a circular reveal animation. I found this demo repo <a href="https://github.com/ferdy182/Android-CircularRevealFragment" rel="nofollow">here</a> that does exactly this. The only change I made was to have the fragment removed on a button click, instead of the fragment touched listener.</p>
  
  <p>The problem is, after removal using the button, when the animation ends, I see the fragment flash for a second. The flash doesnt happen if I'm removing the fragment using the onTouch listener: <a href="https://www.youtube.com/watch?v=9MBx6kLKZM0" rel="nofollow">YouTube link</a></p>
  
  <p>A few observations:<br>
  - If I run the code on my mobile device, then the flash only happens if I'm removing the fragment using the button. No flash occurs when onFragmentTouch is called.<br>
  - If I'm running this on the emulator, then I can see it flash on both, the button press and the fragment touch.  </p>
  
  <p>To simplify things, my onFragmentTouch listener is simply calling a function <code>remove</code> that actually removes the fragment. This same function is also called by the button, in its XML.
  I can't understand why this is happening. Code for reference.</p>
  
  <p>Add fragment, within main activity:</p>
  
  <pre><code>public void addFragment(View v)
      {
          int randomColor =
                  Color.argb(255, (int)(Math.random() * 255), (int)(Math.random() * 255), (int)(Math.random() * 255));
          mfragment = CircularRevealingFragment.newInstance(20, 20, randomColor);
          getFragmentManager().beginTransaction().add(R.id.container, mfragment).commit();
      }
  </code></pre>
  
  <p>Function to remove fragment, also within main activity:</p>
  
  <pre><code>public void remove(View v){
          Animator unreveal = mfragment.prepareUnrevealAnimator(0, 0);
          unreveal.addListener(new Animator.AnimatorListener()
          {
              @Override
              public void onAnimationEnd(Animator animation)
              {
                  getFragmentManager().beginTransaction().remove(mfragment).commit();
              }
              //hiding other overridden function.
          });
          unreveal.start();
      }
  </code></pre>
  
  <p>The CircularRevealingFragment is pretty straightforward, with mostly everything being the same as in that github project. The unreveal animator:</p>
  
  <pre><code>public Animator prepareUnrevealAnimator(float cx, float cy)
      {
          int radius = getEnclosingCircleRadius(getView(), (int)cx, (int)cy);
          Animator anim = ViewAnimationUtils.createCircularReveal(getView(), (int) cx, (int) cy, radius, 0);
          anim.setInterpolator(new AccelerateInterpolator(2f));
          anim.setDuration(1000);
          return anim;
      }
  </code></pre>
  
  <p>Can anyone explain the behavior shown in the video?</p>