Search in sources :

Example 1 with FastScroller

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

the class EmptyViewHelper method onUpdateFilterView.

@Override
public final void onUpdateFilterView(int size) {
    FastScroller fastScroller = mAdapter.getFastScroller();
    hideEmptyDataView();
    if (size > 0) {
        hideEmptyFilterView();
        if (fastScroller != null && fastScroller.isEnabled())
            fastScroller.showScrollbar();
    } else if (mEmptyFilterView != null && mEmptyFilterView.getAlpha() == 0) {
        showEmptyFilterView();
        if (fastScroller != null && !fastScroller.isHidden())
            fastScroller.hideScrollbar();
    }
    if (mEmptyViewListener != null) {
        mEmptyViewListener.onUpdateEmptyFilterView(size);
    }
}
Also used : FastScroller(eu.davidea.fastscroller.FastScroller)

Example 2 with FastScroller

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

the class EmptyViewHelper method onUpdateEmptyView.

@Override
public final void onUpdateEmptyView(int size) {
    FastScroller fastScroller = mAdapter.getFastScroller();
    hideEmptyFilterView();
    if (size > 0) {
        hideEmptyDataView();
        if (fastScroller != null && fastScroller.isEnabled())
            fastScroller.showScrollbar();
    } else if (mEmptyDataView != null && mEmptyDataView.getAlpha() == 0) {
        showEmptyDataView();
        if (fastScroller != null && !fastScroller.isHidden())
            fastScroller.hideScrollbar();
    }
    if (mEmptyViewListener != null) {
        mEmptyViewListener.onUpdateEmptyDataView(size);
    }
}
Also used : FastScroller(eu.davidea.fastscroller.FastScroller)

Example 3 with FastScroller

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

the class FragmentDataBinding method initializeRecyclerView.

@SuppressWarnings({ "ConstantConditions", "NullableProblems" })
private void initializeRecyclerView(Bundle savedInstanceState) {
    // Initialize Adapter and RecyclerView
    FlexibleAdapter.useTag("DataBindingAdapter");
    mAdapter = new BindingFlexibleAdapter<>(getActivity(), true);
    mAdapter.setAnimationOnForwardScrolling(DatabaseConfiguration.animateOnForwardScrolling);
    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 GarageDoorItemAnimator());
    // Add FastScroll to the RecyclerView, after the Adapter has been attached the RecyclerView!!!
    FastScroller fastScroller = getView().findViewById(R.id.fast_scroller);
    mAdapter.setFastScroller(fastScroller);
    // New empty views handling, to set after FastScroller
    EmptyViewHelper.create(mAdapter, getView().findViewById(R.id.empty_view), getView().findViewById(R.id.filter_view));
    mAdapter.setLongPressDragEnabled(true).setHandleDragEnabled(true).setSwipeEnabled(true).setDisplayHeadersAtStartUp(true).setStickyHeaders(true);
    SwipeRefreshLayout swipeRefreshLayout = getView().findViewById(R.id.swipeRefreshLayout);
    swipeRefreshLayout.setEnabled(true);
    mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, Mode.IDLE);
    mAdapter.addScrollableHeaderWithDelay(new ScrollableUseCaseItem(getString(R.string.databinding_use_case_title), getString(R.string.databinding_use_case_description)), 500L, false);
}
Also used : ScrollableUseCaseItem(eu.davidea.samples.flexibleadapter.items.ScrollableUseCaseItem) FastScroller(eu.davidea.fastscroller.FastScroller) GarageDoorItemAnimator(eu.davidea.samples.flexibleadapter.animators.GarageDoorItemAnimator) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout)

Example 4 with FastScroller

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

the class FragmentExpandableMultiLevel 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("ExpandableMultiLevelAdapter");
    mAdapter = new ExampleAdapter(DatabaseService.getInstance().getDatabaseList(), getActivity());
    mAdapter.expandItemsAtStartUp().setNotifyMoveOfFilteredItems(true).setAutoCollapseOnExpand(false).setMinCollapsibleLevel(// Auto-collapse only items with level >= 1 (avoid to collapse also sections!)
    1).setAutoScrollOnExpand(true);
    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);
    // New empty views handling, to set after FastScroller
    EmptyViewHelper.create(mAdapter, getView().findViewById(R.id.empty_view), getView().findViewById(R.id.filter_view));
    // Enable long press to drag items
    mAdapter.setLongPressDragEnabled(true).setHandleDragEnabled(// Enable handle drag
    true).setSwipeEnabled(// Enable swipe items
    true);
    // .setDisplayHeadersAtStartUp(true); //Show Headers at startUp: not necessary if Headers are also Expandable!
    mRecyclerView.addItemDecoration(new FlexibleItemDecoration(getActivity()).withSectionGapOffset(24));
    SwipeRefreshLayout swipeRefreshLayout = getView().findViewById(R.id.swipeRefreshLayout);
    swipeRefreshLayout.setEnabled(true);
    mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, Mode.IDLE);
    // Add 1 Scrollable Header
    mAdapter.addUserLearnedSelection(savedInstanceState == null);
}
Also used : FlexibleItemDecoration(eu.davidea.flexibleadapter.common.FlexibleItemDecoration) FastScroller(eu.davidea.fastscroller.FastScroller) ExampleAdapter(eu.davidea.samples.flexibleadapter.ExampleAdapter) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator)

Example 5 with FastScroller

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

the class FragmentEndlessScrolling method initializeRecyclerView.

private void initializeRecyclerView(Bundle savedInstanceState) {
    // Initialize Adapter and RecyclerView
    // ExampleAdapter makes use of stableIds, I strongly suggest to implement 'item.hashCode()'
    FlexibleAdapter.useTag("EndlessScrollingAdapter");
    if (savedInstanceState != null) {
        mAdapter = new ExampleAdapter(DatabaseService.getInstance().getDatabaseList(), getActivity());
    } else {
        mAdapter = new ExampleAdapter(null, getActivity());
    }
    mAdapter.setAutoScrollOnExpand(true).setNotifyMoveOfFilteredItems(// When true, filtering on big list is very slow, not in this case!
    true).setNotifyChangeOfUnfilteredItems(// true by default
    true).setAnimationOnForwardScrolling(DatabaseConfiguration.animateOnForwardScrolling).setAnimationOnReverseScrolling(true);
    mRecyclerView = getView().findViewById(R.id.recycler_view);
    mRecyclerView.setLayoutManager(createNewLinearLayoutManager());
    mRecyclerView.setAdapter(mAdapter);
    // Size of RV will not change
    mRecyclerView.setHasFixedSize(true);
    // NOTE: Use the custom FadeInDownAnimator for ALL notifications for ALL items,
    // but ScrollableFooterItem implements AnimatedViewHolder with a unique animation: SlideInUp!
    mRecyclerView.setItemAnimator(new FadeInDownItemAnimator());
    // 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);
    // New empty views handling, to set after FastScroller
    EmptyViewHelper.create(mAdapter, getView().findViewById(R.id.empty_view), getView().findViewById(R.id.filter_view));
    // Enable long press to drag items
    mAdapter.setLongPressDragEnabled(true).setHandleDragEnabled(// Enable drag using handle view
    true).setSwipeEnabled(// Enable swipe items
    true);
    SwipeRefreshLayout swipeRefreshLayout = getView().findViewById(R.id.swipeRefreshLayout);
    swipeRefreshLayout.setEnabled(true);
    mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, Mode.IDLE);
    // EndlessScrollListener - OnLoadMore (v5.0.0)
    // To call only if the list is empty
    mAdapter.setLoadingMoreAtStartUp(savedInstanceState == null).setEndlessScrollThreshold(// Default=1
    20).setEndlessScrollListener(this, mProgressItem).setTopEndless(false);
    // Add 1 Header item
    ScrollableLayoutItem scrollHeader = new ScrollableLayoutItem("SLI");
    scrollHeader.setTitle("Endless Scrolling");
    scrollHeader.setSubtitle("...with ScrollableHeaderItem");
    mAdapter.addScrollableHeader(scrollHeader);
}
Also used : FadeInDownItemAnimator(eu.davidea.samples.flexibleadapter.animators.FadeInDownItemAnimator) ScrollableLayoutItem(eu.davidea.samples.flexibleadapter.items.ScrollableLayoutItem) FastScroller(eu.davidea.fastscroller.FastScroller) ExampleAdapter(eu.davidea.samples.flexibleadapter.ExampleAdapter) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout)

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