0

I have extended RoboAsyncTask implemented all needed methods, but while data loading it's displaying default loading animation.

I have made my custom loading dialog but default loading animation on fragment still displaying. It is possible to remove it? Or change animation image?

public class ContactFragment extends RoboSherlockListFragment {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    ContactLoadingTask contactLoadingTask = new ContactLoadingTask(this.getActivity());
    contactLoadingTask.execute();
}


private class ContactLoadingTask extends RoboAsyncTask<List<Contact>> {

    @Inject
    ContactParser contactParser;

    protected ContactLoadingTask(Context context) {
        super(context);
    }

    @Override
    public List<Contact> call() throws Exception {
        return contactParser.getContacts();
    }

    @Override
    protected void onSuccess(List<Contact> contacts) throws Exception {
        setListAdapter(new ContactArrayAdapter(ContactFragment.this.getActivity(), contacts));
    }

}

}

Launching this code i see loading animation on my fragment before contacts are loaded

1 Answers1

0

RoboAsyncTask does not deal with any animation, or anything visible by the user. It only execute code in a background thread.

I think the animation you're talking about is played automatically by ListFragment when you call setListAdapter(), as stated in the setListShown() method documentation

Sadly it doesn't seem you can override this animation, so you might have to use a standard Fragment and manage the ListView yourself. You can look at the source code of ListFragment to see how this is done


If you just want to disable the animation, you might try to use setListShownNoAnimation just before setting your list adapter:

@Override
protected void onSuccess(List<Contact> contacts) throws Exception {
    setListShownNoAnimation(true);
    setListAdapter(new ContactArrayAdapter(ContactFragment.this.getActivity(), contacts));
}
nicopico
  • 3,606
  • 1
  • 28
  • 30