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(); } }
public NameClientTest(int n) { Game game = new Game(); Player human = new TestPlayer("Client" + n); try { NetworkHelper.populateClient(game, human, NetworkTest.IP); } catch (NetworkException e) { System.out.println(e.getMessage()); } LinkedList<Player> players = game.getPlayers(); for (int i = 0; i < players.size(); i++) { System.out.println(players.get(i).getName() + ": " + players.get(i).getColor() + "\n"); } }