1

I'm using Parse.com with Android to import some data and fill a listview with it. I'm having some trouble with asynchronicity.

I've got a class called DataHandler which when instantiated imports the data from a database and puts it into an arraylist. Then, in the fragment where the listview is, I create a new Datahandler and get the ArrayList from it. Then I fill the listview with this array.The thing is that I don't know where to do this last thing.

I need to somehow wait for the data to be imported into the arraylist before I fill the listview with the information. If the ParseQuery was in the fragment I used, I could just use a callback method, but its in a whole different class, and its used several times for several other fragments. What way is there to only call the logic to fill the listview (creating and setting the adapter) when I know the arraylist has been initialized, without removing the DataHandler class?

1 Answer 1

1

I would recommend Otto event bus as solution: you post events with data to be transferred and write code to receive it asynchronously in different classes. Solves many problems with in-code communication. http://square.github.io/otto/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.