public String[] bindListView(Admin userData) { // userName, firstName, lastName ArrayList<String> userArray = new ArrayList<String>(); for (HashMap<String, String> user : userData.getUsers()) { if ((user.get("firstName") != null) && (user.get("lastName") != null) && (user.get("userName") != null)) userArray.add( user.get("firstName") + " " + user.get("lastName") + "\n" + user.get("userName")); } String[] users = new String[userArray.size()]; users = userArray.toArray(users); return users; }
protected String[] doInBackground(Void... params) { Admin admin = new Admin(); AdminRequest rest = new AdminRequest(context); try { admin = rest.getUsers(); if (!admin.getUsers().isEmpty()) { return bindListView(admin); } } catch (Exception e) { Intent intent = new Intent(context, Login.class); startActivity(intent); } return new String[0]; }