Search in sources :

Example 1 with FetchedNewTweetsEvent

use of com.birbit.android.jobqueue.examples.twitter.events.FetchedNewTweetsEvent in project android-priority-jobqueue by yigit.

the class FetchTweetsJob method onRun.

@Override
public void onRun() throws Throwable {
    TweetModel tweetModel = TweetModel.getInstance();
    Tweet lastTweet = tweetModel.getLastTweet();
    List<Status> statusList = TwitterController.getInstance().loadTweets(lastTweet == null ? null : lastTweet.getServerId());
    if (statusList.size() > 0) {
        List<Tweet> tweets = new ArrayList<Tweet>(statusList.size());
        for (Status status : statusList) {
            Tweet tweet = new Tweet(status);
            tweets.add(tweet);
        }
        tweetModel.insertOrReplaceAll(tweets);
        EventBus.getDefault().post(new FetchedNewTweetsEvent());
    }
}
Also used : Status(twitter4j.Status) FetchedNewTweetsEvent(com.birbit.android.jobqueue.examples.twitter.events.FetchedNewTweetsEvent) Tweet(com.birbit.android.jobqueue.examples.twitter.entities.Tweet) ArrayList(java.util.ArrayList) TweetModel(com.birbit.android.jobqueue.examples.twitter.models.TweetModel)

Aggregations

Tweet (com.birbit.android.jobqueue.examples.twitter.entities.Tweet)1 FetchedNewTweetsEvent (com.birbit.android.jobqueue.examples.twitter.events.FetchedNewTweetsEvent)1 TweetModel (com.birbit.android.jobqueue.examples.twitter.models.TweetModel)1 ArrayList (java.util.ArrayList)1 Status (twitter4j.Status)1