Пример #1
0
  @Override
  public void endElement(String uri, String localName, String qName) throws SAXException {
    curElem = false;
    curValue = curValue.trim();

    // check for a known tag
    if (qName.equals("name")) {
      curMission.setName(curValue);
    } else if (qName.equals("players")) {
      curMission.setPlayers(curValue);
    } else if (qName.equals("time-limit")) {
      curMission.setTime(curValue, true);
    } else if (qName.equals("time")) {
      curMission.setTime(curValue, false);
    } else if (qName.equals("info")) {
      curMission.setInfo(curValue);
    } else if (qName.equals("mission")) {
      // Log.v(tag, "Adding mission " + curName + " (" + curMission.getName() + ")");
      data.put(curName, curMission);
      curName = "";
      curMission = null;
    } else if (qName.equals("details")) {
      mLoaded = true;
    }

    curValue = "";
  }
Пример #2
0
  @Override
  public void startElement(String uri, String localName, String qName, Attributes attributes)
      throws SAXException {
    curElem = true;

    // check for a known tag
    if (qName.equals("details")) {
      data = new HashMap<String, MissionInfo>();
      mLoaded = false;
    } else if (qName.equals("mission")) {
      curName = attributes.getValue("id");
      curMission = new MissionInfo();
      curMission.setName(curName);
    } else if (qName.equals("reward")) {
      int level = Integer.parseInt(attributes.getValue("level"));
      int exp = Integer.parseInt(attributes.getValue("exp"));
      int gold = Integer.parseInt(attributes.getValue("gold"));
      curMission.setExp(level, exp);
      curMission.setGold(level, gold);

      // Log.v(tag, String.format("Diff: %d, %d, %d", level, exp, gold));
    }
  }