예제 #1
0
 @Override
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
   super.onCreateContextMenu(menu, v, menuInfo);
   menu.add(0, REPLY, 0, "Reply");
   menu.add(0, REPOST_TWEET, 0, "Retweet");
   menu.add(0, DIRECT_MESSAGE, 0, "Send message");
   menu.add(0, FAVOURITE, 0, "Favourite");
   AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
   Status s = TwitGear.timeLine.get(info.position);
   menu.add(0, VIEW_PROFILE, 0, "View profile " + s.getUser().getScreenName());
 }
예제 #2
0
 public synchronized int fetchStatusUpdates() {
   Log.d(TAG, "Fetching status updates");
   Twitter twitter = this.getTwitter();
   if (twitter == null) {
     Log.d(TAG, "Twitter connection info not initialized");
     return 0;
   }
   try {
     List<Status> statusUpdates = twitter.getFriendsTimeline();
     long latestStatusCreatedAtTime = this.getStatusData().getLatestStatusCreatedAtTime();
     int count = 0;
     ContentValues contentValues = new ContentValues();
     for (Status status : statusUpdates) {
       contentValues.put(StatusData.C_ID, status.getId());
       long createdAt = status.getCreatedAt().getTime();
       contentValues.put(StatusData.C_CREATED_AT, createdAt);
       contentValues.put(StatusData.C_TEXT, status.getText());
       contentValues.put(StatusData.C_USER, status.getUser().getName());
       Log.d(TAG, "Got update with id " + status.getId() + ". Saving");
       this.getStatusData().insertOrIgnore(contentValues);
       if (latestStatusCreatedAtTime < createdAt) {
         count++;
       }
     }
     Log.d(TAG, count > 0 ? "Got" + count + " status updates" : "No new staus updates");
     return count;
   } catch (RuntimeException e) {
     Log.e(TAG, "Failed to fetch status updates", e);
     return 0;
   }
 }