Exemple #1
0
 @Override
 public void onCompleted(Response response) {
   final OnActionListener<T> actionListener = getActionListener();
   FacebookRequestError error = response.getError();
   if (error != null) {
     Logger.logError(
         GetAction.class, "Failed to get what you have requested", error.getException());
     if (actionListener != null) {
       actionListener.onException(error.getException());
     }
   } else {
     if (response.getGraphObject() == null) {
       Logger.logError(
           GetAction.class,
           "The response GraphObject has null value. Response=" + response.toString(),
           null);
     } else {
       if (actionListener != null) {
         try {
           updateCursor(response);
           T result = processResponse(response);
           actionListener.onComplete(result);
         } catch (Exception e) {
           actionListener.onException(e);
         }
       }
     }
   }
 }
 /**
  * Set photo to be published
  *
  * @param file
  */
 public Builder setImage(File file) {
   try {
     mParcelable = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
   } catch (FileNotFoundException e) {
     Logger.logError(Photo.class, "Failed to create photo from file", e);
   }
   return this;
 }
Exemple #3
0
 /**
  * The action link which will appear next to the 'Comment' and 'Like' link under posts. The
  * contained object must have the keys name and link.
  *
  * @param name
  * @param link
  * @return {@link Builder}
  */
 public Builder addAction(String name, String link) {
   try {
     mActions.put("name", name);
     mActions.put("link", link);
   } catch (JSONException e) {
     Logger.logError(Feed.class, "Failed to add action", e);
   }
   return this;
 }
Exemple #4
0
    /**
     * Object of key/value pairs which will appear in the stream attachment beneath the description,
     * with each property on its own line.
     *
     * @param text
     * @param secondText
     * @return {@link Builder}
     */
    public Builder addProperty(String text, String secondText) {
      try {
        mProperties.put(text, secondText);
      } catch (JSONException e) {
        Logger.logError(Feed.class, "Failed to add property", e);
      }

      return this;
    }
Exemple #5
0
    /**
     * Object of key/value pairs which will appear in the stream attachment beneath the description,
     * with each property on its own line.
     *
     * @param text
     * @param urlName
     * @param url
     * @return {@link Builder}
     */
    public Builder addProperty(String text, String linkName, String link) {
      JSONObject json = new JSONObject();

      try {
        json.put("text", linkName);
        json.put("href", link);
        mProperties.put(text, json);
      } catch (JSONException e) {
        Logger.logError(Feed.class, "Failed to add property", e);
      }

      return this;
    }
Exemple #6
0
 @Override
 protected void executeImpl() {
   OnActionListener<T> actionListener = getActionListener();
   if (sessionManager.isLogin(true)) {
     Session session = sessionManager.getActiveSession();
     Bundle bundle = updateAppSecretProof(getBundle());
     Request request = new Request(session, getGraphPath(), bundle, HttpMethod.GET);
     runRequest(request);
   } else {
     String reason = Errors.getError(ErrorMsg.LOGIN);
     Logger.logError(getClass(), reason, null);
     if (actionListener != null) {
       actionListener.onFail(reason);
     }
   }
 }