javascriptphpchatdesktopquickblox

Recent chat should come first in quickblox history list


I want the recent message/chat with the counter should come first in the history list in Quickblox. How to configure this? Attached the screenshot. Thanks in advance

enter image description here


Solution

  • sort dialog list by message date sent

    listdata is arraylist of QBChatDialog

    Collections.sort(listdata, new Comparator<QBChatDialog>() {
                            public int compare(QBChatDialog o1, QBChatDialogo2) {
    
                                long valueA = ((QBChatDialog) o1).getLastMessageDateSent();
                                long valueB = ((QBChatDialog) o2).getLastMessageDateSent();
    
                                if (valueB < valueA) {
                                    return -1;
                                } else {
                                    return 1;
                                }
    
                            }
                        });