Search in sources :

Example 1 with DividerItemDecoration

use of com.etiennelawlor.quickreturn.itemdecorations.DividerItemDecoration in project QuickReturn by lawloretienne.

the class QuickReturnHeaderRecyclerViewFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mValues = getResources().getStringArray(R.array.countries);
    if (mLayoutManagerType.equals("linear")) {
        CountriesLinearLayoutAdapter countriesLinearLayoutAdapter = new CountriesLinearLayoutAdapter(Arrays.asList(mValues));
        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity());
        mRecyclerView.setLayoutManager(layoutManager);
        mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), null));
        mRecyclerView.setAdapter(countriesLinearLayoutAdapter);
    } else if (mLayoutManagerType.equals("grid")) {
        CountriesGridLayoutAdapter countriesGridLayoutAdapter = new CountriesGridLayoutAdapter(Arrays.asList(mValues));
        RecyclerView.LayoutManager layoutManager = new GridLayoutManager(getActivity(), 2);
        mRecyclerView.setLayoutManager(layoutManager);
        mRecyclerView.addItemDecoration(new GridSpacesItemDecoration(QuickReturnUtils.dp2px(getActivity(), 8)));
        mRecyclerView.setAdapter(countriesGridLayoutAdapter);
    }
    int headerHeight = getActivity().getResources().getDimensionPixelSize(R.dimen.header_height2);
    switch(mQuickReturnAnimationType) {
        case TRANSLATION_SIMPLE:
            if (mLayoutManagerType.equals("grid")) {
                mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.HEADER).header(mQuickReturnTextView).minHeaderTranslation(-headerHeight).columnCount(2).build();
            } else {
                mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.HEADER).header(mQuickReturnTextView).minHeaderTranslation(-headerHeight).build();
            }
            mRecyclerView.addOnScrollListener(mScrollListener);
            break;
        case TRANSLATION_SNAP:
            if (mLayoutManagerType.equals("grid")) {
                mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.HEADER).header(mQuickReturnTextView).minHeaderTranslation(-headerHeight).columnCount(2).isSnappable(true).build();
            } else {
                mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.HEADER).header(mQuickReturnTextView).minHeaderTranslation(-headerHeight).isSnappable(true).build();
            }
            mRecyclerView.addOnScrollListener(mScrollListener);
            break;
        case TRANSLATION_ANTICIPATE_OVERSHOOT:
            if (mLayoutManagerType.equals("grid")) {
                mScrollListener2 = new SpeedyQuickReturnRecyclerViewOnScrollListener.Builder(getActivity(), QuickReturnViewType.HEADER).header(mQuickReturnTextView).columnCount(2).build();
            } else {
                mScrollListener2 = new SpeedyQuickReturnRecyclerViewOnScrollListener.Builder(getActivity(), QuickReturnViewType.HEADER).header(mQuickReturnTextView).build();
            }
            mRecyclerView.addOnScrollListener(mScrollListener2);
            break;
        default:
            if (mLayoutManagerType.equals("grid")) {
                mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.HEADER).header(mQuickReturnTextView).minHeaderTranslation(-headerHeight).columnCount(2).build();
            } else {
                mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.HEADER).header(mQuickReturnTextView).minHeaderTranslation(-headerHeight).build();
            }
            mRecyclerView.addOnScrollListener(mScrollListener);
            break;
    }
}
Also used : QuickReturnRecyclerViewOnScrollListener(com.etiennelawlor.quickreturn.library.listeners.QuickReturnRecyclerViewOnScrollListener) SpeedyQuickReturnRecyclerViewOnScrollListener(com.etiennelawlor.quickreturn.library.listeners.SpeedyQuickReturnRecyclerViewOnScrollListener) SpeedyQuickReturnRecyclerViewOnScrollListener(com.etiennelawlor.quickreturn.library.listeners.SpeedyQuickReturnRecyclerViewOnScrollListener) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(com.etiennelawlor.quickreturn.itemdecorations.DividerItemDecoration) GridLayoutManager(android.support.v7.widget.GridLayoutManager) GridLayoutManager(android.support.v7.widget.GridLayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) CountriesGridLayoutAdapter(com.etiennelawlor.quickreturn.adapters.CountriesGridLayoutAdapter) CountriesLinearLayoutAdapter(com.etiennelawlor.quickreturn.adapters.CountriesLinearLayoutAdapter) RecyclerView(android.support.v7.widget.RecyclerView) GridSpacesItemDecoration(com.etiennelawlor.quickreturn.itemdecorations.GridSpacesItemDecoration)

Example 2 with DividerItemDecoration

use of com.etiennelawlor.quickreturn.itemdecorations.DividerItemDecoration 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)

Example 3 with DividerItemDecoration

use of com.etiennelawlor.quickreturn.itemdecorations.DividerItemDecoration in project QuickReturn by lawloretienne.

the class QuickReturnFooterRecyclerViewFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mValues = getResources().getStringArray(R.array.countries);
    if (mLayoutManagerType.equals("linear")) {
        CountriesLinearLayoutAdapter countriesLinearLayoutAdapter = new CountriesLinearLayoutAdapter(Arrays.asList(mValues));
        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity());
        mRecyclerView.setLayoutManager(layoutManager);
        mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), null));
        mRecyclerView.setAdapter(countriesLinearLayoutAdapter);
    } else if (mLayoutManagerType.equals("grid")) {
        CountriesGridLayoutAdapter countriesGridLayoutAdapter = new CountriesGridLayoutAdapter(Arrays.asList(mValues));
        RecyclerView.LayoutManager layoutManager = new GridLayoutManager(getActivity(), 2);
        mRecyclerView.setLayoutManager(layoutManager);
        mRecyclerView.addItemDecoration(new GridSpacesItemDecoration(QuickReturnUtils.dp2px(getActivity(), 8)));
        mRecyclerView.setAdapter(countriesGridLayoutAdapter);
    }
    int footerHeight = getActivity().getResources().getDimensionPixelSize(R.dimen.footer_height);
    switch(mQuickReturnAnimationType) {
        case TRANSLATION_SIMPLE:
            if (mLayoutManagerType.equals("grid")) {
                mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.FOOTER).footer(mQuickReturnTextView).minFooterTranslation(footerHeight).columnCount(2).build();
            } else {
                mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.FOOTER).footer(mQuickReturnTextView).minFooterTranslation(footerHeight).build();
            }
            mRecyclerView.addOnScrollListener(mScrollListener);
            break;
        case TRANSLATION_SNAP:
            if (mLayoutManagerType.equals("grid")) {
                mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.FOOTER).footer(mQuickReturnTextView).minFooterTranslation(footerHeight).columnCount(2).isSnappable(true).build();
            } else {
                mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.FOOTER).footer(mQuickReturnTextView).minFooterTranslation(footerHeight).isSnappable(true).build();
            }
            mRecyclerView.addOnScrollListener(mScrollListener);
            break;
        case TRANSLATION_ANTICIPATE_OVERSHOOT:
            if (mLayoutManagerType.equals("grid")) {
                mScrollListener2 = new SpeedyQuickReturnRecyclerViewOnScrollListener.Builder(getActivity(), QuickReturnViewType.FOOTER).footer(mQuickReturnTextView).columnCount(2).build();
            } else {
                mScrollListener2 = new SpeedyQuickReturnRecyclerViewOnScrollListener.Builder(getActivity(), QuickReturnViewType.FOOTER).footer(mQuickReturnTextView).build();
            }
            mRecyclerView.addOnScrollListener(mScrollListener2);
            break;
        default:
            if (mLayoutManagerType.equals("grid")) {
                mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.FOOTER).footer(mQuickReturnTextView).minFooterTranslation(footerHeight).columnCount(2).build();
            } else {
                mScrollListener = new QuickReturnRecyclerViewOnScrollListener.Builder(QuickReturnViewType.FOOTER).footer(mQuickReturnTextView).minFooterTranslation(footerHeight).build();
            }
            mRecyclerView.addOnScrollListener(mScrollListener);
            break;
    }
}
Also used : QuickReturnRecyclerViewOnScrollListener(com.etiennelawlor.quickreturn.library.listeners.QuickReturnRecyclerViewOnScrollListener) SpeedyQuickReturnRecyclerViewOnScrollListener(com.etiennelawlor.quickreturn.library.listeners.SpeedyQuickReturnRecyclerViewOnScrollListener) SpeedyQuickReturnRecyclerViewOnScrollListener(com.etiennelawlor.quickreturn.library.listeners.SpeedyQuickReturnRecyclerViewOnScrollListener) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(com.etiennelawlor.quickreturn.itemdecorations.DividerItemDecoration) GridLayoutManager(android.support.v7.widget.GridLayoutManager) GridLayoutManager(android.support.v7.widget.GridLayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) CountriesGridLayoutAdapter(com.etiennelawlor.quickreturn.adapters.CountriesGridLayoutAdapter) CountriesLinearLayoutAdapter(com.etiennelawlor.quickreturn.adapters.CountriesLinearLayoutAdapter) RecyclerView(android.support.v7.widget.RecyclerView) GridSpacesItemDecoration(com.etiennelawlor.quickreturn.itemdecorations.GridSpacesItemDecoration)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3 RecyclerView (android.support.v7.widget.RecyclerView)3 DividerItemDecoration (com.etiennelawlor.quickreturn.itemdecorations.DividerItemDecoration)3 QuickReturnRecyclerViewOnScrollListener (com.etiennelawlor.quickreturn.library.listeners.QuickReturnRecyclerViewOnScrollListener)3 GridLayoutManager (android.support.v7.widget.GridLayoutManager)2 CountriesGridLayoutAdapter (com.etiennelawlor.quickreturn.adapters.CountriesGridLayoutAdapter)2 CountriesLinearLayoutAdapter (com.etiennelawlor.quickreturn.adapters.CountriesLinearLayoutAdapter)2 GridSpacesItemDecoration (com.etiennelawlor.quickreturn.itemdecorations.GridSpacesItemDecoration)2 SpeedyQuickReturnRecyclerViewOnScrollListener (com.etiennelawlor.quickreturn.library.listeners.SpeedyQuickReturnRecyclerViewOnScrollListener)2 TwitterAdapter (com.etiennelawlor.quickreturn.adapters.TwitterAdapter)1 Tweet (com.etiennelawlor.quickreturn.models.Tweet)1 ArrayList (java.util.ArrayList)1