19 |
19 |
20 package org.hedgewars.hedgeroid.EngineProtocol; |
20 package org.hedgewars.hedgeroid.EngineProtocol; |
21 |
21 |
22 import java.io.File; |
22 import java.io.File; |
23 import java.util.ArrayList; |
23 import java.util.ArrayList; |
24 import java.util.Arrays; |
|
25 import java.util.Collections; |
24 import java.util.Collections; |
26 import java.util.HashMap; |
25 import java.util.HashMap; |
27 import java.util.List; |
26 import java.util.List; |
28 |
27 |
29 import org.hedgewars.hedgeroid.R; |
28 import org.hedgewars.hedgeroid.R; |
165 } |
164 } |
166 |
165 |
167 return data; |
166 return data; |
168 } |
167 } |
169 |
168 |
170 public static ArrayList<HashMap<String, Object>> getTeams(Context c){ |
169 public static List<HashMap<String, Object>> getTeams(Context c){ |
171 ArrayList<HashMap<String, Object>> ret = new ArrayList<HashMap<String, Object>>(); |
170 List<HashMap<String, Object>> ret = new ArrayList<HashMap<String, Object>>(); |
172 |
171 |
173 File teamsDir = new File(c.getFilesDir().getAbsolutePath() + '/' + Team.DIRECTORY_TEAMS); |
172 File teamsDir = new File(c.getFilesDir().getAbsolutePath() + '/' + Team.DIRECTORY_TEAMS); |
174 File[] teamFileNames = teamsDir.listFiles(); |
173 File[] teamFileNames = teamsDir.listFiles(); |
175 if(teamFileNames != null){ |
174 if(teamFileNames != null){ |
176 for(File s : teamFileNames){ |
175 for(File s : teamFileNames){ |
177 Team t = Team.getTeamFromXml(s.getAbsolutePath()); |
176 Team t = Team.getTeamFromXml(s.getAbsolutePath()); |
178 if(t != null){ |
177 if(t != null){ |
179 t.file = s.getName(); |
178 t.file = s.getName(); |
180 ret.add(teamToHashMap(t)); |
179 ret.add(teamToMap(t)); |
181 } |
180 } |
182 } |
181 } |
183 } |
182 } |
184 return ret; |
183 return ret; |
185 } |
184 } |
186 |
185 |
187 public static HashMap<String, Object> teamToHashMap(Team t){ |
186 public static HashMap<String, Object> teamToMap(Team t){ |
188 HashMap<String, Object> hashmap = new HashMap<String, Object>(); |
187 HashMap<String, Object> hashmap = new HashMap<String, Object>(); |
189 hashmap.put("team", t); |
188 hashmap.put("team", t); |
190 hashmap.put("txt", t.name); |
189 hashmap.put("txt", t.name); |
191 hashmap.put("color", t.color); |
190 hashmap.put("color", t.color); |
192 hashmap.put("count", t.hogCount); |
191 hashmap.put("count", t.hogCount); |