77
77
public class PokemonGo {
78
78
private static final java .lang .String TAG = PokemonGo .class .getSimpleName ();
79
79
private final Time time ;
80
+ private News news ;
80
81
@ Getter
81
82
public long startTime ;
82
83
@ Getter
83
- private final byte [] sessionHash = new byte [32 ];
84
+ public final byte [] sessionHash = new byte [32 ];
84
85
@ Getter
85
86
public RequestHandler requestHandler ;
86
87
@ Getter
@@ -89,7 +90,6 @@ public class PokemonGo {
89
90
public Inventories inventories ;
90
91
@ Getter
91
92
public double latitude ;
92
- private News news ;
93
93
@ Getter
94
94
public double longitude ;
95
95
@ Getter
@@ -159,8 +159,8 @@ public class PokemonGo {
159
159
* Instantiates a new Pokemon go.
160
160
*
161
161
* @param client the http client
162
- * @param time a time implementation
163
- * @param seed the seed to generate same device
162
+ * @param time a time implementation
163
+ * @param seed the seed to generate same device
164
164
*/
165
165
public PokemonGo (OkHttpClient client , Time time , long seed ) {
166
166
this .time = time ;
@@ -176,7 +176,7 @@ public PokemonGo(OkHttpClient client, Time time, long seed) {
176
176
* Deprecated: specify a time implementation
177
177
*
178
178
* @param client the http client
179
- * @param seed the seed to generate same device
179
+ * @param seed the seed to generate same device
180
180
*/
181
181
public PokemonGo (OkHttpClient client , long seed ) {
182
182
this (client , new SystemTimeImpl (), seed );
@@ -187,7 +187,7 @@ public PokemonGo(OkHttpClient client, long seed) {
187
187
* Deprecated: specify a time implementation
188
188
*
189
189
* @param client the http client
190
- * @param time a time implementation
190
+ * @param time a time implementation
191
191
*/
192
192
public PokemonGo (OkHttpClient client , Time time ) {
193
193
this (client , time , hash (UUID .randomUUID ().toString ()));
@@ -207,7 +207,7 @@ public PokemonGo(OkHttpClient client) {
207
207
* Login user with the provided provider
208
208
*
209
209
* @param credentialProvider the credential provider
210
- * @param hashProvider to provide hashes
210
+ * @param hashProvider to provide hashes
211
211
* @throws RequestFailedException if an exception occurred while sending requests
212
212
*/
213
213
public void login (CredentialProvider credentialProvider , HashProvider hashProvider )
@@ -237,8 +237,8 @@ private void reset() {
237
237
active = false ;
238
238
new Random ().nextBytes (sessionHash );
239
239
inventories = new Inventories (this );
240
- news = new News (this );
241
- settings = new Settings (this );
240
+ news = new News (this );
241
+ settings = new Settings (this );
242
242
playerProfile = new PlayerProfile (this );
243
243
map = new Map (this );
244
244
longitude = Double .NaN ;
@@ -293,27 +293,29 @@ private void initialize() throws RequestFailedException {
293
293
294
294
requestHandler .sendServerRequests (envelope );
295
295
296
- try {
297
- FetchAllNewsMessageOuterClass .FetchAllNewsMessage msg = FetchAllNewsMessageOuterClass .FetchAllNewsMessage .newBuilder ().build ();
298
- ServerRequest request = new ServerRequest (RequestType .FETCH_ALL_NEWS , msg );
299
- envelope = ServerRequestEnvelope .create (request );
300
- getRequestHandler ().sendServerRequests (envelope );
301
- FetchAllNewsResponseOuterClass .FetchAllNewsResponse response = FetchAllNewsResponseOuterClass .FetchAllNewsResponse .parseFrom (request .getData ());
302
- if (response .getResult () == FetchAllNewsResponseOuterClass .FetchAllNewsResponse .Result .SUCCESS ) {
303
- Log .i (TAG , "FetchAllNewsMessage Success: total News=" + response .getCurrentNews ().getNewsArticlesCount ());
304
- this .news .setCurrentNews (response .getCurrentNews ());
305
-
306
- // mark all un-read new to read
307
- this .news .markUnreadNews ();
308
- } else {
309
- Log .d (TAG , "FetchAllNewsMessage Failed. Result=" + response .getResult ());
310
- }
311
- } catch (Exception e ) {
312
- Log .d (TAG , "Exceptions FetchAllNew" );
313
- }
314
-
296
+ try {
297
+ FetchAllNewsMessageOuterClass .FetchAllNewsMessage msg = FetchAllNewsMessageOuterClass .FetchAllNewsMessage
298
+ .newBuilder ().build ();
299
+ ServerRequest request = new ServerRequest (RequestType .FETCH_ALL_NEWS , msg );
300
+ envelope = ServerRequestEnvelope .create (request );
301
+ requestHandler .sendServerRequests (envelope );
302
+ FetchAllNewsResponseOuterClass .FetchAllNewsResponse response = FetchAllNewsResponseOuterClass
303
+ .FetchAllNewsResponse .parseFrom (request .getData ());
304
+ if (response .getResult () == FetchAllNewsResponseOuterClass .FetchAllNewsResponse .Result .SUCCESS ) {
305
+ Log .i (TAG , "FetchAllNewsMessage Success: total News=" + response .getCurrentNews ()
306
+ .getNewsArticlesCount ());
307
+ this .news .setCurrentNews (response .getCurrentNews ());
308
+
309
+ // mark all un-read new to read
310
+ this .news .markUnreadNews ();
311
+ } else {
312
+ Log .d (TAG , "FetchAllNewsMessage Failed. Result=" + response .getResult ());
313
+ }
314
+ } catch (Exception e ) {
315
+ Log .d (TAG , "Exceptions FetchAllNew" );
316
+ }
315
317
316
- List <LoginListener > loginListeners = getListeners (LoginListener .class );
318
+ List <LoginListener > loginListeners = getListeners (LoginListener .class );
317
319
318
320
for (LoginListener listener : loginListeners ) {
319
321
listener .onLogin (this );
@@ -392,9 +394,9 @@ public AuthInfo getAuthInfo(boolean refresh)
392
394
/**
393
395
* Sets location.
394
396
*
395
- * @param latitude the latitude
397
+ * @param latitude the latitude
396
398
* @param longitude the longitude
397
- * @param altitude the altitude
399
+ * @param altitude the altitude
398
400
*/
399
401
public void setLocation (double latitude , double longitude , double altitude ) {
400
402
setLocation (latitude , longitude , altitude , accuracy );
@@ -403,10 +405,10 @@ public void setLocation(double latitude, double longitude, double altitude) {
403
405
/**
404
406
* Sets location with accuracy.
405
407
*
406
- * @param latitude the latitude
408
+ * @param latitude the latitude
407
409
* @param longitude the longitude
408
- * @param altitude the altitude
409
- * @param accuracy the accuracy of this location
410
+ * @param altitude the altitude
411
+ * @param accuracy the accuracy of this location
410
412
*/
411
413
public void setLocation (double latitude , double longitude , double altitude , double accuracy ) {
412
414
setLatitude (latitude );
@@ -498,7 +500,7 @@ public SignatureOuterClass.Signature.DeviceInfo getDeviceInfo() {
498
500
* Gets the sensor info
499
501
*
500
502
* @param currentTime the current time
501
- * @param random the random object
503
+ * @param random the random object
502
504
* @return the sensor info
503
505
*/
504
506
public SignatureOuterClass .Signature .SensorInfo getSensorSignature (long currentTime , Random random ) {
@@ -536,7 +538,7 @@ public void setItemTemplateProvider(ItemTemplateProvider provider) {
536
538
/**
537
539
* Updates the current challenge
538
540
*
539
- * @param url the challenge url, if any
541
+ * @param url the challenge url, if any
540
542
* @param hasChallenge whether the challenge solve is required
541
543
*/
542
544
public void updateChallenge (String url , boolean hasChallenge ) {
@@ -576,7 +578,7 @@ public void removeListener(Listener listener) {
576
578
* Returns all listeners for the given type.
577
579
*
578
580
* @param listenerType the type of listeners to return
579
- * @param <T> the listener type
581
+ * @param <T> the listener type
580
582
* @return all listeners for the given type
581
583
*/
582
584
public <T extends Listener > List <T > getListeners (Class <T > listenerType ) {
@@ -595,9 +597,9 @@ public <T extends Listener> List<T> getListeners(Class<T> listenerType) {
595
597
* Invokes a method in all listeners of the given type
596
598
*
597
599
* @param listenerType the listener to call to
598
- * @param name the method name to call
599
- * @param parameters the parameters to pass to the method
600
- * @param <T> the listener type
600
+ * @param name the method name to call
601
+ * @param parameters the parameters to pass to the method
602
+ * @param <T> the listener type
601
603
* @throws ReflectiveOperationException if an exception occurred while invoking the listener
602
604
*/
603
605
public <T extends Listener > void callListener (Class <T > listenerType , String name , Object ... parameters )
0 commit comments