I'm trying to add a chat feature in my Android app using Parse.com. I'm using a custom parseQueryAdapter. Problem is that when I send a message or when I receive a new message, my adapter does not update. I tried to add both
adapter.notifyDataSetInvalidated();
adapter.clear();
adapter.loadObjects();
adapter.notifyDataSetChanged();
in done callback and even in a dedicated refresh button.
This is how it works :
- My adapter is set to a custom listView and a query is set in adapter's constructor
- When I send a message, I create a new ParseObject (message in my database) and I save it to the conversation ParseObject.
- I save the message, then I save the conversation, both with saveInBackground(new SaveCallback() {...}) and saveEventually(new SaveCallback() {...})
- I try to refresh in the done callback
Each time, the listView displays same messages, and I have to come back to the previous fragment and re-open the chat fragment to see new messages...
I noticed that the getCount() method always return what is displayed.
Any idea of how I could refresh my listView's data ?
Thanks !