Exemplo n.º 1
0
 @Override
 public int compare(Status object1, Status object2) {
   final long diff = object2.getId() - object1.getId();
   if (diff > Integer.MAX_VALUE) return Integer.MAX_VALUE;
   if (diff < Integer.MIN_VALUE) return Integer.MIN_VALUE;
   return (int) diff;
 }
  private void addNewTwitterStatus(Status status) {
    ContentResolver resolver = getContentResolver();

    // Make sure status doesn't alraedy exist
    String where = TwitterStatusContentProvider.KEY_STATUS_ID + " = " + status.getId();
    Cursor query =
        resolver.query(TwitterStatusContentProvider.CONTENT_URI, null, where, null, null);
    if (query.getCount() == 0) {
      ContentValues values = new ContentValues();
      values.put(TwitterStatusContentProvider.KEY_STATUS_ID, status.getId());
      values.put(TwitterStatusContentProvider.KEY_CREATED_AT, status.getCreatedAt().getTime());
      values.put(TwitterStatusContentProvider.KEY_STATUS_TEXT, status.getText());
      values.put(TwitterStatusContentProvider.KEY_USER_ID, status.getUser().getId());
      values.put(TwitterStatusContentProvider.KEY_USER_NAME, status.getUser().getName());
      values.put(
          TwitterStatusContentProvider.KEY_USER_SCREEN_NAME, status.getUser().getScreenName());
      values.put(
          TwitterStatusContentProvider.KEY_USER_IMAGE, status.getUser().getMiniProfileImageURL());
      values.put(TwitterStatusContentProvider.KEY_USER_URL, status.getUser().getURL());
      values.put(TwitterStatusContentProvider.KEY_LATITUDE, status.getGeoLocation().getLatitude());
      values.put(
          TwitterStatusContentProvider.KEY_LONGITUDE, status.getGeoLocation().getLongitude());
      resolver.insert(TwitterStatusContentProvider.CONTENT_URI, values);
    }
    query.close();
  }
 /*
  * Favorites the specified tweet, returning true in case of success.
  * If error, returns false.
  */
 public boolean doFav(Status tweet) {
   try {
     twitter.createFavorite(tweet.getId());
     return true;
   } catch (Exception ex) {
     System.err.println("[ERROR] Can't favorite " + tweet.getId());
     ex.printStackTrace();
     return false;
   }
 }
  /*
   * Re-tweets the specified tweet, returning true in case of success.
   * If error, returns false.
   */
  public boolean doRT(Status tweet) {
    try {
      twitter.retweetStatus(tweet.getId());

      return true;
    } catch (Exception ex) {
      System.err.println("[ERROR] Can't retweet " + tweet.getId());
      ex.printStackTrace();
      return false;
    }
  }
Exemplo n.º 5
0
 /**
  * Transforms a twitter4j.Status object into a JSONObject
  *
  * @param pStatus a twitter4j.Status object
  * @return JSONObject
  */
 @SuppressWarnings("unchecked")
 public static JSONObject getJson(Status pStatus) {
   JSONObject jsonObj = null;
   if (pStatus != null) {
     jsonObj = new JSONObject();
     jsonObj.put("createdAt", pStatus.getCreatedAt());
     jsonObj.put("id", pStatus.getId());
     jsonObj.put("text", pStatus.getText());
     jsonObj.put("source", pStatus.getSource());
     jsonObj.put("isTruncated", pStatus.isTruncated());
     jsonObj.put("inReplyToStatusId", pStatus.getInReplyToStatusId());
     jsonObj.put("inReplyToUserId", pStatus.getInReplyToUserId());
     jsonObj.put("isFavorited", pStatus.isFavorited());
     jsonObj.put("isRetweeted", pStatus.isRetweeted());
     jsonObj.put("favoriteCount", pStatus.getFavoriteCount());
     jsonObj.put("inReplyToScreenName", pStatus.getInReplyToScreenName());
     jsonObj.put("geoLocation", pStatus.getGeoLocation());
     jsonObj.put("place", pStatus.getPlace());
     jsonObj.put("retweetCount", pStatus.getRetweetCount());
     jsonObj.put("isPossiblySensitive", pStatus.isPossiblySensitive());
     jsonObj.put("isoLanguageCode", pStatus.getIsoLanguageCode());
     jsonObj.put("contributorsIDs", pStatus.getContributors());
     jsonObj.put("retweetedStatus", pStatus.getRetweetedStatus());
     jsonObj.put("userMentionEntities", pStatus.getUserMentionEntities());
     jsonObj.put("urlEntities", pStatus.getURLEntities());
     jsonObj.put("hashtagEntities", pStatus.getHashtagEntities());
     jsonObj.put("mediaEntities", pStatus.getMediaEntities());
     jsonObj.put("currentUserRetweetId", pStatus.getCurrentUserRetweetId());
     jsonObj.put("user", pStatus.getUser());
   }
   return jsonObj;
 }
Exemplo n.º 6
0
 public List<Status> pollConsume() throws TwitterException {
   List<Status> list = te.getProperties().getTwitter().getRetweetsOfMe(new Paging(lastId));
   for (Status s : list) {
     checkLastId(s.getId());
   }
   return list;
 }
Exemplo n.º 7
0
  public static void insertTweet(Status tweet) throws SQLException {
    try {
      System.out.println(tweet.getCreatedAt() + ": " + tweet.getText());

      if (tweet.getRetweetedStatus() != null) {
        insertRetweet(tweet);
        return;
      }

      PreparedStatement insertTweetStmt = SqlHelper.getInsertTweetStmt();
      insertTweetStmt.setLong(1, tweet.getId());
      if (tweet.getGeoLocation() != null) {
        insertTweetStmt.setFloat(2, (float) tweet.getGeoLocation().getLatitude());
        insertTweetStmt.setFloat(3, (float) tweet.getGeoLocation().getLongitude());
      } else {
        insertTweetStmt.setFloat(2, 0);
        insertTweetStmt.setFloat(3, 0);
      }
      insertTweetStmt.setString(4, tweet.getText());
      insertTweetStmt.setInt(5, (int) tweet.getRetweetCount());
      insertTweetStmt.setTimestamp(6, new Timestamp(tweet.getCreatedAt().getTime()));
      insertTweetStmt.setLong(7, tweet.getInReplyToStatusId());
      insertTweetStmt.setLong(8, tweet.getUser().getId());
      insertTweetStmt.executeUpdate();
    } catch (MySQLIntegrityConstraintViolationException e) {
      // ignore, this is just a duplicate tweet entry, that's rather normal
    }
  }
 private List<Long> obtainReadIds(List<Status> statusList) {
   List<Long> idsToCheck = new ArrayList<Long>(statusList.size());
   for (Status status : statusList) {
     idsToCheck.add(status.getId());
   }
   return th.getReadIds(idsToCheck);
 }
Exemplo n.º 9
0
  private Tweet getTweetObjectFromStatus(Status status) {

    Tweet tweet = new Tweet();
    tweet.setId(Long.toString(status.getId()));
    tweet.setText(status.getText());
    tweet.setCreatedAt(status.getCreatedAt());

    tweet.setFavCount(status.getFavoriteCount());

    User user = status.getUser();

    tweet.setUserId(user.getId());
    tweet.setUserName(user.getName());
    tweet.setUserScreenName(user.getScreenName());

    HashtagEntity[] hashtagEntities = status.getHashtagEntities();
    List<String> hashtags = new ArrayList<String>();

    for (HashtagEntity hashtagEntity : hashtagEntities) {
      hashtags.add(hashtagEntity.getText());
    }

    tweet.setHashTags(hashtags.toArray(new String[hashtags.size()]));

    GeoLocation geoLocation = status.getGeoLocation();
    if (geoLocation != null) {
      double[] coordinates = {geoLocation.getLongitude(), geoLocation.getLatitude()};
      tweet.setCoordinates(coordinates);
    }

    return tweet;
  }
Exemplo n.º 10
0
 /**
  * ツイートの削除
  *
  * @param status 削除するツイート
  * @return 成功したか
  */
 public boolean removeTweet(Status status) {
   try {
     twitter.destroyStatus(status.getId());
   } catch (TwitterException e) {
     return false;
   }
   return true;
 }
Exemplo n.º 11
0
  /**
   * Search tweets with the keyword "word"
   *
   * @param word : keyword
   */
  public void doSearch(String word) {
    List<Status> listStatus;
    listCleanTweets = new ArrayList<Tweet>();
    listDirtyTweets = new ArrayList<Tweet>();

    try {
      Query query = new Query(word);
      query.resultType(ResultType.mixed);
      query.setLang("fr");
      query.count(30);
      QueryResult result = InterfaceG.twitter.search(query);

      listStatus = result.getTweets();

      for (Status status : listStatus) {
        Tweet tclean =
            new Tweet(
                status.getId(),
                status.getUser().getName(),
                cleanTweet(status.getText()),
                status.getCreatedAt().toString(),
                -1);
        listCleanTweets.add(tclean);

        Tweet tdirty =
            new Tweet(
                status.getId(),
                status.getUser().getName(),
                status.getText(),
                status.getCreatedAt().toString(),
                -1);
        listDirtyTweets.add(tdirty);
      }

      setChanged();
      notifyObservers();
    } catch (TwitterException te) {
      System.out.println("doSearch:TwitterExc");
      System.out.println(te.getMessage());
      System.exit(-1);
    } catch (IOException e) {
      System.out.println("doSearch:IOExc");
      System.out.println(e.getMessage());
    }
  }
Exemplo n.º 12
0
 public Tweet(Status status) {
   this.text = status.getText();
   this.longitude = status.getGeoLocation().getLongitude();
   this.latitude = status.getGeoLocation().getLatitude();
   this.userName = status.getUser().getName();
   this.userDescription = status.getUser().getDescription();
   this.createdAt = status.getCreatedAt().getTime();
   this.tweetId = status.getId();
 }
Exemplo n.º 13
0
 public int compareTo(Status that) {
   long delta = this.id - that.getId();
   if (delta < Integer.MIN_VALUE) {
     return Integer.MIN_VALUE;
   } else if (delta > Integer.MAX_VALUE) {
     return Integer.MAX_VALUE;
   }
   return (int) delta;
 }
Exemplo n.º 14
0
  private ArrayAdapter<String> getTimeline() {
    SharedPreferences sp = getSharedPreferences("token", MODE_PRIVATE);
    String token = sp.getString("token", "");
    String tokenSecret = sp.getString("token_seacret", "");

    // twitterオブジェクトの作成
    Twitter tw = new TwitterFactory().getInstance();

    // AccessTokenオブジェクトの作成
    AccessToken at = new AccessToken(token, tokenSecret);

    // Consumer keyとConsumer key seacretの設定
    tw.setOAuthConsumer("iy2FEHXmSXNReJ6nYQ8FRg", "KYro4jM8BHlLSMsSdTylnTcm3pYaTCiG2UZrYK1yI4");

    // AccessTokenオブジェクトを設定
    tw.setOAuthAccessToken(at);

    try {
      // TLの取得
      ResponseList<Status> homeTl = tw.getHomeTimeline();

      ArrayAdapter<String> adapter =
          new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1);

      for (Status status : homeTl) {
        // つぶやきのユーザーIDの取得
        String userName = status.getUser().getScreenName();
        // つぶやきの取得
        String tweet = status.getText();
        adapter.add("ユーザーID:" + userName + "\r\n" + "tweet:" + tweet);
      }
      Status s = homeTl.get(homeTl.size());
      Paging p = new Paging();
      p.setMaxId(s.getId());

      homeTl = null;
      homeTl = tw.getHomeTimeline(p);

      for (Status status : homeTl) {
        // つぶやきのユーザーIDの取得
        String userName = status.getUser().getScreenName();
        // つぶやきの取得
        String tweet = status.getText();
        adapter.add("ユーザーID:" + userName + "\r\n" + "tweet:" + tweet);
      }

      return adapter;
    } catch (TwitterException e) {
      e.printStackTrace();
      if (e.isCausedByNetworkIssue()) {
        Toast.makeText(getApplicationContext(), "ネットワークに接続して下さい", Toast.LENGTH_LONG);
      } else {
        Toast.makeText(getApplicationContext(), "エラーが発生しました。", Toast.LENGTH_LONG);
      }
    }
    return null;
  }
Exemplo n.º 15
0
 /** 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);
   }
 }
Exemplo n.º 16
0
 public long reply(String message, long statusId) throws Exception {
   long replyStatus = -1;
   try {
     Status status =
         getTwitterProxy().updateStatus(new StatusUpdate("message").inReplyToStatusId(statusId));
     replyStatus = status.getId();
   } catch (TwitterException e) {
     logger.error("Error while replying: " + statusId + " Announcer: " + screenName);
   }
   return replyStatus;
 }
Exemplo n.º 17
0
 /**
  * Delete normal tweets sent by the users that match the delta requirements. (ie. delete tweets
  * older then 2 weeks. Default )
  */
 public void deleteTweets() {
   try {
     boolean found = true;
     int start = 1;
     int increment = twitterConfig.getIncrementCount();
     while (found) {
       found = false;
       List<Status> status = twitter.getUserTimeline(new Paging(start, start + increment));
       for (Status s : status) {
         if (earlier.getTime() > s.getCreatedAt().getTime()) {
           found = true;
           twitter.destroyStatus(s.getId());
           logger.debug("removing tweeit with id: {}", s.getId());
         }
       }
       logger.debug("size of status batch is: {} ", status.size());
     }
   } catch (TwitterException e) {
     logger.error("Twitter exception occurred", e);
   }
 }
Exemplo n.º 18
0
  @Override
  public void onStatus(Status status) {
    c++;
    VectorSpace vsm = new VectorSpace(Long.toString(status.getId()), status.getText());
    vocabulary.update(vsm.tokens());
    hashTables.add(vsm);

    if (c > 10000) {
      VectorSpace[] nn = hashTables.get(vsm);
      System.out.println(nn.length);
    }
  }
Exemplo n.º 19
0
  @Override
  public long tweet(String txt) {

    if (txt.length() > 140) {
      throw new ScriptusRuntimeException("tweet > 140 characters: " + txt);
    }

    Status s;
    try {
      s = twitter.updateStatus(new StatusUpdate(txt));
    } catch (TwitterException e) {
      throw new ScriptusRuntimeException(e);
    }
    return s.getId();
  }
Exemplo n.º 20
0
  @Override
  public void onStatus(Status status) {
    User user = status.getUser();

    // gets Username
    String username = status.getUser().getScreenName();
    System.out.println(username);
    String profileLocation = user.getLocation();
    System.out.println(profileLocation);
    long tweetId = status.getId();
    System.out.println(tweetId);
    String content = status.getText();
    System.out.println(content + "\n");

    executor.execute(new Worker(username, id, content, schema));
  }
  @SuppressWarnings("unchecked")
  public void onScroll(
      AbsListView absListView, int firstVisible, int visibleCount, int totalCount) {

    boolean loadMore = /* maybe add a padding */ firstVisible + visibleCount >= totalCount - 1;

    //        Log.d("onScroll:","loadMore f=" + firstVisible + ", vc=" + visibleCount + ", tc="
    // +totalCount);
    if (loadMore) {
      // Debug.startMethodTracing("list" + firstVisible);
      ListAdapter adapter = absListView.getAdapter();
      if (adapter instanceof StatusAdapter) {
        StatusAdapter sta = (StatusAdapter) adapter;
        if (totalCount > 0) {
          Object item = sta.getItem(totalCount - 1);
          int i = 0;
          if (item instanceof DirectMessage) {
            DirectMessage message = (DirectMessage) item;

            List<DirectMessage> messages = th.getDirectsFromDb(message.getId(), 7);
            for (DirectMessage direct : messages) {
              sta.insert(direct, totalCount + i);
              directs.add(direct);
              i++;
            }
          } else if (item instanceof Status) {
            Status last = (Status) item;
            if (statuses == null) statuses = new ArrayList<Status>();

            List<Status> newStatuses = th.getStatuesFromDb(last.getId(), 7, list_id);
            // TODO add checking for old
            List<Long> readIds = obtainReadIds(newStatuses);
            sta.readIds.addAll(readIds);
            for (Status status : newStatuses) {
              if (!matchesFilter(status)) {
                sta.insert(status, totalCount + i);
                statuses.add(status);
                i++;
              }
            }
          }
          sta.notifyDataSetChanged();
        }
      }
      // Debug.stopMethodTracing();
    }
  }
Exemplo n.º 22
0
  protected Map<Long, BackendStatus> statusListToMap(List<Status> list, boolean isProteced) {
    Map<Long, BackendStatus> map = new HashMap<Long, BackendStatus>();
    int size = list.size();

    // 200건 처리토록 함..
    if (size > TWITTER_GET_DATA_SIZE) {
      size = TWITTER_GET_DATA_SIZE;
    }

    Status status = null;
    for (int i = 0; i < size; i++) {
      status = list.get(i);
      map.put(status.getId(), new BackendStatus(status, isProteced));
    }

    return map;
  }
Exemplo n.º 23
0
    public void onStatus(Status status) {
      try {
        String statusAsString = OBJECT_MAPPER.writeValueAsString(status);

        PublishRequest req =
            new PublishRequest()
                . //
                withMessage(statusAsString)
                . //
                withSubject("" + status.getId())
                . //
                withTopicArn(topicArn);

        snsClient.publish(req);
      } catch (Exception ex) {
        dumpError(ex);
      }
    }
Exemplo n.º 24
0
    @Override
    protected List<HaikuStatus> doInBackground(Void... params) {

      twitter4j.Status lastStatus = mAdapter.getItem(mAdapter.getCount() - 1).getStatus();

      Paging paging = new Paging();
      paging.setMaxId(lastStatus.getId() - 1);
      ResponseList<twitter4j.Status> timeline;

      try {
        timeline = mTwitter.getUserTimeline(userScreenName, paging);
      } catch (TwitterException e) {
        Log.e(TAG, e.toString());
        isThereTweetException = true;
        return null;
      }

      MorphologicalAnalysisByGooAPI analyzer =
          new MorphologicalAnalysisByGooAPI(getString(R.string.goo_id));
      List<HaikuStatus> haikuStatusList = new ArrayList<>();

      if (canCreateHaiku) {
        for (twitter4j.Status status : timeline) {
          try {
            List<Word> list =
                analyzer.analyze(
                    status.getRetweetedStatus() != null
                        ? status.getText().replaceFirst("RT", "")
                        : status.getText());
            String haiku = new HaikuGeneratorByGooAPI(list).generateHaikuStrictly();
            haikuStatusList.add(new HaikuStatus(haiku, status));
          } catch (IOException e) {
            Log.d(TAG, e.toString());
          }
        }
      } else {
        for (twitter4j.Status status : timeline) {
          String haiku = "";
          haikuStatusList.add(new HaikuStatus(haiku, status));
        }
      }

      return haikuStatusList;
    }
  protected static ListItem toListItem(Status tweet) {
    ListItem item1 = new ListItem();

    item1.image = defaultImage;
    item1.id = tweet.getId();

    item1.screenName = tweet.getUser().getScreenName();
    item1.name = tweet.getUser().getName();
    item1.comment = tweet.getText();

    item1.geoLocation = tweet.getGeoLocation();
    item1.profileImageURL = tweet.getUser().getProfileImageURL().toString();
    item1.date = diffDate(tweet.getCreatedAt());

    //
    item1.source = tweet.getSource();

    return item1;
  }
Exemplo n.º 26
0
 public void testStatusAsJSON() throws Exception {
   // single Status
   HttpClientImpl http = new HttpClientImpl();
   List<Status> statuses =
       StatusJSONImpl.createStatusList(
           http.get("http://twitter4j.org/en/testcases/statuses/public_timeline.json"), conf);
   Status status = statuses.get(0);
   Assert.assertEquals(new Date(1259041785000l), status.getCreatedAt());
   Assert.assertEquals(6000554383l, status.getId());
   Assert.assertEquals("G_Shock22", status.getInReplyToScreenName());
   Assert.assertEquals(6000444309l, status.getInReplyToStatusId());
   Assert.assertEquals(20159829, status.getInReplyToUserId());
   Assert.assertNull(status.getGeoLocation());
   Assert.assertEquals("web", status.getSource());
   Assert.assertEquals(
       "@G_Shock22 I smelled a roast session coming when yu said that shyt about @2koolNicia lol....",
       status.getText());
   Assert.assertEquals(23459577, status.getUser().getId());
   Assert.assertFalse(status.isRetweet());
   assertDeserializedFormIsEqual(statuses);
 }
Exemplo n.º 27
0
 public void testRetweetStatusAsJSON() throws Exception {
   // single Status
   HttpClientImpl http = new HttpClientImpl();
   Status status =
       new StatusJSONImpl(
           http.get("http://twitter4j.org/en/testcases/statuses/retweet/6010814202.json"), conf);
   Assert.assertEquals(new Date(1259078050000l), status.getCreatedAt());
   Assert.assertEquals(6011259778l, status.getId());
   Assert.assertEquals(null, status.getInReplyToScreenName());
   Assert.assertEquals(-1l, status.getInReplyToStatusId());
   Assert.assertEquals(-1, status.getInReplyToUserId());
   Assert.assertNull(status.getGeoLocation());
   Assert.assertEquals(
       "<a href=\"http://apiwiki.twitter.com/\" rel=\"nofollow\">API</a>", status.getSource());
   Assert.assertEquals(
       "RT @yusukey: この前取材受けた奴 -> 次世代のシステム環境を見据えたアプリケーションサーバー製品の選択 ITpro: http://special.nikkeibp.co.jp/ts/article/0iaa/104388/",
       status.getText());
   Assert.assertEquals(6358482, status.getUser().getId());
   Assert.assertTrue(status.isRetweet());
   assertDeserializedFormIsEqual(status);
 }
Exemplo n.º 28
0
  @Override
  public List<Tweet> getMentions() {

    /*
     * to avoid duplicates (we have to search and get mentions,
     * because mentions by themselves are broken  / sometimes
     * don't update on a timely basis.
     */

    Set<Tweet> result = new TreeSet<Tweet>();
    // FIXME or 200 mentions = DOS
    try {
      List<Status> mentions = twitter.getMentions();

      for (Status s : mentions) {
        Tweet t = new Tweet(s.getId(), s.getText(), s.getUser().getScreenName());
        t.setInReplyToId(s.getInReplyToStatusId());
        result.add(t);
      }
      // mentions should be fixed now?
      //            Query q = new Query("@"+screenName);
      //
      //            QueryResult r = twitter.search(q);
      //
      //			for(twitter4j.Tweet t : r.getTweets()) {
      //				//compute hashcodes like in mockimpl
      //			    Tweet tt = new Tweet(t.getId(), t.getText(), t.getFromUser());
      //			    if(t.get){
      //			        tt.setInReplyToId(t.getInReplyToStatusId()))
      //			    }
      //			    t.
      //				result.add(tt);
      //			}

    } catch (TwitterException e) {
      throw new ScriptusRuntimeException(e);
    }

    return new ArrayList<Tweet>(result);
  }
Exemplo n.º 29
0
  @Override
  public void storeData(Status status) throws InterruptedException {

    BasicDBObject basicObj = new BasicDBObject();
    // if(status.getGeoLocation().equals(true))

    // if(status.getGeoLocation().getLatitude()!=0.0d)
    // {

    if (status.getGeoLocation() != null) {
      try {
        System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText());
        basicObj.put("user_name", status.getUser().getScreenName());
        basicObj.put("retweet_count", status.getRetweetCount());
        // basicObj.put("tweet_followers_count",
        // status.getUser().getFollowersCount());
        basicObj.put("source", status.getSource());
        // basicObj.put("coordinates",status.getGeoLocation());
        basicObj.put("latitude", status.getGeoLocation().getLatitude());
        basicObj.put("longitude", status.getGeoLocation().getLongitude());
        // UserMentionEntity[] mentioned =
        // status.getUserMentionEntities();
        // basicObj.put("tweet_mentioned_count", mentioned.length);
        basicObj.put("tweet_ID", status.getId());
        basicObj.put("tweet_text", status.getText());
        // i++;
      } catch (Exception e) {
        System.out.println(e);
      }

      try {
        items.insert(basicObj);
      } catch (Exception e) {
        System.out.println("MongoDB Connection Error : " + e.getMessage());
      }
    }
    // else
    // throw new InterruptedException();

  }
Exemplo n.º 30
0
 @Override
 public List<ParcelableStatus> loadInBackground() {
   final List<ParcelableStatus> data = getData();
   final long account_id = getAccountId();
   ResponseList<Status> statuses = null;
   try {
     final Paging paging = new Paging();
     final SharedPreferences prefs =
         getContext().getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
     final int load_item_limit =
         prefs.getInt(PREFERENCE_KEY_LOAD_ITEM_LIMIT, PREFERENCE_DEFAULT_LOAD_ITEM_LIMIT);
     paging.setCount(load_item_limit);
     if (mMaxId != -1) {
       paging.setMaxId(mMaxId);
     }
     statuses = getStatuses(paging);
   } catch (final TwitterException e) {
     e.printStackTrace();
   }
   if (statuses != null) {
     Collections.sort(statuses, TWITTER4J_STATUS_ID_COMPARATOR);
     int deleted_count = 0;
     final int size = statuses.size();
     for (int i = 0; i < size; i++) {
       final Status status = statuses.get(i);
       if (deleteStatus(status.getId())) {
         deleted_count++;
       }
       data.add(
           new ParcelableStatus(
               status,
               account_id,
               i == statuses.size() - 1 ? deleted_count > 1 : false,
               isForceSSLConnection()));
     }
   }
   Collections.sort(data, ParcelableStatus.STATUS_ID_COMPARATOR);
   return data;
 }