Search in sources :

Example 1 with TwitterAdapter

use of com.etiennelawlor.quickreturn.adapters.TwitterAdapter in project QuickReturn by lawloretienne.

the class QuickReturnTwitterFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ArrayList<Tweet> tweets = new ArrayList<>();
    for (int i = 0; i < 23; i++) {
        Tweet tweet = new Tweet();
        tweet.setAvatarUrl(mAvatarUrls[i]);
        tweet.setDisplayName(mDisplayNames[i]);
        tweet.setUsername(mUsernames[i]);
        tweet.setTimestamp(mTimestamps[i]);
        tweet.setStarCount(mStars[i]);
        tweet.setRetweetCount(mRetweets[i]);
        tweet.setMessage(mMessages[i]);
        tweets.add(tweet);
    }
    TwitterAdapter adapter = new TwitterAdapter(tweets);
    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity());
    mRecyclerView.setLayoutManager(layoutManager);
    mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), null));
    mRecyclerView.setAdapter(adapter);
    int headerHeight = getResources().getDimensionPixelSize(R.dimen.twitter_header_height);
    int footerHeight = getResources().getDimensionPixelSize(R.dimen.twitter_footer_height);
    int indicatorHeight = QuickReturnUtils.dp2px(getActivity(), 4);
    int headerTranslation = -headerHeight + indicatorHeight;
    int footerTranslation = -footerHeight + indicatorHeight;
    mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.TWITTER).header(mCoordinator.getTabs()).minHeaderTranslation(headerTranslation).footer(mQuickReturnFooterLinearLayout).minFooterTranslation(-footerTranslation).isSnappable(true).build();
    mRecyclerView.addOnScrollListener(mScrollListener);
}
Also used : TwitterAdapter(com.etiennelawlor.quickreturn.adapters.TwitterAdapter) QuickReturnRecyclerViewOnScrollListener(com.etiennelawlor.quickreturn.library.listeners.QuickReturnRecyclerViewOnScrollListener) Tweet(com.etiennelawlor.quickreturn.models.Tweet) ArrayList(java.util.ArrayList) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(com.etiennelawlor.quickreturn.itemdecorations.DividerItemDecoration)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 TwitterAdapter (com.etiennelawlor.quickreturn.adapters.TwitterAdapter)1 DividerItemDecoration (com.etiennelawlor.quickreturn.itemdecorations.DividerItemDecoration)1 QuickReturnRecyclerViewOnScrollListener (com.etiennelawlor.quickreturn.library.listeners.QuickReturnRecyclerViewOnScrollListener)1 Tweet (com.etiennelawlor.quickreturn.models.Tweet)1 ArrayList (java.util.ArrayList)1