Search in sources :

Example 1 with FlexibleItemAnimator

use of eu.davidea.flexibleadapter.common.FlexibleItemAnimator in project FlexibleAdapter by davideas.

the class FragmentAnimators method initializeRecyclerView.

@SuppressWarnings({ "ConstantConditions", "NullableProblems" })
private void initializeRecyclerView(Bundle savedInstanceState) {
    mAdapter = new ExampleAdapter(DatabaseService.getInstance().getDatabaseList(), getActivity());
    // Experimenting NEW features (v5.0.0)
    mAdapter.expandItemsAtStartUp().setAutoCollapseOnExpand(false).setAutoScrollOnExpand(true).setOnlyEntryAnimation(false).setAnimationEntryStep(//In Overall, watch the effect at initial loading when Grid Layout is set
    true).setAnimationOnScrolling(DatabaseConfiguration.animateOnScrolling).setAnimationOnReverseScrolling(true).setAnimationInterpolator(new DecelerateInterpolator()).setAnimationDuration(300L);
    mRecyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
    mRecyclerView.setLayoutManager(createNewLinearLayoutManager());
    mRecyclerView.setAdapter(mAdapter);
    //mRecyclerView.setHasFixedSize(true); //Size of RV will not change
    // NOTE: Custom item animators inherit 'canReuseUpdatedViewHolder()' from Default Item
    // Animator. It will return true if a Payload is provided. FlexibleAdapter is actually
    // sending Payloads onItemChange notifications.
    mRecyclerView.setItemAnimator(new FlexibleItemAnimator());
    initializeSpinnerItemAnimators();
    initializeSpinnerScrollAnimators();
    // Experimenting NEW features (v5.0.0)
    mAdapter.setSwipeEnabled(true).getItemTouchHelperCallback().setSwipeFlags(//Enable swipe
    ItemTouchHelper.RIGHT);
    SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) getView().findViewById(R.id.swipeRefreshLayout);
    swipeRefreshLayout.setEnabled(false);
    mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, SelectableAdapter.MODE_IDLE);
    // Add 1 Scrollable Header
    mAdapter.addScrollableHeader(new ScrollableUseCaseItem(getString(R.string.animator_use_case_title), getString(R.string.animator_use_case_description)));
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ScrollableUseCaseItem(eu.davidea.samples.flexibleadapter.items.ScrollableUseCaseItem) FlexibleItemAnimator(eu.davidea.flexibleadapter.common.FlexibleItemAnimator) ExampleAdapter(eu.davidea.samples.flexibleadapter.ExampleAdapter) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout)

Aggregations

SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)1 FlexibleItemAnimator (eu.davidea.flexibleadapter.common.FlexibleItemAnimator)1 ExampleAdapter (eu.davidea.samples.flexibleadapter.ExampleAdapter)1 ScrollableUseCaseItem (eu.davidea.samples.flexibleadapter.items.ScrollableUseCaseItem)1