Search in sources :

Example 6 with MiniTemplator

use of biz.source_code.miniTemplator.MiniTemplator in project ForPDA by RadiationX.

the class ForumRx method transform.

public static Announce transform(Announce announce, boolean withHtml) throws Exception {
    if (withHtml) {
        MiniTemplator t = App.get().getTemplate(App.TEMPLATE_ANNOUNCE);
        App.setTemplateResStrings(t);
        t.setVariableOpt("style_type", App.get().getCssStyleType());
        t.setVariableOpt("body", announce.getHtml());
        announce.setHtml(t.generateOutput());
        t.reset();
    }
    return announce;
}
Also used : MiniTemplator(biz.source_code.miniTemplator.MiniTemplator)

Example 7 with MiniTemplator

use of biz.source_code.miniTemplator.MiniTemplator in project ForPDA by RadiationX.

the class ForumRx method transform.

public static ForumRules transform(ForumRules rules, boolean withHtml) throws Exception {
    if (withHtml) {
        MiniTemplator t = App.get().getTemplate(App.TEMPLATE_FORUM_RULES);
        App.setTemplateResStrings(t);
        t.setVariableOpt("style_type", App.get().getCssStyleType());
        for (ForumRules.Item item : rules.getItems()) {
            t.setVariableOpt("type", item.isHeader() ? "header" : "");
            t.setVariableOpt("number", item.getNumber());
            t.setVariableOpt("text", item.getText());
            t.addBlockOpt("rules_item");
        }
        rules.setHtml(t.generateOutput());
        t.reset();
    }
    return rules;
}
Also used : ForumRules(forpdateam.ru.forpda.api.forum.models.ForumRules) MiniTemplator(biz.source_code.miniTemplator.MiniTemplator)

Example 8 with MiniTemplator

use of biz.source_code.miniTemplator.MiniTemplator in project ForPDA by RadiationX.

the class QmsChatFragment method showMoreMess.

@JavascriptInterface
public void showMoreMess() {
    if (getContext() == null)
        return;
    MiniTemplator t = App.get().getTemplate(App.TEMPLATE_QMS_CHAT_MESS);
    App.setTemplateResStrings(t);
    int endIndex = currentChat.getShowedMessIndex();
    int startIndex = Math.max(endIndex - 30, 0);
    currentChat.setShowedMessIndex(startIndex);
    QmsRx.generateMess(t, currentChat.getMessages(), startIndex, endIndex);
    String messagesSrc = t.generateOutput();
    t.reset();
    messagesSrc = QmsRx.transformMessageSrc(messagesSrc);
    webView.evalJs("showMoreMess('" + messagesSrc + "')");
}
Also used : MiniTemplator(biz.source_code.miniTemplator.MiniTemplator) SuppressLint(android.annotation.SuppressLint) JavascriptInterface(android.webkit.JavascriptInterface)

Example 9 with MiniTemplator

use of biz.source_code.miniTemplator.MiniTemplator in project ForPDA by RadiationX.

the class QmsChatFragment method onNewMessages.

private void onNewMessages(ArrayList<QmsMessage> qmsMessage) {
    Log.d(LOG_TAG, "Returned messages " + qmsMessage.size());
    if (!qmsMessage.isEmpty()) {
        MiniTemplator t = App.get().getTemplate(App.TEMPLATE_QMS_CHAT_MESS);
        App.setTemplateResStrings(t);
        for (int i = 0; i < qmsMessage.size(); i++) {
            QmsMessage message = qmsMessage.get(i);
            for (QmsMessage viewmessage : currentChat.getMessages()) {
                if (viewmessage.getId() == message.getId()) {
                    return;
                }
            }
            currentChat.addMessage(message);
            QmsRx.generateMess(t, message);
        }
        String messagesSrc = t.generateOutput();
        t.reset();
        messagesSrc = QmsRx.transformMessageSrc(messagesSrc);
        webView.evalJs("showNewMess('".concat(messagesSrc).concat("', true)"));
    }
}
Also used : QmsMessage(forpdateam.ru.forpda.api.qms.models.QmsMessage) MiniTemplator(biz.source_code.miniTemplator.MiniTemplator) SuppressLint(android.annotation.SuppressLint)

Example 10 with MiniTemplator

use of biz.source_code.miniTemplator.MiniTemplator in project ForPDA by RadiationX.

the class QmsChatFragment method loadBaseWebContainer.

// Chat
private void loadBaseWebContainer() {
    MiniTemplator t = App.get().getTemplate(App.TEMPLATE_QMS_CHAT);
    App.setTemplateResStrings(t);
    t.setVariableOpt("style_type", App.get().getCssStyleType());
    t.setVariableOpt("body_type", "qms");
    t.setVariableOpt("messages", "");
    String html = t.generateOutput();
    t.reset();
    webView.loadDataWithBaseURL("https://4pda.ru/forum/", html, "text/html", "utf-8", null);
}
Also used : MiniTemplator(biz.source_code.miniTemplator.MiniTemplator)

Aggregations

MiniTemplator (biz.source_code.miniTemplator.MiniTemplator)10 SuppressLint (android.annotation.SuppressLint)3 ForumUser (forpdateam.ru.forpda.api.others.user.ForumUser)2 ArrayList (java.util.ArrayList)2 Matcher (java.util.regex.Matcher)2 JavascriptInterface (android.webkit.JavascriptInterface)1 ForumRules (forpdateam.ru.forpda.api.forum.models.ForumRules)1 Material (forpdateam.ru.forpda.api.news.models.Material)1 QmsMessage (forpdateam.ru.forpda.api.qms.models.QmsMessage)1 SearchItem (forpdateam.ru.forpda.api.search.models.SearchItem)1 Poll (forpdateam.ru.forpda.api.theme.models.Poll)1 PollQuestion (forpdateam.ru.forpda.api.theme.models.PollQuestion)1 PollQuestionItem (forpdateam.ru.forpda.api.theme.models.PollQuestionItem)1 ThemePost (forpdateam.ru.forpda.api.theme.models.ThemePost)1