]> average.org Git - WhereAmI.git/commitdiff
logging in LastLocation
authorEugene Crosser <Eugene.Crosser@ru.ibm.com>
Thu, 2 Feb 2012 09:58:17 +0000 (13:58 +0400)
committerEugene Crosser <Eugene.Crosser@ru.ibm.com>
Thu, 2 Feb 2012 09:58:17 +0000 (13:58 +0400)
src/org/average/whereami/LastLocation.java

index 52b909894b0eebae750dd3e86a314160b313b10c..bd25283111bb1c2e48bfd70401229045d45b0f25 100644 (file)
@@ -27,10 +27,16 @@ public final class LastLocation extends Oracle {
 
        private Latitude latitude;
 
-       public LastLocation(CredentialStore store) {
+       public LastLocation(final CredentialStore store) {
                HttpTransport transport = new NetHttpTransport();
                JsonFactory jsonFactory = new JacksonFactory();
                AccessTokenResponse token = store.read();
+               Log.v(TAG, "tokens - access: \"" + token.accessToken +
+                       "\", refresh: \"" + token.refreshToken +
+                       "\", client_id: \"" + ClientCredentials.CLIENT_ID +
+                       "\", client_secret: \"" +
+                                       ClientCredentials.CLIENT_SECRET +
+                       "\"");
                GoogleAccessProtectedResource accessProtectedResource =
                        new GoogleAccessProtectedResource(
                                token.accessToken,
@@ -38,12 +44,15 @@ public final class LastLocation extends Oracle {
                                ClientCredentials.CLIENT_ID,
                                ClientCredentials.CLIENT_SECRET,
                                token.refreshToken)
-                               //{
-                               //@Override
-                               //public void onAccessToken(String accessToken) {
-                               //      store.updateAccessToken(accessToken);
-                               //  }
-                               //}
+                               {
+                                       @Override
+                                       public void onAccessToken(
+                                                       String accessToken) {
+                                               Log.v(TAG, "Update access token to \"" + accessToken + "\"");
+                                               store.updateAccessToken(
+                                                       accessToken);
+                                       }
+                               }
                                ;
                Latitude.Builder lbldr = Latitude.builder(transport,
                                                                jsonFactory);
@@ -55,17 +64,22 @@ public final class LastLocation extends Oracle {
        @Override
        public final String getResult() {
                try {
+                       Log.v(TAG, "entering getResult");
                        Latitude.CurrentLocation.Get request =
                                latitude.currentLocation().get();
                        request.setGranularity("best");
                        Location currentLocation = request.execute();
                        return locationMessage(currentLocation);
                 } catch (Exception ex) {
+                       Log.v(TAG, "exception in getResult: " + ex);
+                       ex.printStackTrace();
                        return ex.getMessage();
                 }
        }
 
        private String locationMessage(Location currentLocation) {
+               Log.v(TAG, "entering locationMessage: " +
+                       currentLocation);
                // lat = currentLocation.getLatitude();
                // lon = currentLocation.getLongitude();
                // tsm = currentLocation.getTimestampMs();