0

not load chat history

Please help I need to solve it so much.

Try by this code for save chat may be this I am not sure:

private void retrievemessage() {
    QBMessageGetBuilder messageGetBuilder = new QBMessageGetBuilder();
    messageGetBuilder.setLimit(500);

    if (qbChatDialog != null)
    {
        QBRestChatService.getDialogMessages(qbChatDialog,messageGetBuilder).performAsync(new QBEntityCallback<ArrayList<QBChatMessage>>() {
            @Override
            public void onSuccess(ArrayList<QBChatMessage> qbChatMessages, Bundle bundle) {
                QBChatMessagesHolder.getInstance().putmessages(qbChatDialog.getDialogId(),qbChatMessages);
                adapter=new ChatMessageAdapter(getBaseContext(),qbChatMessages);
                listchatmessage.setAdapter(adapter);
                adapter.notifyDataSetChanged();
            }

            @Override
            public void onError(QBResponseException e) {
                Log.e("ERROR",""+e.getMessage());

            }
        });
    }

}

and its my holder

public class QBChatMessagesHolder {
private static QBChatMessagesHolder instance;
private HashMap<String,ArrayList<QBChatMessage>> qbchatmessagearray;

public static synchronized QBChatMessagesHolder getInstance() {
    QBChatMessagesHolder qbChatMessagesHolder;
    synchronized (QBChatMessagesHolder.class) {
        if (instance == null)
            instance = new QBChatMessagesHolder();
            qbChatMessagesHolder = instance;
    }
    return qbChatMessagesHolder;
}
private QBChatMessagesHolder()
{
this.qbchatmessagearray=new HashMap<>();

}
public void putmessages(String dialogId,ArrayList<QBChatMessage> qbChatMessages)
{
    this.qbchatmessagearray.put(dialogId,qbChatMessages);
}
public void putmessage(String dialogId,QBChatMessage qbChatMessage)
{
    ArrayList<QBChatMessage> lstResult=new ArrayList<>();
    qbchatmessagearray.get(dialogId);
    lstResult.add(qbChatMessage);
    ArrayList<QBChatMessage> lstAdded= new ArrayList(lstResult.size());
    lstAdded.addAll(lstResult);
    putmessages(dialogId,lstAdded);
}

public ArrayList<QBChatMessage> getChatMessageByDialogId(String dialogId)
{
    return (ArrayList<QBChatMessage>)this.qbchatmessagearray.get(dialogId);
}
}

I think my problem is form lstresult.

My message go to history but just shows last message

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
dornadev
  • 1
  • 1
  • 8
  • You have to spend some time to clarify your question, otherwise people would downvote your question and you won't get any answers. – onur güngör May 27 '17 at 07:36
  • In your code you are downloading messages saving in holder but sending to adapter not from holder but only loaded messages. Did you check count downloaded messages? Do you send messages with parameter qbChatMessage.setSaveToHistory(true);? If you use shared QuickBlox server you can download only 100 messages at a time, if you have more 100 messages you have to use pagination. – Valentyn Tereshchenko May 29 '17 at 07:49

0 Answers0