@@ -126,14 +126,17 @@ public void login(final String username, final String password, final LoginListe
126
126
public void onResponse (Call <NianticService .LoginValues > call , Response <NianticService .LoginValues > response ) {
127
127
if (response .body () != null ) {
128
128
loginPTC (username , password , response .body (), loginListener );
129
- }else {
129
+ } else {
130
+ Log .e (TAG , "PTC login failed via login(). There was no response.body()." );
130
131
loginListener .authFailed ("Fetching Pokemon Trainer Club's Login Url Values Failed" );
131
132
}
132
133
133
134
}
134
135
135
136
@ Override
136
137
public void onFailure (Call <NianticService .LoginValues > call , Throwable t ) {
138
+ t .printStackTrace ();
139
+ Log .e (TAG , "PTC login failed via login(). valuesCallback.onFailure() threw: " + t .getMessage ());
137
140
loginListener .authFailed ("Fetching Pokemon Trainer Club's Login Url Values Failed" );
138
141
}
139
142
};
@@ -170,12 +173,15 @@ public void onResponse(Call<NianticService.LoginResponse> call, Response<Niantic
170
173
String ticket = location .split ("ticket=" )[1 ];
171
174
requestToken (ticket , loginListener );
172
175
} else {
176
+ Log .e (TAG , "PTC login failed via loginPTC(). There was no location header in response." );
173
177
loginListener .authFailed ("Pokemon Trainer Club Login Failed" );
174
178
}
175
179
}
176
180
177
181
@ Override
178
182
public void onFailure (Call <NianticService .LoginResponse > call , Throwable t ) {
183
+ t .printStackTrace ();
184
+ Log .e (TAG , "PTC login failed via loginPTC(). loginCallback.onFailure() threw: " + t .getMessage ());
179
185
loginListener .authFailed ("Pokemon Trainer Club Login Failed" );
180
186
}
181
187
};
@@ -204,17 +210,20 @@ public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response)
204
210
205
211
loginListener .authSuccessful (token );
206
212
} else {
213
+ Log .e (TAG , "PTC login failed while fetching a requestToken via requestToken(). Token is null." );
207
214
loginListener .authFailed ("Pokemon Trainer Club Login Failed" );
208
215
}
209
216
} catch (IOException e ) {
210
217
e .printStackTrace ();
218
+ Log .e (TAG , "PTC login failed while fetching a requestToken authCallback.onResponse() raised: " + e .getMessage ());
211
219
loginListener .authFailed ("Pokemon Trainer Club Authentication Failed" );
212
220
}
213
221
}
214
222
215
223
@ Override
216
224
public void onFailure (Call <ResponseBody > call , Throwable t ) {
217
225
t .printStackTrace ();
226
+ Log .e (TAG , "PTC login failed while fetching a requestToken authCallback.onResponse() threw: " + t .getMessage ());
218
227
loginListener .authFailed ("Pokemon Trainer Club Authentication Failed" );
219
228
}
220
229
};
@@ -239,7 +248,9 @@ public void run() {
239
248
mAuthInfo = new GoogleLogin (mPoGoClient ).login (token );
240
249
mPokemonGo = new PokemonGo (mAuthInfo , mPoGoClient );
241
250
EventBus .getDefault ().post (new LoginEventResult (true , mAuthInfo , mPokemonGo ));
242
- } catch (Exception e ) {
251
+ } catch (RemoteServerException | LoginFailedException | RuntimeException e ) {
252
+ e .printStackTrace ();
253
+ Log .e (TAG , "Setting google auth token failed. setGoogleAuthToken() raised: " + e .getMessage ());
243
254
EventBus .getDefault ().post (new LoginEventResult (false , null , null ));
244
255
}
245
256
}
@@ -258,7 +269,9 @@ public void run() {
258
269
mAuthInfo = new PtcLogin (mPoGoClient ).login (token );
259
270
mPokemonGo = new PokemonGo (mAuthInfo , mPoGoClient );
260
271
EventBus .getDefault ().post (new LoginEventResult (true , mAuthInfo , mPokemonGo ));
261
- } catch (Exception e ) {
272
+ } catch (RemoteServerException | LoginFailedException | RuntimeException e ) {
273
+ e .printStackTrace ();
274
+ Log .e (TAG , "Failed to set the PTC auth token on PoGoAPI via setPTCAuthToken(). Raised: " + e .getMessage ());
262
275
EventBus .getDefault ().post (new LoginEventResult (false , null , null ));
263
276
}
264
277
}
@@ -273,7 +286,9 @@ public void run() {
273
286
mAuthInfo = new PtcLogin (mPoGoClient ).login (username , password );
274
287
mPokemonGo = new PokemonGo (mAuthInfo , mPoGoClient );
275
288
EventBus .getDefault ().post (new LoginEventResult (true , mAuthInfo , mPokemonGo ));
276
- } catch (Exception e ) {
289
+ } catch (RemoteServerException | LoginFailedException | RuntimeException e ) {
290
+ e .printStackTrace ();
291
+ Log .e (TAG , "Failed to PTC login using PoGoAPI via login(). Raised: " + e .getMessage ());
277
292
EventBus .getDefault ().post (new LoginEventResult (false , null , null ));
278
293
}
279
294
}
@@ -285,23 +300,28 @@ public void getMapInformation(final double lat, final double longitude, final do
285
300
@ Override
286
301
public void run () {
287
302
try {
303
+
288
304
if (mPokemonGo != null ) {
289
305
290
- //This fixes Exception of missind ID
291
- Thread .sleep (50 );
306
+ Thread .sleep (33 );
292
307
mPokemonGo .setLocation (lat , longitude , alt );
293
- EventBus .getDefault ().post (new CatchablePokemonEvent (mPokemonGo .getMap ().getCatchablePokemon ()));
294
- EventBus .getDefault ().post (new PokestopsEvent (mPokemonGo .getMap ().getMapObjects ().getPokestops ()));
295
-
308
+ Thread .sleep (33 );
309
+ EventBus .getDefault ().post (new CatchablePokemonEvent (mPokemonGo .getMap ().getCatchablePokemon (), lat , longitude ));
310
+ Thread .sleep (33 );
311
+ EventBus .getDefault ().post (new PokestopsEvent (mPokemonGo .getMap ().getMapObjects ().getPokestops ()));
296
312
}
297
313
298
314
} catch (LoginFailedException e ) {
315
+ e .printStackTrace ();
316
+ Log .e (TAG , "Failed to fetch map information via getMapInformation(). Login credentials wrong or user banned. Raised: " + e .getMessage ());
299
317
EventBus .getDefault ().post (new LoginEventResult (false , null , null ));
300
318
} catch (RemoteServerException e ) {
319
+ e .printStackTrace ();
320
+ Log .e (TAG , "Failed to fetch map information via getMapInformation(). Remote server unreachable. Raised: " + e .getMessage ());
301
321
EventBus .getDefault ().post (new ServerUnreachableEvent (e ));
302
- } catch (NullPointerException e ) {
322
+ } catch (InterruptedException | RuntimeException e ) {
303
323
e .printStackTrace ();
304
- } catch ( Exception e ) {
324
+ Log . e ( TAG , "Failed to fetch map information via getMapInformation(). PoGoAPI crashed. Raised: " + e . getMessage ());
305
325
EventBus .getDefault ().post (new InternalExceptionEvent (e ));
306
326
}
307
327
}
0 commit comments