/** Remove any favorited tweets that occured prior to delta given. */
 private void removeFavorites() {
   try {
     boolean found = true;
     int start = 1;
     int increment = twitterConfig.getIncrementCount();
     while (found) {
       found = false;
       ResponseList<Status> responses = twitter.getFavorites(new Paging(start, start + increment));
       for (Status status : responses) {
         if (earlier.getTime() > status.getCreatedAt().getTime()) {
           twitter.destroyFavorite(status.getId());
           logger.debug("delete dm: " + status.getId());
           found = true;
         }
       }
     }
   } catch (TwitterException e) {
     logger.error("Twitter exception occurred", e);
   }
 }
    @Override
    protected ModifyStatusesTaskOutput doInBackground(ModifyStatusesTaskInput... inputArray) {

      TwitterStatuses contentFeed = new TwitterStatuses();
      ModifyStatusesTaskInput input = inputArray[0];
      Twitter twitter = getTwitterInstance();
      String errorDescription = null;

      AppdotnetApi appdotnetApi = getAppdotnetApi();
      if (appdotnetApi != null) {
        switch (input.mStatusesType) {
          case DELETE:
            {
              if (input.mStatuses != null) {
                for (int i = 0; i < input.mStatuses.getStatusCount(); i++) {
                  TwitterStatus twitterStatus = input.mStatuses.getStatus(i);
                  AdnPost post = appdotnetApi.deleteTweet(twitterStatus.mId);
                  if (post == null) {
                    errorDescription = "Unable to delete status";
                  }
                }
              }
              break;
            }

          case SET_FAVORITE:
            {
              boolean favorite = input.mValue == 1;

              if (input.mStatuses != null) {
                for (int i = 0; i < input.mStatuses.getStatusCount(); i++) {
                  TwitterStatus twitterStatus = input.mStatuses.getStatus(i);
                  if (twitterStatus.mIsFavorited != favorite) {
                    AdnPost post = appdotnetApi.setAdnFavorite(twitterStatus.mId, favorite);

                    if (post != null) {
                      twitterStatus = new TwitterStatus(post);
                      twitterStatus.setFavorite(favorite);
                      contentFeed.add(twitterStatus);
                    }
                  }
                }
              }
              break;
            }
        }
      } else if (twitter != null) {

        try {
          switch (input.mStatusesType) {
            case DELETE:
              {
                if (input.mStatuses != null) {
                  for (int i = 0; i < input.mStatuses.getStatusCount(); i++) {
                    TwitterStatus twitterStatus = input.mStatuses.getStatus(i);
                    twitter.destroyStatus(twitterStatus.mId);
                  }
                }
                break;
              }

            case SET_FAVORITE:
              {
                boolean favorite = input.mValue == 1;

                if (input.mStatuses != null) {
                  for (int i = 0; i < input.mStatuses.getStatusCount(); i++) {
                    TwitterStatus twitterStatus = input.mStatuses.getStatus(i);
                    if (twitterStatus.mIsFavorited != favorite) {
                      try {
                        twitter4j.Status status;
                        if (favorite) {
                          status = twitter.createFavorite(twitterStatus.mId);
                        } else {
                          status = twitter.destroyFavorite(twitterStatus.mId);
                        }

                        // Yuck: See the comment for
                        // TwitterStatus.setFavorite() for
                        // reasons for this
                        twitterStatus = new TwitterStatus(status);
                        twitterStatus.setFavorite(favorite);

                        contentFeed.add(twitterStatus);
                      } catch (TwitterException e) {
                        // we might get errors setting the favorite
                        // state to the same
                        // value again.
                        // Just ignore those ones...
                      }
                    }
                  }
                }

                break;
              }
          }
        } catch (TwitterException e) {
          e.printStackTrace();
          errorDescription = e.getErrorMessage();
          Log.e("api-call", errorDescription, e);
          if (e.getRateLimitStatus() != null && e.getRateLimitStatus().getRemaining() <= 0) {
            errorDescription +=
                "\nTry again in " + e.getRateLimitStatus().getSecondsUntilReset() + " " + "seconds";
          }
        }
      }

      return new ModifyStatusesTaskOutput(
          new TwitterFetchResult(errorDescription == null, errorDescription),
          input.mCallbackHandle,
          contentFeed,
          null);
    }