use of eu.davidea.samples.flexibleadapter.OverallAdapter in project FlexibleAdapter by davideas.
the class FragmentOverall method initializeRecyclerView.
@SuppressWarnings({ "ConstantConditions", "NullableProblems" })
private void initializeRecyclerView(Bundle savedInstanceState) {
// Initialize Adapter and RecyclerView
// OverallAdapter makes use of stableIds, I strongly suggest to implement 'item.hashCode()'
// In this example the Adapter make uses of METHOD B and extends FlexibleAdapter: items
// don't implement the AutoMap and don't implement create and binding methods: The Adapter
// remains responsible to handling all view types.
mAdapter = new OverallAdapter(getActivity());
// Experimenting NEW features (v5.0.0)
mAdapter.setOnlyEntryAnimation(true).setAnimationInterpolator(new DecelerateInterpolator()).setAnimationInitialDelay(500L).setAnimationDelay(70L);
// Prepare the RecyclerView and attach the Adapter to it
mRecyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
//Setting ViewCache to 0 (default=2) will animate items better while scrolling down+up with LinearLayout
mRecyclerView.setItemViewCacheSize(0);
mRecyclerView.setLayoutManager(createNewStaggeredGridLayoutManager());
mRecyclerView.setAdapter(mAdapter);
//Size of RV will not change
mRecyclerView.setHasFixedSize(true);
// After Adapter is attached to RecyclerView
mAdapter.setLongPressDragEnabled(true);
mRecyclerView.postDelayed(new Runnable() {
@Override
public void run() {
if (getView() != null) {
//Fix NPE when closing app before the execution of Runnable
Snackbar.make(getView(), "Long press drag is enabled", Snackbar.LENGTH_SHORT).show();
}
}
}, 4000L);
SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) getView().findViewById(R.id.swipeRefreshLayout);
swipeRefreshLayout.setEnabled(true);
mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, SelectableAdapter.MODE_IDLE);
// Add 2 Scrollable Headers
mAdapter.showLayoutInfo(savedInstanceState == null);
mAdapter.addScrollableHeader(new ScrollableUseCaseItem(getString(R.string.overall_use_case_title), getString(R.string.overall_use_case_description)));
}
Aggregations