Last active
August 29, 2015 14:27
-
-
Save safaorhan/b9cc5a22839d700fbf90 to your computer and use it in GitHub Desktop.
QBHelper - Step 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
QBPrivateChatManagerListener privateChatManagerListener; | |
QBMessageListener<QBPrivateChat> privateChatMessageListener; | |
public void initFramework() { | |
//.. | |
privateChatMessageListener = new QBMessageListener<QBPrivateChat>() { | |
@Override | |
public void processMessage(QBPrivateChat qbPrivateChat, QBChatMessage qbChatMessage) { | |
if (qbChatMessage.isMarkable()) { | |
int opponentId = qbPrivateChat.getParticipant(); | |
QBDialog dialog = getDialogOfOpponent(opponentId); | |
if (null == dialog) { // We don't have this chat's dialog. | |
retrieveDialogs(); | |
} | |
} | |
} | |
@Override | |
public void processError(QBPrivateChat qbPrivateChat, QBChatException e, QBChatMessage qbChatMessage) { | |
//.. | |
} | |
@Override | |
public void processMessageDelivered(QBPrivateChat qbPrivateChat, String s) { | |
//.. | |
} | |
@Override | |
public void processMessageRead(QBPrivateChat qbPrivateChat, String s) { | |
//.. | |
} | |
}; | |
privateChatManagerListener = new QBPrivateChatManagerListener() { | |
@Override | |
public void chatCreated(final QBPrivateChat privateChat, final boolean createdLocally) { | |
privateChat.addMessageListener(privateChatMessageListener); | |
} | |
}; | |
} | |
public QBDialog getDialogOfOpponent(int opponentId) { | |
for (QBDialog dialog : chatDialogs) { | |
if (dialog.getOccupants().contains(opponentId)) { | |
return dialog; | |
} | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment