Hello all!
I can’t seem to get .maxItemsPerRequest() to work on my UserTimeline or SearchTimeline. I’ve probably made a very basic mistake, so please excuse my ignorance.
I’m trying to get my app to return the 3 latest tweets from my own timeline upon creation. There’s no ability to refresh tweets or anything special like that; just a static display in a ListView.
Here’s my MainActivity.java:
public class MainActivity extends ListActivity {
// Note: Your consumer key and secret should be obfuscated in your source code before shipping.
private static final String TWITTER_KEY = "********";
private static final String TWITTER_SECRET = "********";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout)
findViewById(R.id.collapsing_toolbar);
AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.app_bar);
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
boolean isShow = false;
int scrollRange = -1;
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (scrollRange == -1) {
scrollRange = appBarLayout.getTotalScrollRange();
}
if (scrollRange + verticalOffset == 0) {
collapsingToolbar.setTitle("Morosphere");
isShow = true;
} else if(isShow) {
collapsingToolbar.setTitle(" ");
isShow = false;
}
}
});
TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
Fabric.with(this, new Twitter(authConfig));
final UserTimeline userTimeline = new UserTimeline.Builder()
.screenName("morosphere")
.maxItemsPerRequest(3)
.build();
final TweetTimelineListAdapter adapter = new TweetTimelineListAdapter.Builder(this)
.setTimeline(userTimeline)
.build();
setListAdapter(adapter);
}
}
And here’s the relevant part of my XML:
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/twitter_card"
style="@style/CardStyle"
card_view:cardCornerRadius="16dp"
card_view:cardBackgroundColor="#ffffff">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="5dp">
<TextView
style="@style/CardTextHeader"
android:drawableLeft="@drawable/ic_contact_twitter"
android:drawablePadding="5dp"
android:text="@string/twitter_card_header"/>
<View
style="@style/CardTitleDivider" />
<ListView
android:id='@android:id/list'
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</android.support.v7.widget.CardView>
Regardless of what number I insert into .maxItemsPerRequest(), the UserTimeline always returns the maximum amount of Tweets.
What am I doing wrong?
Happy to provide any information not already in this post 