Search in sources :

Example 1 with FadeInDownAnimator

use of eu.davidea.samples.flexibleadapter.animators.FadeInDownAnimator in project FlexibleAdapter by davideas.

the class FragmentEndlessScrolling 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()'
    mAdapter = new ExampleAdapter(DatabaseService.getInstance().getDatabaseList(), getActivity());
    // Experimenting NEW features (v5.0.0)
    mAdapter.setAutoScrollOnExpand(true).setNotifyMoveOfFilteredItems(//When true, filtering on big list is very slow, not in this case!
    true).setNotifyChangeOfUnfilteredItems(//We have highlighted text while filtering, so let's enable this feature to be consistent with the active filter
    true).setAnimationOnScrolling(DatabaseConfiguration.animateOnScrolling).setAnimationOnReverseScrolling(true);
    mRecyclerView = (RecyclerView) 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 FadeInDownAnimator());
    // Add FastScroll to the RecyclerView, after the Adapter has been attached the RecyclerView!!!
    mAdapter.setFastScroller((FastScroller) getView().findViewById(R.id.fast_scroller), Utils.getColorAccent(getActivity()), (MainActivity) getActivity());
    // Experimenting NEW features (v5.0.0)
    //Enable long press to drag items
    mAdapter.setLongPressDragEnabled(true).setHandleDragEnabled(//Enable drag using handle view
    true).setSwipeEnabled(//Enable swipe items
    true);
    SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) getView().findViewById(R.id.swipeRefreshLayout);
    swipeRefreshLayout.setEnabled(true);
    mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, SelectableAdapter.MODE_IDLE);
    // EndlessScrollListener - OnLoadMore (v5.0.0)
    //.setLoadingMoreAtStartUp(true) //To call only if the list is empty
    mAdapter.setEndlessTargetCount(//Endless is automatically disabled if totalItems >= 15
    15).setEndlessScrollListener(this, mProgressItem);
    // Add 1 Scrollable Header and 1 Footer items
    mAdapter.showLayoutInfo(savedInstanceState == null);
    mAdapter.addScrollableFooter();
}
Also used : ExampleAdapter(eu.davidea.samples.flexibleadapter.ExampleAdapter) FadeInDownAnimator(eu.davidea.samples.flexibleadapter.animators.FadeInDownAnimator) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout)

Aggregations

SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 ExampleAdapter (eu.davidea.samples.flexibleadapter.ExampleAdapter)1 FadeInDownAnimator (eu.davidea.samples.flexibleadapter.animators.FadeInDownAnimator)1