Search in sources :

Example 1 with GarageDoorItemAnimator

use of eu.davidea.samples.flexibleadapter.animators.GarageDoorItemAnimator 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)

Aggregations

SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)1 FastScroller (eu.davidea.fastscroller.FastScroller)1 GarageDoorItemAnimator (eu.davidea.samples.flexibleadapter.animators.GarageDoorItemAnimator)1 ScrollableUseCaseItem (eu.davidea.samples.flexibleadapter.items.ScrollableUseCaseItem)1