title: ObjectAnimator onAnimationEnd listener is called before the animation finishes
body: <p>its weird and strange, but it seems like when I attach an AnimatorListener to an ObjectAnimator I use for animating fragment transactions, the callback gets actually called slightly before finish of the animation. 
  I use the listener to populate content into the fragment (from DB). The operation could take quite long time (~200ms) sometimes and when I do it in onCreate or so, it just destroys the animation, because the content is returned and rendered during the animation...there is lot of junk and stutter then..
  So when I add the populate call into the listener it works when also the DB select takes long time. But sometimes it's nearly instantaneous and in that case I have problem when the callback is called before the end of the animation. The gap between the callback and the actuall end is long enaugh to return the data from DB and again destroy fluidness of the animation:/</p>
  
  <p>Do you guys know, how to solve this issue? Below is nearly whole code of that Fragment.</p>
  
  <p>So basicaly there are two ways how to solve this issue..I can find completely another solution how to populate the content to the fragment without junky animations, or I can find a way how to solve the problem with the listener.</p>
  
  <p>And there is one extra way I dont like. I can create a Handler and call postDelayed..awful solution:) </p>
  
  <pre><code>public class ImportantContactsFragment extends Fragment {
  
  public static final String TAG = ImportantContactsFragment.class.getSimpleName();
  
  
  private ListView list;
  private Spinner departmentsSwitcher;
  private Spinner facultiesSwitcher;
  private ContactsAdapter adapter;
  private ArrayList&lt;ImportantContact&gt; currentListOfPeople;
  private int currentFaculty = 1;
  private Department currentDeparment = Department.STUDY_DEPARTMENT;
  private PullToRefreshAttacher mPullToRefreshAttacher;
  private boolean boot = true;
  private AsyncTask&lt;Integer, ArrayList&lt;ImportantContact&gt;, ArrayList&lt;ImportantContact&gt;&gt; task;
  
  
  private ArrayList&lt;Faculty&gt; faculties;
  
  
  private SpinnerAdapter departmentsSpinnerAdapter;
  private SpinnerAdapter facultiesSpinnerAdapter;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      currentListOfPeople = new ArrayList&lt;ImportantContact&gt;();
      faculties = new ArrayList&lt;Faculty&gt;(2);
      currentDeparment = Department.STUDY_DEPARTMENT;
  
      faculties.add(Faculty.getFEL());
      faculties.add(Faculty.getFIT());
  
      FrameLayout view = (FrameLayout) inflater.inflate(R.layout.important_contacts_fragment_list_layout, container, false);
      departmentsSwitcher = (Spinner) view.findViewById(R.id.departmentsSpinner);
      facultiesSwitcher = (Spinner) view.findViewById(R.id.facultiesSpinner);
  
  
      facultiesSpinnerAdapter = new ArrayAdapter&lt;Faculty&gt;(getActivity(), R.layout.spinner_text_view, faculties);
      departmentsSpinnerAdapter = new ArrayAdapter&lt;Department&gt;(getActivity(), R.layout.spinner_text_view, Department.values());
  
  
      departmentsSwitcher.setAdapter(departmentsSpinnerAdapter);
      facultiesSwitcher.setAdapter(facultiesSpinnerAdapter);
  
      list = (ListView) view.findViewById(R.id.list);
      adapter = new ContactsAdapter(getActivity(), R.layout.important_contacts_list_item, currentListOfPeople, list);
      list.setAdapter(adapter);
      list.requestFocus();
      departmentsSwitcher.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              currentDeparment = (Department) departmentsSpinnerAdapter.getItem(position);
              fillAdapterWithData(currentFaculty, currentDeparment);
          }
  
          @Override
          public void onNothingSelected(AdapterView&lt;?&gt; parent) {
          }
      });
      facultiesSwitcher.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              currentFaculty = position + 1;
              fillAdapterWithData(currentFaculty, currentDeparment);
          }
  
          @Override
          public void onNothingSelected(AdapterView&lt;?&gt; parent) {
  
          }
      });
  
      return view;
  }
  
  
  @Override
  public void onResume() {
      super.onResume();
      Tracking.onResume(this);
  //        fillAdapterWithData(currentFaculty, currentDeparment);
  
  }
  
  @Override
  public void onPause() {
      super.onPause();
      if (task != null) {
          task.cancel(true);
      }
  }
  
  
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
      super.onViewCreated(view, savedInstanceState);
  
  
  
  
  }
  
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
      getActivity().getActionBar().setTitle(getString(R.string.important_contacts));
  }
  
  public void fillAdapterWithData(int facultyId, Department department) {
      if (boot) {
          boot = false;
          return;
      }
      currentListOfPeople.clear();
      if (task != null) {
          task.cancel(true);
      }
      task = new AsyncTask&lt;Integer, ArrayList&lt;ImportantContact&gt;, ArrayList&lt;ImportantContact&gt;&gt;() {
          @Override
          protected ArrayList&lt;ImportantContact&gt; doInBackground(Integer... params) {
              return Controller.peopleDBController.getListOfImportantContactFromListOfContact(Controller.contactsDBController.searchRows(params[0], params[1]));
          }
  
  
          @Override
          protected void onPostExecute(ArrayList&lt;ImportantContact&gt; importantContacts) {
  
  //          adapter.notifyDataSetChanged();
              adapter.addAll(importantContacts);
  
  
          }
      };
  //        getActivity().setProgressBarVisibility(true);
  
      task.execute(facultyId, department.ordinal());
      adapter.addAll(Controller.peopleDBController.getListOfImportantContactFromListOfContact(Controller.contactsDBController.searchRows(facultyId, department.ordinal())));
  
  }
  
  @Override
  public Animator onCreateAnimator(int transit, boolean enter, int nextAnim) {
      if(enter){
          Animator animator = AnimatorInflater.loadAnimator(getActivity(), R.anim.fragment_slide_anim);
          if(animator!=null){
          animator.addListener(new Animator.AnimatorListener() {
              @Override
              public void onAnimationStart(Animator animation) {
  
              }
  
              @Override
              public void onAnimationEnd(Animator animation) {
  //                    fillAdapterWithData(currentFaculty, currentDeparment);
              }
  
              @Override
              public void onAnimationCancel(Animator animation) {
  
              }
  
              @Override
              public void onAnimationRepeat(Animator animation) {
  
              }
          });
          }
          return  animator;
      }
      else{
          return super.onCreateAnimator(transit, enter, nextAnim);
      }
  
  
  
  }
  </code></pre>