Search in sources :

Example 11 with FastScroller

use of eu.davidea.fastscroller.FastScroller in project FlexibleAdapter by davideas.

the class FragmentHolderSections method initializeRecyclerView.

@SuppressWarnings({ "ConstantConditions", "NullableProblems" })
private void initializeRecyclerView(Bundle savedInstanceState) {
    // Initialize Adapter and RecyclerView
    // ExampleAdapter makes use of stableIds, I strongly suggest to implement 'item.hashCode()'
    FlexibleAdapter.useTag("HolderSectionsAdapter");
    mAdapter = new ExampleAdapter(DatabaseService.getInstance().getDatabaseList(), getActivity());
    mRecyclerView = getView().findViewById(R.id.recycler_view);
    mRecyclerView.setLayoutManager(createNewLinearLayoutManager());
    mRecyclerView.setAdapter(mAdapter);
    // Size of RV will not change
    mRecyclerView.setHasFixedSize(true);
    // NOTE: Use default item animator 'canReuseUpdatedViewHolder()' will return true if
    // a Payload is provided. FlexibleAdapter is actually sending Payloads onItemChange.
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    // Add FastScroll to the RecyclerView, after the Adapter has been attached the RecyclerView!!!
    FastScroller fastScroller = getView().findViewById(R.id.fast_scroller);
    fastScroller.addOnScrollStateChangeListener((MainActivity) getActivity());
    mAdapter.setFastScroller(fastScroller);
    mAdapter.setDisplayHeadersAtStartUp(true).setStickyHeaders(true).setOnlyEntryAnimation(true);
    SwipeRefreshLayout swipeRefreshLayout = getView().findViewById(R.id.swipeRefreshLayout);
    swipeRefreshLayout.setEnabled(true);
    mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, Mode.IDLE);
    // Add 1 Scrollable Header
    mAdapter.addScrollableHeader(new ScrollableUseCaseItem(getString(R.string.model_holders_use_case_title), getString(R.string.model_holders_use_case_description)));
}
Also used : ScrollableUseCaseItem(eu.davidea.samples.flexibleadapter.items.ScrollableUseCaseItem) FastScroller(eu.davidea.fastscroller.FastScroller) ExampleAdapter(eu.davidea.samples.flexibleadapter.ExampleAdapter) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator)

Example 12 with FastScroller

use of eu.davidea.fastscroller.FastScroller in project FlexibleAdapter by davideas.

the class FragmentViewPager method initializeRecyclerView.

private void initializeRecyclerView() {
    // Initialize Adapter and RecyclerView
    // Use of stableIds, I strongly suggest to implement 'item.hashCode()'
    FlexibleAdapter.useTag("ViewPagerAdapter");
    mAdapter = new FlexibleAdapter<>(createList(50, 5), getActivity(), true);
    mAdapter.setAnimationOnForwardScrolling(DatabaseConfiguration.animateOnForwardScrolling);
    RecyclerView mRecyclerView = getView().findViewById(R.id.recycler_view);
    mRecyclerView.setLayoutManager(new SmoothScrollLinearLayoutManager(getActivity()));
    mRecyclerView.setAdapter(mAdapter);
    // Size of RV will not change
    mRecyclerView.setHasFixedSize(true);
    // NOTE: Use default item animator 'canReuseUpdatedViewHolder()' will return true if
    // a Payload is provided. FlexibleAdapter is actually sending Payloads onItemChange.
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    // Add FastScroll to the RecyclerView, after the Adapter has been attached the RecyclerView!!!
    FastScroller fastScroller = getView().findViewById(R.id.fast_scroller);
    mAdapter.setFastScroller(fastScroller);
    // Sticky Headers
    mAdapter.setDisplayHeadersAtStartUp(true).setStickyHeaders(true);
}
Also used : RecyclerView(androidx.recyclerview.widget.RecyclerView) FastScroller(eu.davidea.fastscroller.FastScroller) SmoothScrollLinearLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator)

Aggregations

FastScroller (eu.davidea.fastscroller.FastScroller)12 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)8 DefaultItemAnimator (androidx.recyclerview.widget.DefaultItemAnimator)6 ExampleAdapter (eu.davidea.samples.flexibleadapter.ExampleAdapter)6 FlexibleItemDecoration (eu.davidea.flexibleadapter.common.FlexibleItemDecoration)5 ScrollableUseCaseItem (eu.davidea.samples.flexibleadapter.items.ScrollableUseCaseItem)4 EmptyViewHelper (eu.davidea.flexibleadapter.helpers.EmptyViewHelper)2 NavigationView (android.support.design.widget.NavigationView)1 RecyclerView (android.support.v7.widget.RecyclerView)1 SearchView (android.support.v7.widget.SearchView)1 View (android.view.View)1 TextView (android.widget.TextView)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 SmoothScrollLinearLayoutManager (eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager)1 AbstractFlexibleItem (eu.davidea.flexibleadapter.items.AbstractFlexibleItem)1 FadeInDownItemAnimator (eu.davidea.samples.flexibleadapter.animators.FadeInDownItemAnimator)1 GarageDoorItemAnimator (eu.davidea.samples.flexibleadapter.animators.GarageDoorItemAnimator)1 ScrollableLayoutItem (eu.davidea.samples.flexibleadapter.items.ScrollableLayoutItem)1 HeaderView (eu.davidea.samples.flexibleadapter.views.HeaderView)1