7777public class PokemonGo {
7878 private static final java .lang .String TAG = PokemonGo .class .getSimpleName ();
7979 private final Time time ;
80+ private News news ;
8081 @ Getter
8182 public long startTime ;
8283 @ Getter
83- private final byte [] sessionHash = new byte [32 ];
84+ public final byte [] sessionHash = new byte [32 ];
8485 @ Getter
8586 public RequestHandler requestHandler ;
8687 @ Getter
@@ -89,7 +90,6 @@ public class PokemonGo {
8990 public Inventories inventories ;
9091 @ Getter
9192 public double latitude ;
92- private News news ;
9393 @ Getter
9494 public double longitude ;
9595 @ Getter
@@ -159,8 +159,8 @@ public class PokemonGo {
159159 * Instantiates a new Pokemon go.
160160 *
161161 * @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
164164 */
165165 public PokemonGo (OkHttpClient client , Time time , long seed ) {
166166 this .time = time ;
@@ -176,7 +176,7 @@ public PokemonGo(OkHttpClient client, Time time, long seed) {
176176 * Deprecated: specify a time implementation
177177 *
178178 * @param client the http client
179- * @param seed the seed to generate same device
179+ * @param seed the seed to generate same device
180180 */
181181 public PokemonGo (OkHttpClient client , long seed ) {
182182 this (client , new SystemTimeImpl (), seed );
@@ -187,7 +187,7 @@ public PokemonGo(OkHttpClient client, long seed) {
187187 * Deprecated: specify a time implementation
188188 *
189189 * @param client the http client
190- * @param time a time implementation
190+ * @param time a time implementation
191191 */
192192 public PokemonGo (OkHttpClient client , Time time ) {
193193 this (client , time , hash (UUID .randomUUID ().toString ()));
@@ -207,7 +207,7 @@ public PokemonGo(OkHttpClient client) {
207207 * Login user with the provided provider
208208 *
209209 * @param credentialProvider the credential provider
210- * @param hashProvider to provide hashes
210+ * @param hashProvider to provide hashes
211211 * @throws RequestFailedException if an exception occurred while sending requests
212212 */
213213 public void login (CredentialProvider credentialProvider , HashProvider hashProvider )
@@ -237,8 +237,8 @@ private void reset() {
237237 active = false ;
238238 new Random ().nextBytes (sessionHash );
239239 inventories = new Inventories (this );
240- news = new News (this );
241- settings = new Settings (this );
240+ news = new News (this );
241+ settings = new Settings (this );
242242 playerProfile = new PlayerProfile (this );
243243 map = new Map (this );
244244 longitude = Double .NaN ;
@@ -293,27 +293,29 @@ private void initialize() throws RequestFailedException {
293293
294294 requestHandler .sendServerRequests (envelope );
295295
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+ }
315317
316- List <LoginListener > loginListeners = getListeners (LoginListener .class );
318+ List <LoginListener > loginListeners = getListeners (LoginListener .class );
317319
318320 for (LoginListener listener : loginListeners ) {
319321 listener .onLogin (this );
@@ -392,9 +394,9 @@ public AuthInfo getAuthInfo(boolean refresh)
392394 /**
393395 * Sets location.
394396 *
395- * @param latitude the latitude
397+ * @param latitude the latitude
396398 * @param longitude the longitude
397- * @param altitude the altitude
399+ * @param altitude the altitude
398400 */
399401 public void setLocation (double latitude , double longitude , double altitude ) {
400402 setLocation (latitude , longitude , altitude , accuracy );
@@ -403,10 +405,10 @@ public void setLocation(double latitude, double longitude, double altitude) {
403405 /**
404406 * Sets location with accuracy.
405407 *
406- * @param latitude the latitude
408+ * @param latitude the latitude
407409 * @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
410412 */
411413 public void setLocation (double latitude , double longitude , double altitude , double accuracy ) {
412414 setLatitude (latitude );
@@ -498,7 +500,7 @@ public SignatureOuterClass.Signature.DeviceInfo getDeviceInfo() {
498500 * Gets the sensor info
499501 *
500502 * @param currentTime the current time
501- * @param random the random object
503+ * @param random the random object
502504 * @return the sensor info
503505 */
504506 public SignatureOuterClass .Signature .SensorInfo getSensorSignature (long currentTime , Random random ) {
@@ -536,7 +538,7 @@ public void setItemTemplateProvider(ItemTemplateProvider provider) {
536538 /**
537539 * Updates the current challenge
538540 *
539- * @param url the challenge url, if any
541+ * @param url the challenge url, if any
540542 * @param hasChallenge whether the challenge solve is required
541543 */
542544 public void updateChallenge (String url , boolean hasChallenge ) {
@@ -576,7 +578,7 @@ public void removeListener(Listener listener) {
576578 * Returns all listeners for the given type.
577579 *
578580 * @param listenerType the type of listeners to return
579- * @param <T> the listener type
581+ * @param <T> the listener type
580582 * @return all listeners for the given type
581583 */
582584 public <T extends Listener > List <T > getListeners (Class <T > listenerType ) {
@@ -595,9 +597,9 @@ public <T extends Listener> List<T> getListeners(Class<T> listenerType) {
595597 * Invokes a method in all listeners of the given type
596598 *
597599 * @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
601603 * @throws ReflectiveOperationException if an exception occurred while invoking the listener
602604 */
603605 public <T extends Listener > void callListener (Class <T > listenerType , String name , Object ... parameters )
0 commit comments