How do i get a ArrayList<Tweet> from a users timeline?

android
java

#1

Hello,

i would like to integrate my twitter tweets to my own adapter.

Using the TweetTimelineListAdapter is no option because i will create a global timeline with a few other elements, but i didn’t find a way to get the tweets from

UserTimeline userTimeline = new UserTimeline.Builder().screenName("blahblah").build();

into a ArrayList.

Hope someone can help me.


#2

@Nico_DreamzZ Happy to help - can you share more about the type of timeline you’re trying to make? For example, what is a “Global Timeline”?


#3

@bonnell thanks for your reply.

With a global timeline i mean, that not only tweets are shown is my list. There are forum posts from a rss feed an messages from Facebook. You should be possible to see all activity from the project I’m developing a app for.


#4

To realize this timeline i written an own adapter for the recycler view and now i need a list of the tweets out of the user timeline.


#5

Yes, using your own adapter in this case would be a good way to handle this. Alternatively, create a collection and use the collection timeline.


#6

My only problem is to get all tweets from the “UserTimeline” object into a arraylist :confused:


#7

Yes, there isn’t a default option for that conversion, alternatively, you could use the REST API: https://dev.twitter.com/rest/reference/get/collections/list


#8

Yes this will maybe an option, but there must be also a way to get all tweets through the api.


#9

I got it working, after 5 hours playing with the timeline object :smiley:

For someone who also needs the tweets of a timeline:
userTimeline.next(null, new Callback<TimelineResult<Tweet>>() { @Override public void success(Result<TimelineResult<Tweet>> result) { for(Tweet tweet : result.data.items){ tweets.add(tweet); } } @Override public void failure(TwitterException exception) { exception.printStackTrace(); } });


#10

Thanks for sharing your solution @Nico_DreamzZ and happy coding!