Exemplo n.º 1
0
  private void loadData() {
    String str = NetworkHelper.getSingleThreadEntity(MAINQUEST_ENDPOINT_URL);

    try {
      JSONArray jArray = new JSONArray(str);
      if (jArray != null) {
        int length = jArray.length();
        for (int i = 0; i < length; i++) {
          int id = jArray.getJSONObject(i).getInt("id");
          String title = jArray.getJSONObject(i).getString("title");
          String xp = jArray.getJSONObject(i).getString("xp");
          String dueDate = jArray.getJSONObject(i).getString("date");
          String overview = jArray.getJSONObject(i).getString("overview");
          Adventure adventure = new Adventure(id, title, xp, dueDate, overview);
          if (adventure.isMainQuest()) {
            mainQuests.add(adventure);
          }
        }
      }

      Adventure[] mainQuestsArray = mainQuests.toArray(new Adventure[mainQuests.size()]);
      ArrayAdapter<Adventure> arrayAdapter =
          new ArrayAdapter<Adventure>(getActivity(), R.layout.list_item, mainQuestsArray);
      listView.setAdapter(arrayAdapter);

    } catch (JSONException e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 2
0
  public static void main(String[] args) {
    String filename = args[0];
    // System.out.println(filename);

    Adventure newAdventure = new Adventure();

    newAdventure.startAdventure(filename);
  }