116 } |
116 } |
117 public static ArrayList<HashMap<String, ?>> getTypes(Context c){ |
117 public static ArrayList<HashMap<String, ?>> getTypes(Context c){ |
118 ArrayList<HashMap<String, ?>> data = new ArrayList<HashMap<String, ?>>(6); |
118 ArrayList<HashMap<String, ?>> data = new ArrayList<HashMap<String, ?>>(6); |
119 String[] levels = {c.getString(R.string.human), c.getString(R.string.bot5), c.getString(R.string.bot4), c.getString(R.string.bot3), c.getString(R.string.bot2), c.getString(R.string.bot1)}; |
119 String[] levels = {c.getString(R.string.human), c.getString(R.string.bot5), c.getString(R.string.bot4), c.getString(R.string.bot3), c.getString(R.string.bot2), c.getString(R.string.bot1)}; |
120 int[] images = {R.drawable.human, R.drawable.bot5, R.drawable.bot4, R.drawable.bot3, R.drawable.bot2, R.drawable.bot1}; |
120 int[] images = {R.drawable.human, R.drawable.bot5, R.drawable.bot4, R.drawable.bot3, R.drawable.bot2, R.drawable.bot1}; |
121 |
121 |
122 for(int i = 0; i < levels.length; i++){ |
122 for(int i = 0; i < levels.length; i++){ |
123 HashMap<String, Object> map = new HashMap<String, Object>(); |
123 HashMap<String, Object> map = new HashMap<String, Object>(); |
124 map.put("txt", levels[i]); |
124 map.put("txt", levels[i]); |
125 map.put("img", images[i]); |
125 map.put("img", images[i]); |
126 data.add(map); |
126 data.add(map); |
127 } |
127 } |
128 |
128 |
129 return data; |
129 return data; |
130 } |
130 } |
131 |
131 |
132 public static ArrayList<HashMap<String, ?>> getHats(Context c){ |
132 public static ArrayList<HashMap<String, ?>> getHats(Context c){ |
133 ArrayList<String> files = Utils.getFilesFromDirWithSuffix(c, "Graphics/Hats", ".png", true); |
133 ArrayList<String> files = Utils.getFilesFromDirWithSuffix(c, "Graphics/Hats", ".png", true); |
134 String pathPrefix = Utils.getDownloadPath(c) + "Graphics/Hats/"; |
134 String pathPrefix = Utils.getDownloadPath(c) + "Graphics/Hats/"; |
135 int size = files.size(); |
135 int size = files.size(); |
136 ArrayList<HashMap<String, ?>> data = new ArrayList<HashMap<String, ?>>(size); |
136 ArrayList<HashMap<String, ?>> data = new ArrayList<HashMap<String, ?>>(size); |
137 |
137 |
138 HashMap<String, Object> hashmap; |
138 HashMap<String, Object> hashmap; |
139 for(String s : files){ |
139 for(String s : files){ |
140 hashmap = new HashMap<String, Object>(); |
140 hashmap = new HashMap<String, Object>(); |
141 hashmap.put("txt", s); |
141 hashmap.put("txt", s); |
142 Bitmap b = BitmapFactory.decodeFile(pathPrefix + s + ".png");//create a full path - decode to to a bitmap |
142 Bitmap b = BitmapFactory.decodeFile(pathPrefix + s + ".png");//create a full path - decode to to a bitmap |
143 b = Bitmap.createBitmap(b, 0,0,b.getWidth()/2, b.getWidth()/2); |
143 b = Bitmap.createBitmap(b, 0,0,b.getWidth()/2, b.getWidth()/2); |
144 hashmap.put("img", b); |
144 hashmap.put("img", b); |
145 data.add(hashmap); |
145 data.add(hashmap); |
146 } |
146 } |
147 |
147 |
148 return data; |
148 return data; |
149 } |
149 } |
150 |
150 |
151 public static ArrayList<HashMap<String, ?>> getTeams(Context c){ |
151 public static ArrayList<HashMap<String, ?>> getTeams(Context c){ |
152 ArrayList<HashMap<String, ?>> ret = new ArrayList<HashMap<String, ?>>(); |
152 ArrayList<HashMap<String, ?>> ret = new ArrayList<HashMap<String, ?>>(); |
153 |
153 |
154 File teamsDir = new File(c.getFilesDir().getAbsolutePath() + '/' + Team.DIRECTORY_TEAMS); |
154 File teamsDir = new File(c.getFilesDir().getAbsolutePath() + '/' + Team.DIRECTORY_TEAMS); |
155 File[] teamFileNames = teamsDir.listFiles(); |
155 File[] teamFileNames = teamsDir.listFiles(); |
156 |
156 if(teamsDir != null){ |
157 for(File s : teamFileNames){ |
157 for(File s : teamFileNames){ |
158 Team t = Team.getTeamFromXml(s.getAbsolutePath()); |
158 Team t = Team.getTeamFromXml(s.getAbsolutePath()); |
159 if(t != null){ |
159 if(t != null){ |
160 ret.add(teamToHashMap(t)); |
160 ret.add(teamToHashMap(t)); |
|
161 } |
161 } |
162 } |
162 } |
163 } |
163 return ret; |
164 return ret; |
164 } |
165 } |
165 |
166 |
166 public static HashMap<String, Object> teamToHashMap(Team t){ |
167 public static HashMap<String, Object> teamToHashMap(Team t){ |
167 HashMap<String, Object> hashmap = new HashMap<String, Object>(); |
168 HashMap<String, Object> hashmap = new HashMap<String, Object>(); |
168 hashmap.put("team", t); |
169 hashmap.put("team", t); |
169 hashmap.put("txt", t.name); |
170 hashmap.put("txt", t.name); |
170 switch(t.levels[0]){ |
171 switch(t.levels[0]){ |