use of com.omkarmoghe.pokemap.models.events.LurePokemonEvent in project Pokemap by omkarmoghe.
the class NianticManager method getLuredPokemon.
public void getLuredPokemon(final double lat, final double longitude, final double alt) {
final int myCurrentBatch = this.currentBatchCall;
mHandler.post(new Runnable() {
@Override
public void run() {
try {
if (mPokemonGo != null && NianticManager.this.currentBatchCall == myCurrentBatch) {
Thread.sleep(133);
mPokemonGo.setLocation(lat, longitude, alt);
Thread.sleep(133);
List<CatchablePokemon> pokemon = new ArrayList<>();
for (Pokestop pokestop : mPokemonGo.getMap().getMapObjects().getPokestops()) {
if (!pokestop.getFortData().getLureInfo().equals(FortLureInfoOuterClass.FortLureInfo.getDefaultInstance())) {
Log.d(TAG, "run: hasFortInfo = " + pokestop.getFortData().getLureInfo());
pokemon.add(new CatchablePokemon(mPokemonGo, pokestop.getFortData()));
}
}
if (NianticManager.this.currentBatchCall == myCurrentBatch)
EventBus.getDefault().post(new LurePokemonEvent(pokemon, lat, longitude));
}
} catch (LoginFailedException e) {
e.printStackTrace();
Log.e(TAG, "Failed to fetch map information via getPokeStops(). Login credentials wrong or user banned. Raised: " + e.getMessage());
EventBus.getDefault().post(new LoginEventResult(false, null, null));
} catch (RemoteServerException e) {
e.printStackTrace();
Log.e(TAG, "Failed to fetch map information via getPokeStops(). Remote server unreachable. Raised: " + e.getMessage());
EventBus.getDefault().post(new ServerUnreachableEvent(e));
} catch (InterruptedException | RuntimeException e) {
e.printStackTrace();
Log.e(TAG, "Failed to fetch map information via getPokeStops(). PoGoAPI crashed. Raised: " + e.getMessage());
EventBus.getDefault().post(new InternalExceptionEvent(e));
}
}
});
}
Aggregations