/** {@inheritDoc} */
  public void reloadUserInfo() {
    clearUserInfo();
    if (!isUserSignedIn()) {
      return;
    }

    final Bundle parameters = new Bundle();
    parameters.putString("fields", "name,picture.type(large)");
    final GraphRequest graphRequest = new GraphRequest(AccessToken.getCurrentAccessToken(), "me");
    graphRequest.setParameters(parameters);
    GraphResponse response = graphRequest.executeAndWait();

    JSONObject json = response.getJSONObject();
    try {
      userName = json.getString("name");
      userImageUrl = json.getJSONObject("picture").getJSONObject("data").getString("url");

    } catch (final JSONException jsonException) {
      Log.e(
          LOG_TAG,
          "Unable to get Facebook user info. " + jsonException.getMessage() + "\n" + response,
          jsonException);
      // Nothing much we can do here.
    }
  }
예제 #2
0
  @Override
  public void onCompleted(final JSONObject object, final GraphResponse response) {
    if (response != null && response.getError() != null) {
      Logger.debug(LoginActivity.TAG, response.getError().toString());
      return;
    }

    Logger.debug(LoginActivity.TAG, object.toString());
    goToMain();
  }
예제 #3
0
  public static JSONObject awaitGetGraphMeRequestWithCache(final String accessToken) {
    JSONObject cachedValue = ProfileInformationCache.getProfileInformation(accessToken);
    if (cachedValue != null) {
      return cachedValue;
    }

    GraphRequest graphRequest = getGraphMeRequestWithCache(accessToken);
    GraphResponse response = graphRequest.executeAndWait();
    if (response.getError() != null) {
      return null;
    }

    return response.getJSONObject();
  }
예제 #4
0
 // Graph callback
 @Override
 public void onCompleted(GraphResponse graphResponse) {
   if (graphResponse.getError() == null) {
     Toast.makeText(this, R.string.toast_posted, Toast.LENGTH_LONG).show();
     mPostText.setText(StringConstant.EMPTY);
   }
 }
예제 #5
0
    public final void onCompleted(GraphResponse graphresponse)
    {
        int i;
        if (graphresponse.getError() != null)
        {
            return;
        }
        graphresponse = graphresponse.getJSONObject();
        JSONObject jsonobject;
        try
        {
            graphresponse = graphresponse.getJSONArray("data");
        }
        // Misplaced declaration of an exception variable
        catch (GraphResponse graphresponse)
        {
            d.a(FacebookUtils.access$700(), "getPermissions", graphresponse);
            return;
        }
        i = 0;
_L2:
        if (i >= graphresponse.length())
        {
            break MISSING_BLOCK_LABEL_114;
        }
        jsonobject = graphresponse.getJSONObject(i);
        if ("granted".equals(jsonobject.getString("status")))
        {
            a.add(jsonobject.getString("permission"));
            break MISSING_BLOCK_LABEL_164;
        }
        if ("declined".equals(jsonobject.getString("status")))
        {
            b.add(jsonobject.getString("permission"));
        }
        break MISSING_BLOCK_LABEL_164;
        AccessToken.setCurrentAccessToken(new AccessToken(c.getToken(), FacebookSdk.getApplicationId(), FacebookUtils.access$300().a, a, b, AccessTokenSource.FACEBOOK_APPLICATION_WEB, c.getExpires(), null));
        FacebookUtils.setConnectionState(true);
        return;
        i++;
        if (true) goto _L2; else goto _L1
 @Override
 public void OnFbSignInComplete(GraphResponse graphResponse, String error) {
   progressBar.setVisibility(View.GONE);
   if (error == null) {
     try {
       JSONObject jsonObject = graphResponse.getJSONObject();
       fbName.setText(jsonObject.getString("name"));
       fbEmail.setText(jsonObject.getString("email"));
       String id = jsonObject.getString("id");
       String profileImg = "http://graph.facebook.com/" + id + "/picture?type=large";
     } catch (JSONException e) {
       e.printStackTrace();
     }
   }
 }
 protected void processSuccess(GraphResponse graphresponse)
 {
     unlikeToken = Utility.safeGetStringFromResponse(graphresponse.getJSONObject(), "id");
 }
 @Override
 protected Comment processResponse(GraphResponse response) {
   return JsonUtils.fromJson(response.getRawResponse(), Comment.class);
 }