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


Java DisplayUnit类代码示例

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


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

示例1: parse

import org.commcare.suite.model.DisplayUnit; //导入依赖的package包/类
public Action parse() throws InvalidStructureException, IOException, XmlPullParserException {
    this.checkNode(NAME_ACTION);

    DisplayUnit display = null;
    Vector<StackOperation> stackOps = new Vector<StackOperation>();

    while (nextTagInBlock(NAME_ACTION)) {
        if (parser.getName().equals("display")) {
            display = parseDisplayBlock();
        } else if (parser.getName().equals("stack")) {
            StackOpParser sop = new StackOpParser(parser);
            while (this.nextTagInBlock("stack")) {
                stackOps.addElement(sop.parse());
            }
        }
    }

    if (display == null) {
        throw new InvalidStructureException("<action> block must define a <display> element", parser);
    }
    if (stackOps.size() == 0) {
        throw new InvalidStructureException("An <action> block must define at least one stack operation", parser);
    }
    return new Action(display, stackOps);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:26,代码来源:ActionParser.java

示例2: buildPromptEntry

import org.commcare.suite.model.DisplayUnit; //导入依赖的package包/类
private void buildPromptEntry(LinearLayout promptsLayout, String promptId,
                              DisplayUnit displayUnit, boolean isLastPrompt) {
    Hashtable<String, String> userAnswers =
            remoteQuerySessionManager.getUserAnswers();
    promptsLayout.addView(createPromptMedia(displayUnit));

    EditText promptEditText = new EditText(this);
    if (userAnswers.containsKey(promptId)) {
        promptEditText.setText(userAnswers.get(promptId));
    }
    promptEditText.setBackgroundResource(R.drawable.login_edit_text);
    // needed to allow 'done' and 'next' keyboard action
    promptEditText.setSingleLine();

    if (isLastPrompt) {
        promptEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    } else {
        // replace 'done' on keyboard with 'next'
        promptEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
    }
    promptsLayout.addView(promptEditText);
    promptsBoxes.put(promptId, promptEditText);
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:24,代码来源:QueryRequestActivity.java

示例3: init

import org.commcare.suite.model.DisplayUnit; //导入依赖的package包/类
@Override
public void init(SessionWrapper sessionWrapper) throws CommCareSessionException {
    this.sessionWrapper = sessionWrapper;
    remoteQuerySessionManager =
            RemoteQuerySessionManager.buildQuerySessionManager(sessionWrapper,
                    sessionWrapper.getEvaluationContext());

    if (remoteQuerySessionManager == null) {
        throw new CommCareSessionException(String.format("QueryManager for case " +
                "claim screen with id %s cannot be null.", sessionWrapper.getNeededData()));
    }
    userInputDisplays = remoteQuerySessionManager.getNeededUserInputDisplays();

    int count = 0;
    fields = new String[userInputDisplays.keySet().size()];
    for (Map.Entry<String, DisplayUnit> displayEntry : userInputDisplays.entrySet()) {
        fields[count] = displayEntry.getValue().getText().evaluate(sessionWrapper.getEvaluationContext());
    }
    mTitle = "Case Claim";

}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:22,代码来源:QueryScreen.java

示例4: handleInputAndUpdateSession

import org.commcare.suite.model.DisplayUnit; //导入依赖的package包/类
@Override
public boolean handleInputAndUpdateSession(CommCareSession session, String input) {
    String[] answers = input.split(",");
    Hashtable<String, String> userAnswers = new Hashtable<>();
    int count = 0;
    for (Map.Entry<String, DisplayUnit> displayEntry : userInputDisplays.entrySet()) {
        userAnswers.put(displayEntry.getKey(), answers[count]);
        count ++;
    }
    answerPrompts(userAnswers);
    InputStream response = makeQueryRequestReturnStream();
    boolean refresh = processResponse(response);
    if (currentMessage != null) {
        out.println(currentMessage);
    }
    return refresh;
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:18,代码来源:QueryScreen.java

示例5: parseDisplayBlock

import org.commcare.suite.model.DisplayUnit; //导入依赖的package包/类
/**
 * Build a DisplayUnit object by parsing the contents of a display tag.
 */
public DisplayUnit parseDisplayBlock() throws InvalidStructureException, IOException, XmlPullParserException {
    Text imageValue = null;
    Text audioValue = null;
    Text displayText = null;

    while (nextTagInBlock("display")) {
        if (parser.getName().equals("text")) {

            String attributeValue = parser.getAttributeValue(null, "form");

            if (attributeValue != null && attributeValue.equals("image")) {
                imageValue = new TextParser(parser).parse();
            } else if (attributeValue != null && attributeValue.equals("audio")) {
                audioValue = new TextParser(parser).parse();
            } else {
                displayText = new TextParser(parser).parse();
            }
        }
        // check and parse media stuff
        // still default to using this for now if it exists
        else if ("media".equals(parser.getName())) {
            String imagePath = parser.getAttributeValue(null, "image");
            if (imagePath != null) {
                imageValue = Text.PlainText(imagePath);
            }

            String audioPath = parser.getAttributeValue(null, "audio");
            if (audioPath != null) {
                audioValue = Text.PlainText(audioPath);
            }
            //only ends up grabbing the last entries with
            //each attribute, but we can only use one of each anyway.
        }
    }

    return new DisplayUnit(displayText, imageValue, audioValue);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:41,代码来源:CommCareElementParser.java

示例6: buildPromptUI

import org.commcare.suite.model.DisplayUnit; //导入依赖的package包/类
private void buildPromptUI() {
    LinearLayout promptsLayout = (LinearLayout)findViewById(R.id.query_prompts);
    OrderedHashtable<String, DisplayUnit> userInputDisplays =
            remoteQuerySessionManager.getNeededUserInputDisplays();
    int promptCount = 1;

    for (Enumeration en = userInputDisplays.keys(); en.hasMoreElements(); ) {
        String promptId = (String)en.nextElement();
        boolean isLastPrompt = promptCount++ == userInputDisplays.size();
        buildPromptEntry(promptsLayout, promptId,
                userInputDisplays.get(promptId), isLastPrompt);
    }
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:14,代码来源:QueryRequestActivity.java

示例7: createPromptMedia

import org.commcare.suite.model.DisplayUnit; //导入依赖的package包/类
private MediaLayout createPromptMedia(DisplayUnit display) {
    DisplayData displayData = display.evaluate();
    String promptText =
            Localizer.processArguments(displayData.getName(), new String[]{""}).trim();
    TextView text = new TextView(getApplicationContext());
    text.setText(promptText);
    text.setPadding(0, 0, 0, 7);
    text.setTextColor(Color.BLACK);

    MediaLayout helpLayout = MediaLayout.buildAudioImageLayout(this, text, displayData.getAudioURI(), displayData.getImageURI());
    int padding = (int)getResources().getDimension(R.dimen.help_text_padding);
    helpLayout.setPadding(padding, padding, padding, padding);

    return helpLayout;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:16,代码来源:QueryRequestActivity.java

示例8: parseDisplayBlock

import org.commcare.suite.model.DisplayUnit; //导入依赖的package包/类
/**
 * Build a DisplayUnit object by parsing the contents of a display tag.
 */
public DisplayUnit parseDisplayBlock() throws InvalidStructureException, IOException, XmlPullParserException {
    Text imageValue = null;
    Text audioValue = null;
    Text displayText = null;
    Text badgeText = null;

    while (nextTagInBlock("display")) {
        if (parser.getName().equals("text")) {
            String attributeValue = parser.getAttributeValue(null, "form");
            if ("image".equals(attributeValue)) {
                imageValue = new TextParser(parser).parse();
            } else if ("audio".equals(attributeValue)) {
                audioValue = new TextParser(parser).parse();
            } else if ("badge".equals(attributeValue) ) {
                badgeText = new TextParser(parser).parse();
            } else {
                displayText = new TextParser(parser).parse();
            }
        } else if ("media".equals(parser.getName())) {
            String imagePath = parser.getAttributeValue(null, "image");
            if (imagePath != null) {
                imageValue = Text.PlainText(imagePath);
            }

            String audioPath = parser.getAttributeValue(null, "audio");
            if (audioPath != null) {
                audioValue = Text.PlainText(audioPath);
            }
            //only ends up grabbing the last entries with
            //each attribute, but we can only use one of each anyway.
        }
    }

    return new DisplayUnit(displayText, imageValue, audioValue, badgeText);
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:39,代码来源:CommCareElementParser.java

示例9: parse

import org.commcare.suite.model.DisplayUnit; //导入依赖的package包/类
@Override
public Action parse() throws InvalidStructureException, IOException, XmlPullParserException {
    this.checkNode(NAME_ACTION);

    String iconForActionBarPlacement = parser.getAttributeValue(null, "action-bar-icon");

    DisplayUnit display = null;
    Vector<StackOperation> stackOps = new Vector<>();

    XPathExpression relevantExpr = parseRelevancyExpr();

    while (nextTagInBlock(NAME_ACTION)) {
        if (parser.getName().equals("display")) {
            display = parseDisplayBlock();
        } else if (parser.getName().equals("stack")) {
            StackOpParser sop = new StackOpParser(parser);
            while (this.nextTagInBlock("stack")) {
                stackOps.addElement(sop.parse());
            }
        }
    }

    if (display == null) {
        throw new InvalidStructureException("<action> block must define a <display> element", parser);
    }
    if (stackOps.size() == 0) {
        throw new InvalidStructureException("An <action> block must define at least one stack operation", parser);
    }
    return new Action(display, stackOps, relevantExpr, iconForActionBarPlacement);
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:31,代码来源:ActionParser.java

示例10: getNeededUserInputDisplays

import org.commcare.suite.model.DisplayUnit; //导入依赖的package包/类
public Hashtable<String, DisplayUnit> getNeededUserInputDisplays() {
    return queryDatum.getUserQueryPrompts();
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:4,代码来源:RemoteQuerySessionManager.java

示例11: parse

import org.commcare.suite.model.DisplayUnit; //导入依赖的package包/类
@Override
public Entry parse() throws InvalidStructureException, IOException, XmlPullParserException {
    this.checkNode(parserBlockTag);

    String xFormNamespace = null;
    Vector<SessionDatum> data = new Vector<SessionDatum>();
    Hashtable<String, DataInstance> instances = new Hashtable<String, DataInstance>();

    String commandId = "";
    DisplayUnit display = null;
    Vector<StackOperation> stackOps = new Vector<StackOperation>();
    AssertionSet assertions = null;
    SyncPost post = null;

    while (nextTagInBlock(parserBlockTag)) {
        String tagName = parser.getName();
        if ("form".equals(tagName)) {
            if (parserBlockTag.equals(VIEW_ENTRY_TAG)) {
                throw new InvalidStructureException("<" + parserBlockTag + ">'s cannot specify XForms!!", parser);
            }
            xFormNamespace = parser.nextText();
        } else if ("command".equals(tagName)) {
            commandId = parser.getAttributeValue(null, "id");
            display = parseCommandDisplay();
        } else if ("instance".equals(tagName.toLowerCase())) {
            parseInstance(instances);
        } else if ("session".equals(tagName)) {
            parseSessionData(data);
        } else if ("entity".equals(tagName) || "details".equals(tagName)) {
            throw new InvalidStructureException("Incompatible CaseXML 1.0 elements detected in <" + parserBlockTag + ">. " +
                    tagName + " is not a valid construct in 2.0 CaseXML", parser);
        } else if ("stack".equals(tagName)) {
            parseStack(stackOps);
        } else if ("assertions".equals(tagName)) {
            assertions = new AssertionSetParser(parser).parse();
        } else if ("post".equals(tagName)) {
            post = parsePost();
        }
    }

    if (display == null) {
        throw new InvalidStructureException("<entry> block must define display text details", parser);
    }

    //The server side wasn't generating <view> blocks correctly for a long time, so if we have
    //an entry with no xmlns and no operations, we'll consider that a view.
    boolean isViewEntry = VIEW_ENTRY_TAG.equals(parserBlockTag) ||
            (FORM_ENTRY_TAG.equals(parserBlockTag) &&
                    xFormNamespace == null &&
                    stackOps.size() == 0);

    if (isViewEntry) {
        return new ViewEntry(commandId, display, data, instances, stackOps, assertions);
    } else if (FORM_ENTRY_TAG.equals(parserBlockTag)) {
        return new FormEntry(commandId, display, data, xFormNamespace, instances, stackOps, assertions);
    } else if (SYNC_REQUEST_TAG.equals(parserBlockTag)) {
        if (post == null) {
            throw new RuntimeException(SYNC_REQUEST_TAG + " must contain a <post> element");
        } else {
            return new SyncEntry(commandId, display, data, instances, stackOps, assertions, post);
        }
    }

    throw new RuntimeException("Misconfigured entry parser with unsupported '" + parserBlockTag + "' tag.");
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:66,代码来源:EntryParser.java

示例12: getNeededUserInputDisplays

import org.commcare.suite.model.DisplayUnit; //导入依赖的package包/类
public OrderedHashtable<String, DisplayUnit> getNeededUserInputDisplays() {
    return queryDatum.getUserQueryPrompts();
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:4,代码来源:RemoteQuerySessionManager.java

示例13: parse

import org.commcare.suite.model.DisplayUnit; //导入依赖的package包/类
@Override
public Entry parse() throws InvalidStructureException, IOException, XmlPullParserException {
    this.checkNode(parserBlockTag);

    String xFormNamespace = null;
    Vector<SessionDatum> data = new Vector<>();
    Hashtable<String, DataInstance> instances = new Hashtable<>();

    String commandId = "";
    DisplayUnit display = null;
    Vector<StackOperation> stackOps = new Vector<>();
    AssertionSet assertions = null;
    PostRequest post = null;

    while (nextTagInBlock(parserBlockTag)) {
        String tagName = parser.getName();
        if ("form".equals(tagName)) {
            if (parserBlockTag.equals(VIEW_ENTRY_TAG)) {
                throw new InvalidStructureException("<" + parserBlockTag + ">'s cannot specify XForms!!", parser);
            }
            xFormNamespace = parser.nextText();
        } else if ("command".equals(tagName)) {
            commandId = parser.getAttributeValue(null, "id");
            display = parseCommandDisplay();
        } else if ("instance".equals(tagName.toLowerCase())) {
            parseInstance(instances);
        } else if ("session".equals(tagName)) {
            parseSessionData(data);
        } else if ("entity".equals(tagName) || "details".equals(tagName)) {
            throw new InvalidStructureException("Incompatible CaseXML 1.0 elements detected in <" + parserBlockTag + ">. " +
                    tagName + " is not a valid construct in 2.0 CaseXML", parser);
        } else if ("stack".equals(tagName)) {
            parseStack(stackOps);
        } else if ("assertions".equals(tagName)) {
            assertions = new AssertionSetParser(parser).parse();
        } else if ("post".equals(tagName)) {
            post = parsePost();
        }
    }

    if (display == null) {
        throw new InvalidStructureException("<entry> block must define display text details", parser);
    }

    //The server side wasn't generating <view> blocks correctly for a long time, so if we have
    //an entry with no xmlns and no operations, we'll consider that a view.
    boolean isViewEntry = VIEW_ENTRY_TAG.equals(parserBlockTag) ||
            (FORM_ENTRY_TAG.equals(parserBlockTag) &&
                    xFormNamespace == null &&
                    stackOps.size() == 0);

    if (isViewEntry) {
        return new ViewEntry(commandId, display, data, instances, stackOps, assertions);
    } else if (FORM_ENTRY_TAG.equals(parserBlockTag)) {
        return new FormEntry(commandId, display, data, xFormNamespace, instances, stackOps, assertions);
    } else if (REMOTE_REQUEST_TAG.equals(parserBlockTag)) {
        if (post == null) {
            throw new RuntimeException(REMOTE_REQUEST_TAG + " must contain a <post> element");
        } else {
            return new RemoteRequestEntry(commandId, display, data, instances, stackOps, assertions, post);
        }
    }

    throw new RuntimeException("Misconfigured entry parser with unsupported '" + parserBlockTag + "' tag.");
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:66,代码来源:EntryParser.java

示例14: getUserInputDisplays

import org.commcare.suite.model.DisplayUnit; //导入依赖的package包/类
public Hashtable<String, DisplayUnit> getUserInputDisplays(){
    return userInputDisplays;
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:4,代码来源:QueryScreen.java


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