title: ViewPropertyAnimator loops unexpectedly
body: <p>I'm trying to animate a set of buttons such that they disappear sequentually on click, then performs an action based on the button clicked. The action is assigned to the animation listener which triggers on animation end. This works fine. </p>
  
  <p>The problem is that I want the buttons to reappear sequentually when the activity resumes. For some reason the action assigned to the animation listener re-triggers even after setting the animation to null. What am I missing?</p>
  
  <pre><code>public class MainMenu extends ActionBarActivity {
  
  private MenuItemBuilder menuItemBuilder;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main_menu);
  
      init();
  }
  
  private void init() {
      menuItemBuilder = new MenuItemBuilder(this);
  }
  
  @Override
  protected void onResume() {
      super.onResume();
  
      if (menuItemBuilder != null) {
          menuItemBuilder.animateAllViewsEnter();
      }
  }
  </code></pre>
  
  <p>Below is the menu builder. I have three menu items: Load database, price list, and about. This class manages all the animations.</p>
  
  <pre><code>public MenuItemBuilder(Context context) {
      this.context = context;
  
      init();
  }
  
  private void init() {
      initLoadDatabase();
      initPriceList();
      initAbout();
  }
  
  private View getViewFromId(int res) {
      return ((Activity) context).findViewById(res);
  }
  
  private ImageButton getImageButtonFromId(int res) {
      return (ImageButton) ((Activity) context).findViewById(res);
  }
  
  private void initLoadDatabase() {
      final ImageButton button = getImageButtonFromId(R.id.imageLoadDatabase);
      button.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              animateAllViewsExit(ButtonType.LOAD_DATABASE);
          }
      });
  }
  
  private void initPriceList() {
      final ImageButton button = getImageButtonFromId(R.id.imagePriceList);
      button.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              animateAllViewsExit(ButtonType.PRICE_LIST);
          }
      });
  }
  
  private void initAbout() {
      final ImageButton button = getImageButtonFromId(R.id.imageAbout);
      button.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              animateAllViewsExit(ButtonType.ABOUT);
          }
      });
  }
  
  private List&lt;View&gt; getAnimatedViews() {
      List&lt;View&gt; viewList = new ArrayList&lt;&gt;();
      viewList.add(getViewFromId(R.id.imageLoadDatabase));
      viewList.add(getViewFromId(R.id.priceListContainer));
      viewList.add(getViewFromId(R.id.imageAbout));
  
      return viewList;
  }
  
  public void animateAllViewsEnter() {
      List&lt;View&gt; viewList = getAnimatedViews();
      for (int i = 0; i &lt; viewList.size(); i++) {
          View view = viewList.get(i);
          view.animate()
                  .setStartDelay((viewList.size() - i) * 250)
                  .alpha(1.0f);
      }
  }
  
  private void animateAllViewsExit(ButtonType buttonType) {
      List&lt;View&gt; viewList = getAnimatedViews();
      for (int i = 0; i &lt; viewList.size(); i++) {
          View view = viewList.get(i);
          ViewPropertyAnimator animator = view.animate()
                  .setStartDelay(i * 250)
                  .alpha(0.0f);
  
          if (i == viewList.size() - 1) {
              lastAnimation = animator;
          }
      }
  
      setAnimationAction(buttonType);
  }
  
  private void setAnimationAction(final ButtonType buttonType) {
      if (lastAnimation != null) {
          lastAnimation.setListener(new Animator.AnimatorListener() {
              @Override
              public void onAnimationStart(Animator animation) {
              }
  
              @Override
              public void onAnimationEnd(Animator animation) {
                  performAction(buttonType);
                  lastAnimation = null;
              }
  
              @Override
              public void onAnimationCancel(Animator animation) {
              }
  
              @Override
              public void onAnimationRepeat(Animator animation) {
              }
          });
      }
  }
  
  private void performAction(ButtonType buttonType) {
      switch (buttonType) {
          case LOAD_DATABASE:
              // TODO to be done
              break;
          case PRICE_LIST:
              context.startActivity(new Intent(context, PriceList.class));
              break;
          case ABOUT:
              context.startActivity(new Intent(context, About.class));
              break;
      }
  }
  
  private enum ButtonType {
      LOAD_DATABASE,
      PRICE_LIST,
      ABOUT
  }
  </code></pre>