コード例 #1
0
  /**
   * Overrided for Twitter support
   *
   * @param requestCode The integer request code originally supplied to startActivityForResult(),
   *     allowing you to identify who this result came from.
   * @param resultCode The integer result code returned by the child activity through its
   *     setResult().
   * @param data An Intent, which can return result data to the caller (various data can be attached
   *     to Intent "extras").
   */
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    int sanitizedRequestCode = requestCode & 0xFFFF;
    if (sanitizedRequestCode != REQUEST_AUTH) return;
    super.onActivityResult(requestCode, resultCode, data);

    Uri uri = data != null ? data.getData() : null;

    if (uri != null && uri.toString().startsWith(mRedirectURL)) {
      String verifier = uri.getQueryParameter(URL_TWITTER_OAUTH_VERIFIER);

      RequestLogin2AsyncTask requestLogin2AsyncTask = new RequestLogin2AsyncTask();
      mRequests.put(REQUEST_LOGIN2, requestLogin2AsyncTask);
      Bundle args = new Bundle();
      args.putString(RequestLogin2AsyncTask.PARAM_VERIFIER, verifier);
      requestLogin2AsyncTask.execute(args);
    } else {
      if (mLocalListeners.get(REQUEST_LOGIN) != null) {
        mLocalListeners
            .get(REQUEST_LOGIN)
            .onError(getID(), REQUEST_LOGIN, "incorrect URI returned: " + uri, null);
        mLocalListeners.remove(REQUEST_LOGIN);
      }
      /*
       *
       * No authentication challenges found
       * Relevant discussions can be found on the Internet at:
       * http://www.google.co.jp/search?q=8e063946 or
       * http://www.google.co.jp/search?q=ef59cf9f
       *
       * */
      initTwitterClient();
    }
  }
コード例 #2
0
  /**
   * Request ArrayList of {@link com.github.gorbin.asne.core.persons.SocialPerson} by array of
   * userIds
   *
   * @param userID array of user ids in social network
   * @param onRequestSocialPersonsCompleteListener listener for request ArrayList of {@link
   *     com.github.gorbin.asne.core.persons.SocialPerson}
   */
  @Override
  public void requestSocialPersons(
      String[] userID,
      OnRequestSocialPersonsCompleteListener onRequestSocialPersonsCompleteListener) {
    super.requestSocialPersons(userID, onRequestSocialPersonsCompleteListener);
    ArrayList<String> users = new ArrayList<String>(Arrays.asList(userID));
    int i = 0;
    long[] usersId = new long[users.size()];
    for (String user : users) {
      if (TextUtils.isEmpty(user)) {
        users.remove(user);
        break;
      }
      try {
        usersId[i] = Long.parseLong(user);
      } catch (NumberFormatException e) {
        throw new SocialNetworkException("userID should be long number");
      }
      i++;
    }

    Bundle args = new Bundle();
    args.putLongArray(RequestSocialPersonsAsyncTask.PARAM_USER_ID, usersId);
    executeRequest(new RequestSocialPersonsAsyncTask(), args, REQUEST_GET_PERSON);
  }
コード例 #3
0
 /**
  * Post link with message
  *
  * @param bundle bundle containing information that should be shared(Bundle constants in {@link
  *     com.github.gorbin.asne.core.SocialNetwork})
  * @param message message that should be shared with bundle
  * @param onPostingCompleteListener listener for posting request
  */
 @Override
 public void requestPostLink(
     Bundle bundle, String message, OnPostingCompleteListener onPostingCompleteListener) {
   super.requestPostLink(bundle, message, onPostingCompleteListener);
   Bundle args = bundle;
   args.putString(RequestUpdateStatusAsyncTask.PARAM_MESSAGE, message);
   executeRequest(new RequestUpdateStatusAsyncTask(), args, REQUEST_POST_LINK);
 }
コード例 #4
0
 /**
  * Post photo with message to social network
  *
  * @param photo photo that should be shared
  * @param message message that should be shared with photo
  * @param onPostingCompleteListener listener for posting request
  */
 @Override
 public void requestPostPhoto(
     File photo, String message, OnPostingCompleteListener onPostingCompleteListener) {
   super.requestPostPhoto(photo, message, onPostingCompleteListener);
   Bundle args = new Bundle();
   args.putString(RequestUpdateStatusAsyncTask.PARAM_MESSAGE, message);
   args.putString(RequestUpdateStatusAsyncTask.PARAM_PHOTO_PATH, photo.getAbsolutePath());
   executeRequest(new RequestUpdateStatusAsyncTask(), args, REQUEST_POST_PHOTO);
 }
コード例 #5
0
  /**
   * Post message to social network
   *
   * @param message message that should be shared
   * @param onPostingCompleteListener listener for posting request
   */
  @Override
  public void requestPostMessage(
      String message, OnPostingCompleteListener onPostingCompleteListener) {
    super.requestPostMessage(message, onPostingCompleteListener);

    Bundle args = new Bundle();
    args.putString(RequestUpdateStatusAsyncTask.PARAM_MESSAGE, message);

    executeRequest(new RequestUpdateStatusAsyncTask(), args, REQUEST_POST_MESSAGE);
  }
コード例 #6
0
 /**
  * Request {@link com.github.gorbin.asne.core.AccessToken} of Twitter social network that you can
  * get from onRequestAccessTokenCompleteListener
  *
  * @param onRequestAccessTokenCompleteListener listener for {@link
  *     com.github.gorbin.asne.core.AccessToken} request
  */
 @Override
 public void requestAccessToken(
     OnRequestAccessTokenCompleteListener onRequestAccessTokenCompleteListener) {
   super.requestAccessToken(onRequestAccessTokenCompleteListener);
   ((OnRequestAccessTokenCompleteListener) mLocalListeners.get(REQUEST_ACCESS_TOKEN))
       .onRequestAccessTokenComplete(
           getID(),
           new AccessToken(
               mSharedPreferences.getString(SAVE_STATE_KEY_OAUTH_TOKEN, null),
               mSharedPreferences.getString(SAVE_STATE_KEY_OAUTH_SECRET, null)));
 }
コード例 #7
0
 /**
  * Remove follows by id from current user
  *
  * @param userID user id that should be removed from friends
  * @param onRequestRemoveFriendCompleteListener listener to remove friend request response
  */
 @Override
 public void requestRemoveFriend(
     String userID, OnRequestRemoveFriendCompleteListener onRequestRemoveFriendCompleteListener) {
   super.requestRemoveFriend(userID, onRequestRemoveFriendCompleteListener);
   Bundle args = new Bundle();
   try {
     args.putLong(RequestRemoveFriendAsyncTask.PARAM_USER_ID, Long.parseLong(userID));
   } catch (NumberFormatException e) {
     throw new SocialNetworkException("userID should be long number");
   }
   executeRequest(new RequestRemoveFriendAsyncTask(), args, REQUEST_REMOVE_FRIEND);
 }
コード例 #8
0
 /**
  * Request user {@link com.github.gorbin.asne.twitter.TwitterPerson} by userId - detailed user
  * data
  *
  * @param userId id of Twitter user
  * @param onRequestDetailedSocialPersonCompleteListener listener for request detailed social
  *     person
  */
 @Override
 public void requestDetailedSocialPerson(
     String userId,
     OnRequestDetailedSocialPersonCompleteListener onRequestDetailedSocialPersonCompleteListener) {
   super.requestDetailedSocialPerson(userId, onRequestDetailedSocialPersonCompleteListener);
   Bundle args = new Bundle();
   if (userId != null) {
     try {
       args.putLong(RequestGetDetailedPersonAsyncTask.PARAM_USER_ID, Long.parseLong(userId));
     } catch (NumberFormatException e) {
       throw new SocialNetworkException("userID should be long number");
     }
   }
   executeRequest(new RequestGetDetailedPersonAsyncTask(), args, REQUEST_GET_DETAIL_PERSON);
 }
コード例 #9
0
 /**
  * Request {@link com.github.gorbin.asne.core.persons.SocialPerson} by user id
  *
  * @param userID id of Twitter user
  * @param onRequestSocialPersonCompleteListener listener for {@link
  *     com.github.gorbin.asne.core.persons.SocialPerson} request
  */
 @Override
 public void requestSocialPerson(
     String userID, OnRequestSocialPersonCompleteListener onRequestSocialPersonCompleteListener) {
   super.requestSocialPerson(userID, onRequestSocialPersonCompleteListener);
   if (TextUtils.isEmpty(userID)) {
     throw new SocialNetworkException("userID can't be null or empty");
   }
   Bundle args = new Bundle();
   try {
     args.putLong(RequestGetSocialPersonAsyncTask.PARAM_USER_ID, Long.parseLong(userID));
   } catch (NumberFormatException e) {
     throw new SocialNetworkException("userID should be long number");
   }
   executeRequest(new RequestGetSocialPersonAsyncTask(), args, REQUEST_GET_PERSON);
 }
コード例 #10
0
 /** Cancel login request */
 @Override
 public void cancelLoginRequest() {
   super.cancelLoginRequest();
   initTwitterClient();
 }
コード例 #11
0
 /**
  * Get current user friends list
  *
  * @param onRequestGetFriendsCompleteListener listener for getting list of current user friends
  */
 @Override
 public void requestGetFriends(
     OnRequestGetFriendsCompleteListener onRequestGetFriendsCompleteListener) {
   super.requestGetFriends(onRequestGetFriendsCompleteListener);
   executeRequest(new RequestGetFriendsAsyncTask(), null, REQUEST_GET_FRIENDS);
 }
コード例 #12
0
 /**
  * Request current user {@link com.github.gorbin.asne.core.persons.SocialPerson}
  *
  * @param onRequestSocialPersonCompleteListener listener for request {@link
  *     com.github.gorbin.asne.core.persons.SocialPerson}
  */
 @Override
 public void requestCurrentPerson(
     OnRequestSocialPersonCompleteListener onRequestSocialPersonCompleteListener) {
   super.requestCurrentPerson(onRequestSocialPersonCompleteListener);
   executeRequest(new RequestGetSocialPersonAsyncTask(), null, REQUEST_GET_CURRENT_PERSON);
 }
コード例 #13
0
 /**
  * Make login request - authorize in Twitter social network
  *
  * @param onLoginCompleteListener listener to trigger when Login complete
  */
 @Override
 public void requestLogin(OnLoginCompleteListener onLoginCompleteListener) {
   super.requestLogin(onLoginCompleteListener);
   executeRequest(new RequestLoginAsyncTask(), null, REQUEST_LOGIN);
 }