Search in sources :

Example 1 with QmsChatModel

use of forpdateam.ru.forpda.api.qms.models.QmsChatModel in project ForPDA by RadiationX.

the class QmsChatFragment method onCreateNewTheme.

// From theme creator
@Override
public void onCreateNewTheme(String nick, String title, String message) {
    addUnusedAttachments();
    refreshToolbarMenuItems(false);
    progressBar.setVisibility(View.VISIBLE);
    subscribe(RxApi.Qms().sendNewTheme(nick, title, message), this::onNewThemeCreate, new QmsChatModel());
}
Also used : QmsChatModel(forpdateam.ru.forpda.api.qms.models.QmsChatModel)

Example 2 with QmsChatModel

use of forpdateam.ru.forpda.api.qms.models.QmsChatModel in project ForPDA by RadiationX.

the class Qms method parseChat.

private QmsChatModel parseChat(String response) {
    QmsChatModel chat = new QmsChatModel();
    Matcher matcher = chatPattern.matcher(response);
    QmsMessage item;
    while (matcher.find()) {
        item = new QmsMessage();
        if (matcher.group(1) == null && matcher.group(7) != null) {
            item.setIsDate(true);
            item.setDate(matcher.group(7).trim());
        } else {
            item.setMyMessage(!matcher.group(1).isEmpty());
            item.setId(Integer.parseInt(matcher.group(2)));
            if (item.isMyMessage()) {
                item.setReadStatus(!matcher.group(3).equals("1"));
            } else {
                item.setReadStatus(true);
            }
            item.setTime(matcher.group(4));
            item.setAvatar(matcher.group(5));
            item.setContent(matcher.group(6).trim());
        }
        chat.addMessage(item);
    }
    matcher = chatInfoPattern.matcher(response);
    if (matcher.find()) {
        chat.setNick(ApiUtils.fromHtml(matcher.group(1).trim()));
        chat.setTitle(ApiUtils.fromHtml(matcher.group(2).trim()));
        chat.setUserId(Integer.parseInt(matcher.group(3)));
        chat.setThemeId(Integer.parseInt(matcher.group(4)));
        chat.setAvatarUrl(matcher.group(5));
    }
    return chat;
}
Also used : Matcher(java.util.regex.Matcher) QmsMessage(forpdateam.ru.forpda.api.qms.models.QmsMessage) QmsChatModel(forpdateam.ru.forpda.api.qms.models.QmsChatModel)

Example 3 with QmsChatModel

use of forpdateam.ru.forpda.api.qms.models.QmsChatModel in project ForPDA by RadiationX.

the class QmsChatFragment method loadData.

@Override
public boolean loadData() {
    if (!super.loadData()) {
        return false;
    }
    if (currentChat.getUserId() != QmsChatModel.NOT_CREATED && currentChat.getThemeId() != QmsChatModel.NOT_CREATED) {
        refreshToolbarMenuItems(false);
        progressBar.setVisibility(View.VISIBLE);
        subscribe(RxApi.Qms().getChat(currentChat.getUserId(), currentChat.getThemeId()), this::onLoadChat, new QmsChatModel(), v -> loadData());
    }
    return true;
}
Also used : QmsChatModel(forpdateam.ru.forpda.api.qms.models.QmsChatModel)

Aggregations

QmsChatModel (forpdateam.ru.forpda.api.qms.models.QmsChatModel)3 QmsMessage (forpdateam.ru.forpda.api.qms.models.QmsMessage)1 Matcher (java.util.regex.Matcher)1