11
11
import android .support .annotation .NonNull ;
12
12
import android .util .Log ;
13
13
14
+ import com .omkarmoghe .pokemap .models .events .GymsEvent ;
14
15
import com .omkarmoghe .pokemap .models .events .InternalExceptionEvent ;
15
16
import com .omkarmoghe .pokemap .models .events .LoginEventResult ;
16
17
import com .omkarmoghe .pokemap .models .events .PokestopsEvent ;
27
28
28
29
import java .io .IOException ;
29
30
import java .util .ArrayList ;
31
+ import java .util .Collection ;
30
32
import java .util .HashMap ;
31
33
import java .util .List ;
32
34
import java .util .concurrent .TimeUnit ;
33
35
import java .util .logging .Logger ;
34
36
37
+ import POGOProtos .Map .Fort .FortDataOuterClass ;
35
38
import POGOProtos .Networking .Envelopes .RequestEnvelopeOuterClass .RequestEnvelope .AuthInfo ;
36
39
37
40
import okhttp3 .Cookie ;
@@ -295,7 +298,7 @@ public void run() {
295
298
});
296
299
}
297
300
298
- public void getMapInformation (final double lat , final double longitude , final double alt ){
301
+ public void getCatchablePokemon (final double lat , final double longitude , final double alt ){
299
302
mHandler .post (new Runnable () {
300
303
@ Override
301
304
public void run () {
@@ -307,25 +310,83 @@ public void run() {
307
310
mPokemonGo .setLocation (lat , longitude , alt );
308
311
Thread .sleep (33 );
309
312
EventBus .getDefault ().post (new CatchablePokemonEvent (mPokemonGo .getMap ().getCatchablePokemon (), lat , longitude ));
313
+ }
314
+
315
+ } catch (LoginFailedException e ) {
316
+ e .printStackTrace ();
317
+ Log .e (TAG , "Failed to fetch map information via getCatchablePokemon(). Login credentials wrong or user banned. Raised: " + e .getMessage ());
318
+ EventBus .getDefault ().post (new LoginEventResult (false , null , null ));
319
+ } catch (RemoteServerException e ) {
320
+ e .printStackTrace ();
321
+ Log .e (TAG , "Failed to fetch map information via getCatchablePokemon(). Remote server unreachable. Raised: " + e .getMessage ());
322
+ EventBus .getDefault ().post (new ServerUnreachableEvent (e ));
323
+ } catch (InterruptedException | RuntimeException e ) {
324
+ e .printStackTrace ();
325
+ Log .e (TAG , "Failed to fetch map information via getCatchablePokemon(). PoGoAPI crashed. Raised: " + e .getMessage ());
326
+ EventBus .getDefault ().post (new InternalExceptionEvent (e ));
327
+ }
328
+ }
329
+ });
330
+ }
331
+
332
+ public void getPokeStops (final double lat , final double longitude , final double alt ){
333
+ mHandler .post (new Runnable () {
334
+ @ Override
335
+ public void run () {
336
+ try {
337
+
338
+ if (mPokemonGo != null ) {
339
+
310
340
Thread .sleep (33 );
311
341
EventBus .getDefault ().post (new PokestopsEvent (mPokemonGo .getMap ().getMapObjects ().getPokestops ()));
312
342
}
313
343
314
344
} catch (LoginFailedException e ) {
315
345
e .printStackTrace ();
316
- Log .e (TAG , "Failed to fetch map information via getMapInformation (). Login credentials wrong or user banned. Raised: " + e .getMessage ());
346
+ Log .e (TAG , "Failed to fetch map information via getPokeStops (). Login credentials wrong or user banned. Raised: " + e .getMessage ());
317
347
EventBus .getDefault ().post (new LoginEventResult (false , null , null ));
318
348
} catch (RemoteServerException e ) {
319
349
e .printStackTrace ();
320
- Log .e (TAG , "Failed to fetch map information via getMapInformation (). Remote server unreachable. Raised: " + e .getMessage ());
350
+ Log .e (TAG , "Failed to fetch map information via getPokeStops (). Remote server unreachable. Raised: " + e .getMessage ());
321
351
EventBus .getDefault ().post (new ServerUnreachableEvent (e ));
322
352
} catch (InterruptedException | RuntimeException e ) {
323
353
e .printStackTrace ();
324
- Log .e (TAG , "Failed to fetch map information via getMapInformation (). PoGoAPI crashed. Raised: " + e .getMessage ());
354
+ Log .e (TAG , "Failed to fetch map information via getPokeStops (). PoGoAPI crashed. Raised: " + e .getMessage ());
325
355
EventBus .getDefault ().post (new InternalExceptionEvent (e ));
326
356
}
327
357
}
328
358
});
329
359
}
330
360
361
+ public void getGyms (final double latitude , final double longitude , final double alt ) {
362
+
363
+ mHandler .post (new Runnable () {
364
+ @ Override
365
+ public void run () {
366
+ try {
367
+
368
+ if (mPokemonGo != null ) {
369
+
370
+ Thread .sleep (33 );
371
+ mPokemonGo .setLocation (latitude , longitude , alt );
372
+ Thread .sleep (33 );
373
+ EventBus .getDefault ().post (new GymsEvent (mPokemonGo .getMap ().getMapObjects ().getGyms ()));
374
+ }
375
+
376
+ } catch (LoginFailedException e ) {
377
+ e .printStackTrace ();
378
+ Log .e (TAG , "Failed to fetch map information via getGyms(). Login credentials wrong or user banned. Raised: " + e .getMessage ());
379
+ EventBus .getDefault ().post (new LoginEventResult (false , null , null ));
380
+ } catch (RemoteServerException e ) {
381
+ e .printStackTrace ();
382
+ Log .e (TAG , "Failed to fetch map information via getGyms(). Remote server unreachable. Raised: " + e .getMessage ());
383
+ EventBus .getDefault ().post (new ServerUnreachableEvent (e ));
384
+ } catch (InterruptedException | RuntimeException e ) {
385
+ e .printStackTrace ();
386
+ Log .e (TAG , "Failed to fetch map information via getGyms(). PoGoAPI crashed. Raised: " + e .getMessage ());
387
+ EventBus .getDefault ().post (new InternalExceptionEvent (e ));
388
+ }
389
+ }
390
+ });
391
+ }
331
392
}
0 commit comments