| 19 |
19 |
|
| 20 |
20 |
package org.distorted.magic;
|
| 21 |
21 |
|
| 22 |
|
import java.io.IOException;
|
| 23 |
22 |
import java.io.InputStream;
|
| 24 |
23 |
import java.net.HttpURLConnection;
|
| 25 |
24 |
import java.net.URL;
|
| ... | ... | |
| 31 |
30 |
interface Receiver
|
| 32 |
31 |
{
|
| 33 |
32 |
void receive(String[][][][] scores);
|
|
33 |
void exception(String exception);
|
| 34 |
34 |
}
|
| 35 |
35 |
|
| 36 |
36 |
static final int MAX_PLACES = 12;
|
| ... | ... | |
| 128 |
128 |
mValues[size][level][place][1] = name;
|
| 129 |
129 |
mValues[size][level][place][2] = realTime;
|
| 130 |
130 |
}
|
| 131 |
|
else
|
| 132 |
|
{
|
| 133 |
|
android.util.Log.e("fillRow", "row invalid: level or place invalid: "+row);
|
| 134 |
|
}
|
| 135 |
|
}
|
| 136 |
|
else
|
| 137 |
|
{
|
| 138 |
|
android.util.Log.e("fillRow", "row invalid: size invalid: "+row);
|
| 139 |
131 |
}
|
| 140 |
132 |
}
|
| 141 |
|
else
|
| 142 |
|
{
|
| 143 |
|
android.util.Log.e("fillRow", "row invalid: "+row);
|
| 144 |
|
}
|
| 145 |
133 |
}
|
| 146 |
134 |
|
| 147 |
135 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| ... | ... | |
| 183 |
171 |
|
| 184 |
172 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 185 |
173 |
|
| 186 |
|
private void doDownload()
|
|
174 |
private boolean doDownload()
|
| 187 |
175 |
{
|
| 188 |
176 |
String veri = "distored";
|
| 189 |
177 |
String name = URLencode(veri);
|
| ... | ... | |
| 203 |
191 |
conn.connect();
|
| 204 |
192 |
conn.getOutputStream().flush();
|
| 205 |
193 |
|
| 206 |
|
InputStream is = null;
|
| 207 |
|
|
| 208 |
|
try
|
|
194 |
try( InputStream is = conn.getInputStream() )
|
| 209 |
195 |
{
|
| 210 |
|
is = conn.getInputStream();
|
| 211 |
196 |
int ch;
|
| 212 |
197 |
StringBuilder sb = new StringBuilder();
|
| 213 |
198 |
while( ( ch = is.read() ) != -1 )
|
| ... | ... | |
| 218 |
203 |
}
|
| 219 |
204 |
catch(Exception e)
|
| 220 |
205 |
{
|
| 221 |
|
android.util.Log.e("downloader", "biffed it getting HTTPResponse");
|
| 222 |
|
}
|
| 223 |
|
finally
|
| 224 |
|
{
|
| 225 |
|
try
|
| 226 |
|
{
|
| 227 |
|
if (is != null)
|
| 228 |
|
is.close();
|
| 229 |
|
}
|
| 230 |
|
catch (Exception e) {}
|
|
206 |
mReceiver.exception("biffed it getting HTTPResponse");
|
|
207 |
return false;
|
| 231 |
208 |
}
|
| 232 |
209 |
}
|
| 233 |
|
catch( IOException ioe )
|
| 234 |
|
{
|
| 235 |
|
android.util.Log.e("downloader", "IOException: "+ioe.getMessage());
|
| 236 |
|
}
|
| 237 |
|
catch( SecurityException se )
|
|
210 |
catch( Exception e )
|
| 238 |
211 |
{
|
| 239 |
|
android.util.Log.e("downloader", "SecurityException: "+se.getMessage());
|
|
212 |
mReceiver.exception(e.getMessage());
|
|
213 |
return false;
|
| 240 |
214 |
}
|
| 241 |
215 |
|
| 242 |
|
/*
|
| 243 |
|
mScores =
|
| 244 |
|
|
| 245 |
|
"0 0 0 INEED7X7X7 1 rus" + "\n" +
|
| 246 |
|
"0 0 1 Tilly 1 uk" + "\n" +
|
| 247 |
|
"0 0 2 ARNOLD 1 rus" + "\n" +
|
| 248 |
|
"0 0 3 ALBERTO 1 mex" + "\n" +
|
| 249 |
|
"0 0 4 TO 1 ger" + "\n" +
|
| 250 |
|
"0 1 0 INEED7X7X7 1 rus" + "\n" +
|
| 251 |
|
"0 1 1 Tilly 1 uk" + "\n" +
|
| 252 |
|
"0 1 2 ALBERTO 1 mex" + "\n" +
|
| 253 |
|
"0 1 3 RINAT 1 rus" + "\n" +
|
| 254 |
|
"0 1 4 BOOW 1 tha" + "\n" +
|
| 255 |
|
"0 2 0 Neriel 3 bra" + "\n" +
|
| 256 |
|
"0 2 1 NPPN 3 vie" + "\n" +
|
| 257 |
|
"0 2 2 FREDRIK 4 den" + "\n" +
|
| 258 |
|
"0 2 3 OHIOCUBER 4 usa" + "\n" +
|
| 259 |
|
"0 2 4 S13 4 usa" + "\n" +
|
| 260 |
|
"0 3 0 NIKITOS 8 rus" + "\n" +
|
| 261 |
|
"0 3 1 THISNAVIS 8 usa" + "\n" +
|
| 262 |
|
"0 3 2 MDR04 9 ita" + "\n" +
|
| 263 |
|
"0 3 3 ROBERT04 9 unk" + "\n" +
|
| 264 |
|
"0 3 4 DULCE 10 mex" + "\n" +
|
| 265 |
|
"1 0 0 INEED7X7X7 1 rus" + "\n" +
|
| 266 |
|
"1 0 1 Tilly 1 uk" + "\n" +
|
| 267 |
|
"1 0 2 REBECCA 1 fra" + "\n" +
|
| 268 |
|
"1 0 3 PRAKOBKRIT 1 tha" + "\n" +
|
| 269 |
|
"1 0 4 E 1 mex" + "\n" +
|
| 270 |
|
"1 1 0 BAYLEY 3 usa" + "\n" +
|
| 271 |
|
"1 1 1 DEMONAIRE 3 uk" + "\n" +
|
| 272 |
|
"1 1 2 UMMWT 3 ina" + "\n" +
|
| 273 |
|
"1 1 3 MDR04 4 ita" + "\n" +
|
| 274 |
|
"1 1 4 FREDRIK 4 den" + "\n" +
|
| 275 |
|
"1 2 0 HAGER 5 egy" + "\n" +
|
| 276 |
|
"1 2 1 S13 7 usa" + "\n" +
|
| 277 |
|
"1 2 2 UTEK 7 ina" + "\n" +
|
| 278 |
|
"1 2 3 UMMWT 7 ina" + "\n" +
|
| 279 |
|
"1 2 4 210JITQU 7 ukr" + "\n" +
|
| 280 |
|
"1 3 0 UTEK 16 ina" + "\n" +
|
| 281 |
|
"1 3 1 LOLO766 21 fra" + "\n" +
|
| 282 |
|
"1 3 2 NIKITOS 21 rus" + "\n" +
|
| 283 |
|
"1 3 3 PYCUK1707 21 rus" + "\n" +
|
| 284 |
|
"1 3 4 KEDAR 22 ind" + "\n" +
|
| 285 |
|
"2 0 0 INEED7X7X7 1 rus" + "\n" +
|
| 286 |
|
"2 0 1 HOMER0815 1 ger" + "\n" +
|
| 287 |
|
"2 0 2 EIP 1 usa" + "\n" +
|
| 288 |
|
"2 0 3 THEBIGBOSS 1 fra" + "\n" +
|
| 289 |
|
"2 0 4 PHONG 1 vie" + "\n" +
|
| 290 |
|
"2 1 0 SATERNSPY9 3 unk" + "\n" +
|
| 291 |
|
"2 1 1 S13 4 usa" + "\n" +
|
| 292 |
|
"2 1 2 ALSOELAN 4 usa" + "\n" +
|
| 293 |
|
"2 1 3 NIKITOS 4 rus" + "\n" +
|
| 294 |
|
"2 1 4 SEPIA6MIRA 4 unk" + "\n" +
|
| 295 |
|
"2 2 0 STEVE123 9 irl" + "\n" +
|
| 296 |
|
"2 2 1 NIKITOS 9 rus" + "\n" +
|
| 297 |
|
"2 2 2 SEPIA6MIRA 9 unk" + "\n" +
|
| 298 |
|
"2 2 3 INEED7X7X7 10 rus" + "\n" +
|
| 299 |
|
"2 2 4 S13 10 usa" + "\n" +
|
| 300 |
|
"2 3 0 NIKITOS 22 rus" + "\n" +
|
| 301 |
|
"2 3 1 RUBIK123 24 lit" + "\n" +
|
| 302 |
|
"2 3 2 NONAME 24 fin" + "\n" +
|
| 303 |
|
"2 3 3 ABB0 26 ind" + "\n" +
|
| 304 |
|
"2 3 4 NOYS 27 mex" + "\n" +
|
| 305 |
|
"3 0 0 JARO 1 ger" + "\n" +
|
| 306 |
|
"3 0 1 INEED7X7X7 1 rus" + "\n" +
|
| 307 |
|
"3 0 2 MDR04 1 ita" + "\n" +
|
| 308 |
|
"3 0 3 SAMW 1 uk" + "\n" +
|
| 309 |
|
"3 0 4 MOKAI88 1 den" + "\n" +
|
| 310 |
|
"3 1 0 MDR04G 3 ita" + "\n" +
|
| 311 |
|
"3 1 1 INEED7X7X7 4 rus" + "\n" +
|
| 312 |
|
"3 1 2 S13 4 usa" + "\n" +
|
| 313 |
|
"3 1 3 KARAVAN 4 rus" + "\n" +
|
| 314 |
|
"3 1 4 AWSOME897 4 usa" + "\n" +
|
| 315 |
|
"3 2 0 INEED7X7X7 8 rus" + "\n" +
|
| 316 |
|
"3 2 1 KARAVAN 8 rus" + "\n" +
|
| 317 |
|
"3 2 2 S13 9 usa" + "\n" +
|
| 318 |
|
"3 2 3 ALSOELAN 9 usa" + "\n" +
|
| 319 |
|
"3 2 4 ROBERT04 9 unk" + "\n" +
|
| 320 |
|
"3 3 0 NIKITOS 23 rus" + "\n" +
|
| 321 |
|
"3 3 1 THISNAVIS 23 usa" + "\n" +
|
| 322 |
|
"3 3 2 INEED7X7X7 24 rus" + "\n" +
|
| 323 |
|
"3 3 3 RUBIK123 30 lit" + "\n" +
|
| 324 |
|
"3 3 4 SKY16 31 usa";
|
| 325 |
|
|
| 326 |
|
*/
|
|
216 |
return true;
|
| 327 |
217 |
}
|
| 328 |
218 |
|
| 329 |
219 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| ... | ... | |
| 355 |
245 |
|
| 356 |
246 |
public void run()
|
| 357 |
247 |
{
|
|
248 |
boolean success=true;
|
|
249 |
|
| 358 |
250 |
try
|
| 359 |
251 |
{
|
| 360 |
252 |
if( gottaDownload() )
|
| 361 |
253 |
{
|
| 362 |
254 |
mRunning = true;
|
| 363 |
|
doDownload();
|
|
255 |
success = doDownload();
|
| 364 |
256 |
fillValues();
|
| 365 |
257 |
}
|
| 366 |
258 |
}
|
| ... | ... | |
| 370 |
262 |
}
|
| 371 |
263 |
|
| 372 |
264 |
mRunning = false;
|
| 373 |
|
mReceiver.receive(mValues);
|
|
265 |
|
|
266 |
if( success )
|
|
267 |
{
|
|
268 |
mReceiver.receive(mValues);
|
|
269 |
}
|
| 374 |
270 |
}
|
| 375 |
271 |
}
|
Downloading High Scores: actually downloading scores!