当前位置: 首页>>代码示例>>Java>>正文


Java QBChatMessage类代码示例

本文整理汇总了Java中com.quickblox.chat.model.QBChatMessage的典型用法代码示例。如果您正苦于以下问题:Java QBChatMessage类的具体用法?Java QBChatMessage怎么用?Java QBChatMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


QBChatMessage类属于com.quickblox.chat.model包,在下文中一共展示了QBChatMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadChatHistory

import com.quickblox.chat.model.QBChatMessage; //导入依赖的package包/类
public void loadChatHistory(QBChatDialog dialog, int skipPagination,
                            final QBEntityCallback<ArrayList<QBChatMessage>> callback) {
    QBRequestGetBuilder customObjectRequestBuilder = new QBRequestGetBuilder();
    customObjectRequestBuilder.setSkip(skipPagination);
    customObjectRequestBuilder.setLimit(CHAT_HISTORY_ITEMS_PER_PAGE);
    customObjectRequestBuilder.sortDesc(CHAT_HISTORY_ITEMS_SORT_FIELD);

    QBRestChatService.getDialogMessages(dialog, customObjectRequestBuilder).performAsync(
            new QBEntityCallback<ArrayList<QBChatMessage>>() {
                @Override
                public void onSuccess(ArrayList<QBChatMessage> qbChatMessages, Bundle bundle) {
                    callback.onSuccess(qbChatMessages, bundle);
                }

                @Override
                public void onError(QBResponseException e) {
                    callback.onError(e);
                }
            });
}
 
开发者ID:QuickBlox,项目名称:ChatMessagesAdapter-android,代码行数:21,代码来源:ChatHelper.java

示例2: processMessage

import com.quickblox.chat.model.QBChatMessage; //导入依赖的package包/类
@Override
public void processMessage(QBChat qbChat, QBChatMessage qbChatMessage) {
    User u = null;
    try {
        QBUser sender = getUserById(qbChatMessage.getSenderId());
        u = new User();
        u.setId(sender.getId());
        u.setLastRequestAt(u.getLastRequestAt());
        u.setLogin(sender.getLogin());
        u.setEmail(sender.getEmail());
        u.setName(sender.getFullName());
    } catch (QBResponseException e) {
        e.printStackTrace();
        return;
    }
    // Bracket hell ->
    EventBus.getDefault().post(new MessageReceivedEvent(new ChatMessage(u, qbChatMessage.getBody())));
    Log.d(TAG, "processMessage: " + qbChat + " " + qbChatMessage);
}
 
开发者ID:javabrewery,项目名称:brew-chat,代码行数:20,代码来源:ChatService.java

示例3: createGroupMessageAboutCreateGroupChat

import com.quickblox.chat.model.QBChatMessage; //导入依赖的package包/类
public static QBChatMessage createGroupMessageAboutCreateGroupChat(Context context, QBChatDialog qbDialog, String photoUrl) {
    QBChatMessage qbChatMessage = new QBChatMessage();
    qbChatMessage.setSaveToHistory(VALUE_SAVE_TO_HISTORY);
    qbChatMessage.setProperty(PROPERTY_NOTIFICATION_TYPE,
            String.valueOf(NotificationType.GROUP_CHAT_UPDATE.getValue()));
    qbChatMessage.setBody(context.getResources().getString(R.string.cht_notification_message));
    qbChatMessage.setProperty(PROPERTY_ROOM_CURRENT_OCCUPANTS_IDS,
            ChatUtils.getOccupantsIdsStringFromList(qbDialog.getOccupants()));
    qbChatMessage.setProperty(PROPERTY_ROOM_ADDED_OCCUPANTS_IDS,
            ChatUtils.getOccupantsIdsStringFromList(qbDialog.getOccupants()));
    qbChatMessage.setProperty(PROPERTY_ROOM_UPDATED_AT, String.valueOf(qbDialog.getUpdatedAt().getTime()));
    qbChatMessage.setProperty(PROPERTY_ROOM_UPDATE_INFO, String.valueOf(
            ChatNotificationType.CHAT_OCCUPANTS.getValue()));
    if (photoUrl != null) {
        qbChatMessage.setProperty(PROPERTY_ROOM_PHOTO, photoUrl);
    }
    return qbChatMessage;
}
 
开发者ID:QuickBlox,项目名称:q-municate-android,代码行数:19,代码来源:ChatNotificationUtils.java

示例4: saveMessagesToCache

import com.quickblox.chat.model.QBChatMessage; //导入依赖的package包/类
public static void saveMessagesToCache(Context context, DataManager dataManager,
        List<QBChatMessage> qbMessagesList, String dialogId) {
    for (int i = 0; i < qbMessagesList.size(); i++) {
        QBChatMessage qbChatMessage = qbMessagesList.get(i);


        State msgState = State.SYNC;
        if (!CollectionsUtil.isEmpty(qbChatMessage.getReadIds())){

            msgState = qbChatMessage.getReadIds().contains
                    (AppSession.getSession().getUser().getId()) ? State.READ : State.SYNC;
        }

        saveMessageOrNotificationToCache(context, dataManager, dialogId, qbChatMessage, msgState, false);
    }
    updateDialogModifiedDate(dataManager, dialogId, false);
}
 
开发者ID:QuickBlox,项目名称:q-municate-android,代码行数:18,代码来源:DbUtils.java

示例5: createLocalMessage

import com.quickblox.chat.model.QBChatMessage; //导入依赖的package包/类
public static Message createLocalMessage(QBChatMessage qbChatMessage, DialogOccupant dialogOccupant, State state) {
    long dateSent = getMessageDateSent(qbChatMessage);
    Message message = new Message();
    message.setMessageId(qbChatMessage.getId());
    message.setDialogOccupant(dialogOccupant);
    message.setCreatedDate(dateSent);

    if (messageIsRead(qbChatMessage)) {
        state = State.READ;
    } else if (messageIsDelivered(qbChatMessage)) {
        state = State.DELIVERED;
    }

    message.setState(state);
    message.setBody(qbChatMessage.getBody());
    return message;
}
 
开发者ID:QuickBlox,项目名称:q-municate-android,代码行数:18,代码来源:ChatUtils.java

示例6: sendChatMessage

import com.quickblox.chat.model.QBChatMessage; //导入依赖的package包/类
public void sendChatMessage(QBChatMessage message, QBChatDialog chatDialog) throws QBResponseException {
    message.setMarkable(true);
    chatDialog.initForChat(chatService);

    if (QBDialogType.GROUP.equals(chatDialog.getType())) {
        if (!chatDialog.isJoined()) {
            tryJoinRoomChat(chatDialog);
        }
    }

    String error = null;
    try {
        chatDialog.sendMessage(message);
    } catch (SmackException.NotConnectedException e) {
        error = context.getString(R.string.dlg_fail_connection);
    }
    if (error != null) {
        throw new QBResponseException(error);
    }
}
 
开发者ID:QuickBlox,项目名称:q-municate-android,代码行数:21,代码来源:QBChatHelper.java

示例7: checkForSendingNotification

import com.quickblox.chat.model.QBChatMessage; //导入依赖的package包/类
protected void checkForSendingNotification(boolean ownMessage, QBChatMessage qbChatMessage, QMUser user,
                                           boolean isPrivateChat) {
    String dialogId = qbChatMessage.getDialogId();
    if (qbChatMessage.getId() == null || dialogId == null) {
        return;
    }

    if (!ownMessage) {
        sendNotificationBroadcast(QBServiceConsts.GOT_CHAT_MESSAGE, qbChatMessage, user, dialogId, isPrivateChat);
    }

    if (currentDialog != null) {
        if (!ownMessage && !currentDialog.getDialogId().equals(dialogId)) {
            sendNotificationBroadcast(QBServiceConsts.GOT_CHAT_MESSAGE_LOCAL, qbChatMessage, user, dialogId, isPrivateChat);
        }
    } else if (!ownMessage) {
        sendNotificationBroadcast(QBServiceConsts.GOT_CHAT_MESSAGE_LOCAL, qbChatMessage, user, dialogId,
                isPrivateChat);
    }
}
 
开发者ID:QuickBlox,项目名称:q-municate-android,代码行数:21,代码来源:QBChatHelper.java

示例8: sendNotificationBroadcast

import com.quickblox.chat.model.QBChatMessage; //导入依赖的package包/类
private void sendNotificationBroadcast(String action, QBChatMessage chatMessage, QMUser user, String dialogId,
                                       boolean isPrivateMessage) {
    Intent intent = new Intent(action);
    String messageBody = chatMessage.getBody();
    String extraChatMessage;

    if (!CollectionsUtil.isEmpty(chatMessage.getAttachments())) {
        //in current version we can send only one attachment
        QBAttachment attachment = chatMessage.getAttachments().iterator().next();
        extraChatMessage = context.getResources().getString(R.string.was_attached, attachment.getType());
    } else {
        extraChatMessage = messageBody;
    }

    intent.putExtra(QBServiceConsts.EXTRA_CHAT_MESSAGE, extraChatMessage);
    intent.putExtra(QBServiceConsts.EXTRA_USER, user);
    intent.putExtra(QBServiceConsts.EXTRA_DIALOG_ID, dialogId);
    intent.putExtra(QBServiceConsts.EXTRA_IS_PRIVATE_MESSAGE, isPrivateMessage);

    LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
    context.sendBroadcast(intent);
}
 
开发者ID:QuickBlox,项目名称:q-municate-android,代码行数:23,代码来源:QBChatHelper.java

示例9: updateStatusMessageReadServer

import com.quickblox.chat.model.QBChatMessage; //导入依赖的package包/类
public void updateStatusMessageReadServer(QBChatDialog chatDialog, CombinationMessage combinationMessage,
                                          boolean isOnline) throws Exception {
    if (isOnline) {
        chatDialog.initForChat(chatService);

        QBChatMessage qbChatMessage = new QBChatMessage();
        qbChatMessage.setId(combinationMessage.getMessageId());
        qbChatMessage.setDialogId(chatDialog.getDialogId());
        qbChatMessage.setSenderId(combinationMessage.getDialogOccupant().getUser().getId());

        chatDialog.readMessage(qbChatMessage);
    } else {
        StringifyArrayList<String> messagesIdsList = new StringifyArrayList<String>();
        messagesIdsList.add(combinationMessage.getMessageId());
        QBRestChatService.markMessagesAsRead(chatDialog.getDialogId(), messagesIdsList).perform();
    }
}
 
开发者ID:QuickBlox,项目名称:q-municate-android,代码行数:18,代码来源:QBChatHelper.java

示例10: createGroupDialogByNotification

import com.quickblox.chat.model.QBChatMessage; //导入依赖的package包/类
private void createGroupDialogByNotification(QBChatMessage qbChatMessage, DialogNotification.Type notificationType) {
    qbChatMessage.setBody(context.getString(R.string.cht_notification_message));

    QBChatDialog qbDialog = ChatNotificationUtils.parseDialogFromQBMessage(context, qbChatMessage, qbChatMessage.getBody(), QBDialogType.GROUP);

    qbDialog.getOccupants().add(chatCreator.getId());
    DbUtils.saveDialogToCache(dataManager, qbDialog);

    String roomJidId = qbDialog.getRoomJid();
    if (roomJidId != null) {
        tryJoinRoomChat(qbDialog);
        new FinderUnknownUsers(context, chatCreator, qbDialog).find();
    }

    DialogNotification dialogNotification = ChatUtils.convertMessageToDialogNotification(parseReceivedMessage(qbChatMessage));
    dialogNotification.setType(notificationType);
    Message message = ChatUtils.createTempLocalMessage(dialogNotification);
    DbUtils.saveTempMessage(dataManager, message);

    boolean ownMessage = !message.isIncoming(chatCreator.getId());
    QMUser user = QMUserService.getInstance().getUserCache().get((long) qbChatMessage.getSenderId());
    checkForSendingNotification(ownMessage, qbChatMessage, user, false);
}
 
开发者ID:QuickBlox,项目名称:q-municate-android,代码行数:24,代码来源:QBChatHelper.java

示例11: createGroupChat

import com.quickblox.chat.model.QBChatMessage; //导入依赖的package包/类
public QBChatDialog createGroupChat(String name, List<Integer> friendIdsList, String photoUrl) throws Exception {
    ArrayList<Integer> occupantIdsList = (ArrayList<Integer>) ChatUtils.getOccupantIdsWithUser(friendIdsList);

    QBChatDialog dialogToCreate = new QBChatDialog();
    dialogToCreate.setName(name);
    dialogToCreate.setType(QBDialogType.GROUP);
    dialogToCreate.setOccupantsIds(occupantIdsList);
    dialogToCreate.setPhoto(photoUrl);

    QBChatDialog qbDialog = QBRestChatService.createChatDialog(dialogToCreate).perform();
    DbUtils.saveDialogToCache(dataManager, qbDialog);

    joinRoomChat(qbDialog);

    sendSystemMessageAboutCreatingGroupChat(qbDialog, friendIdsList);

    QBChatMessage chatMessage = ChatNotificationUtils.createGroupMessageAboutCreateGroupChat(context, qbDialog, photoUrl);
    sendChatMessage(chatMessage, qbDialog);

    return qbDialog;
}
 
开发者ID:QuickBlox,项目名称:q-municate-android,代码行数:22,代码来源:QBChatHelper.java

示例12: sendSystemMessage

import com.quickblox.chat.model.QBChatMessage; //导入依赖的package包/类
public void sendSystemMessage(QBChatMessage chatMessage, int opponentId, String dialogId) {
    addNecessaryPropertyForQBChatMessage(chatMessage, dialogId);
    chatMessage.setRecipientId(opponentId);
    try {
        systemMessagesManager.sendSystemMessage(chatMessage);
    } catch (SmackException.NotConnectedException e) {
        ErrorUtils.logError(e);
    }
}
 
开发者ID:QuickBlox,项目名称:q-municate-android,代码行数:10,代码来源:QBChatHelper.java

示例13: sendSystemMessageAboutCreatingGroupChat

import com.quickblox.chat.model.QBChatMessage; //导入依赖的package包/类
private void sendSystemMessageAboutCreatingGroupChat(QBChatDialog dialog, Integer friendId) throws Exception {
    QBChatMessage chatMessageForSending = ChatNotificationUtils
            .createSystemMessageAboutCreatingGroupChat(context, dialog);

    addNecessaryPropertyForQBChatMessage(chatMessageForSending, dialog.getDialogId());
    sendSystemMessage(chatMessageForSending, friendId, dialog.getDialogId());
}
 
开发者ID:QuickBlox,项目名称:q-municate-android,代码行数:8,代码来源:QBChatHelper.java

示例14: updateGroupDialogByNotification

import com.quickblox.chat.model.QBChatMessage; //导入依赖的package包/类
private void updateGroupDialogByNotification(QBChatMessage qbChatMessage) {
    String dialogId = qbChatMessage.getDialogId();
    QBChatDialog qbDialog = dataManager.getQBChatDialogDataManager().getByDialogId(dialogId);
    if (qbDialog == null) {
        qbDialog = ChatNotificationUtils.parseDialogFromQBMessage(context, qbChatMessage, QBDialogType.GROUP);
    }

    ChatNotificationUtils.updateDialogFromQBMessage(context, dataManager, qbChatMessage, qbDialog);
    DbUtils.saveDialogToCache(dataManager, qbDialog);

    notifyUpdatingDialog();
}
 
开发者ID:QuickBlox,项目名称:q-municate-android,代码行数:13,代码来源:QBChatHelper.java

示例15: friendRequestMessageReceived

import com.quickblox.chat.model.QBChatMessage; //导入依赖的package包/类
private void friendRequestMessageReceived(QBChatMessage qbChatMessage, DialogNotification.Type notificationType) {
    String dialogId = qbChatMessage.getDialogId();
    Message message = parseReceivedMessage(qbChatMessage);

    if (!QMUserService.getInstance().getUserCache().exists((long) qbChatMessage.getSenderId())) {
        QBRestHelper.loadAndSaveUser(qbChatMessage.getSenderId());
    }

    DialogNotification dialogNotification = ChatUtils.convertMessageToDialogNotification(message);
    dialogNotification.setType(notificationType);

    QBChatDialog chatDialog = dataManager.getQBChatDialogDataManager().getByDialogId(dialogId);
    if (chatDialog == null) {
        QBChatDialog newChatDialog = ChatNotificationUtils.parseDialogFromQBMessage(context, qbChatMessage, QBDialogType.PRIVATE);
        ArrayList<Integer> occupantsIdsList = ChatUtils.createOccupantsIdsFromPrivateMessage(chatCreator.getId(), qbChatMessage.getSenderId());
        newChatDialog.setOccupantsIds(occupantsIdsList);
        DbUtils.saveDialogToCache(dataManager, newChatDialog, false);
    }

    DialogOccupant dialogOccupant = dataManager.getDialogOccupantDataManager().getDialogOccupant(dialogId, qbChatMessage.getSenderId());
    DbUtils.saveDialogNotificationToCache(context, dataManager, dialogOccupant, qbChatMessage, false);

    if (dialogOccupant != null) {
        checkForSendingNotification(false, qbChatMessage, dialogOccupant.getUser(), true);
    }
}
 
开发者ID:QuickBlox,项目名称:q-municate-android,代码行数:27,代码来源:QBChatHelper.java


注:本文中的com.quickblox.chat.model.QBChatMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。