I am implementing group chat using Parse in my Android Application . and the scene is , when sender sends any message to group , i am pinning this message with a label in parse local data store at sender side. and i also put auto refreshing method, which retrieving data from parse local data store every second. but the problem is when i am calling pinInBackground method , data is not being populating in ListView using adapter. but when i call saveInBackground and pinInBackground method together then it is being populating.
I check that size of data is also increasing in localdatastore. but not reflecting in ListView.
I am using following method for retrieving data from localdatastore -
private ArrayList<ParseObject> mMessages;
private MyCustomAdapter1 mAdapter;
private ListView lvChat;
private boolean mFirstLoad;
//in onCreate() method
mMessages = new ArrayList<ParseObject>();
lvChat.setTranscriptMode(1);
mFirstLoad = true;
mAdapter = new MyCustomAdapter1(getActivity(), mMessages);
lvChat.setAdapter(mAdapter);
private void receiveChatMessages() {
ParseQuery<ParseObject> query = ParseQuery.getQuery("ChatMessages");
query.orderByAscending("createdAt");
query.fromPin("myLable");
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> list, ParseException e) {
if (e == null) {
mMessages.clear();
mMessages.addAll(list);
mAdapter.notifyDataSetChanged(); // update adapter
// Scroll to the bottom of the list on initial load
if (mFirstLoad) {
lvChat.setSelection(mAdapter.getCount() - 1);
mFirstLoad = false;
}
} else {
Log.d("message", "Error: " + e.getMessage());
}
}
});
}
Question - What would be the reason that saveInBackground method is being reflecing data but pinInBackground is not?
Thanks in advance!