Search in sources :

Example 1 with MentionsData

use of forpdateam.ru.forpda.api.mentions.models.MentionsData in project ForPDA by RadiationX.

the class Mentions method getMentions.

public MentionsData getMentions(int st) throws Exception {
    MentionsData data = new MentionsData();
    NetworkResponse response = Api.getWebClient().get("https://4pda.ru/forum/index.php?act=mentions&st=".concat(Integer.toString(st)));
    Matcher matcher = mentionsPattern.matcher(response.getBody());
    while (matcher.find()) {
        MentionItem item = new MentionItem();
        item.setState(matcher.group(1).equals("read") ? MentionItem.STATE_READ : MentionItem.STATE_UNREAD);
        item.setType(matcher.group(2).equalsIgnoreCase("Форум") ? MentionItem.TYPE_TOPIC : MentionItem.TYPE_NEWS);
        item.setLink(matcher.group(3));
        item.setTitle(ApiUtils.fromHtml(matcher.group(4)));
        item.setDesc(ApiUtils.fromHtml(matcher.group(5)));
        item.setDate(matcher.group(6));
        item.setNick(ApiUtils.fromHtml(matcher.group(7)));
        data.addItem(item);
    }
    data.setPagination(Pagination.parseForum(response.getBody()));
    return data;
}
Also used : MentionsData(forpdateam.ru.forpda.api.mentions.models.MentionsData) MentionItem(forpdateam.ru.forpda.api.mentions.models.MentionItem) Matcher(java.util.regex.Matcher) NetworkResponse(forpdateam.ru.forpda.api.NetworkResponse)

Example 2 with MentionsData

use of forpdateam.ru.forpda.api.mentions.models.MentionsData in project ForPDA by RadiationX.

the class MentionsPresenter method getMentions.

@Override
public void getMentions(int st) {
    view.setRefreshing(true);
    subscribe(RxApi.Mentions().getMentions(st), data -> {
        view.setRefreshing(false);
        view.showMentions(data);
    }, new MentionsData(), v -> getMentions(st));
}
Also used : MentionsData(forpdateam.ru.forpda.api.mentions.models.MentionsData)

Aggregations

MentionsData (forpdateam.ru.forpda.api.mentions.models.MentionsData)2 NetworkResponse (forpdateam.ru.forpda.api.NetworkResponse)1 MentionItem (forpdateam.ru.forpda.api.mentions.models.MentionItem)1 Matcher (java.util.regex.Matcher)1