use of androidx.recyclerview.widget.DefaultItemAnimator 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);
}
use of androidx.recyclerview.widget.DefaultItemAnimator in project UltimateRecyclerView by cymcsg.
the class GridLayoutRVTest method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getMainLayout());
mToolbar = (Toolbar) findViewById(R.id.tool_bar);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayShowTitleEnabled(true);
listuv = (UltimateRecyclerView) findViewById(R.id.ultimate_recycler_view);
mGridAdapter = new GridJRAdapter(getJRList());
mGridAdapter.setSpanColumns(columns);
mGridLayoutManager = new BasicGridLayoutManager(this, columns, mGridAdapter);
listuv.setLayoutManager(mGridLayoutManager);
listuv.setHasFixedSize(true);
listuv.setSaveEnabled(true);
listuv.setClipToPadding(false);
// mGridAdapter.setCustomLoadMoreView(LayoutInflater.from(this).inflate(R.layout.custom_bottom_progressbar, null));
listuv.setNormalHeader(setupHeaderView());
final Handler f = new Handler();
listuv.setOnLoadMoreListener(new UltimateRecyclerView.OnLoadMoreListener() {
@Override
public void loadMore(int itemsCount, int maxLastVisiblePosition) {
// Log.d(TAG, itemsCount + " :: " + itemsCount);
f.postDelayed(new Runnable() {
@Override
public void run() {
mGridAdapter.insert(SampleDataboxset.genJRList(5));
afterAdd();
}
}, 2000);
}
});
// listuv.enableLoadmore();
// listuv.disableLoadmore();
listuv.setLoadMoreView(R.layout.custom_bottom_progressbar);
listuv.setAdapter(mGridAdapter);
listuv.setItemAnimator(new DefaultItemAnimator());
harness_control();
}
use of androidx.recyclerview.widget.DefaultItemAnimator in project collect by opendatakit.
the class AppListFragment method setupBottomSheet.
private void setupBottomSheet() {
CollectAbstractActivity activity = (CollectAbstractActivity) getActivity();
if (activity == null) {
Timber.e("Activity is null");
return;
}
bottomSheetDialog = new BottomSheetDialog(activity);
View sheetView = getActivity().getLayoutInflater().inflate(R.layout.bottom_sheet, null);
final RecyclerView recyclerView = sheetView.findViewById(R.id.recyclerView);
final SortDialogAdapter adapter = new SortDialogAdapter(getActivity(), recyclerView, sortingOptions, getSelectedSortingOrder(), new RecyclerViewClickListener() {
@Override
public void onItemClicked(SortDialogAdapter.ViewHolder holder, int position) {
holder.updateItemColor(selectedSortingOrder);
performSelectedSearch(position);
bottomSheetDialog.dismiss();
}
});
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapter);
recyclerView.setItemAnimator(new DefaultItemAnimator());
bottomSheetDialog.setContentView(sheetView);
}
use of androidx.recyclerview.widget.DefaultItemAnimator in project collect by opendatakit.
the class AppListActivity method showBottomSheetDialog.
private void showBottomSheetDialog() {
bottomSheetDialog = new BottomSheetDialog(this);
final View sheetView = getLayoutInflater().inflate(R.layout.bottom_sheet, null);
final RecyclerView recyclerView = sheetView.findViewById(R.id.recyclerView);
final SortDialogAdapter adapter = new SortDialogAdapter(this, recyclerView, sortingOptions, getSelectedSortingOrder(), new RecyclerViewClickListener() {
@Override
public void onItemClicked(SortDialogAdapter.ViewHolder holder, int position) {
holder.updateItemColor(selectedSortingOrder);
performSelectedSearch(position);
bottomSheetDialog.dismiss();
}
});
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapter);
recyclerView.setItemAnimator(new DefaultItemAnimator());
bottomSheetDialog.setContentView(sheetView);
bottomSheetDialog.show();
}
use of androidx.recyclerview.widget.DefaultItemAnimator in project collect by opendatakit.
the class AboutActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about_layout);
DaggerUtils.getComponent(this).inject(this);
initToolbar();
int[][] items = { { R.drawable.ic_outline_website_24, R.string.odk_website, R.string.odk_website_summary }, { R.drawable.ic_outline_forum_24, R.string.odk_forum, R.string.odk_forum_summary }, { R.drawable.ic_outline_share_24, R.string.tell_your_friends, R.string.tell_your_friends_msg }, { R.drawable.ic_outline_rate_review_24, R.string.leave_a_review, R.string.leave_a_review_msg }, { R.drawable.ic_outline_stars_24, R.string.all_open_source_licenses, R.string.all_open_source_licenses_msg } };
RecyclerView recyclerView = findViewById(R.id.recyclerView);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(new AboutListAdapter(items, this, this));
recyclerView.setItemAnimator(new DefaultItemAnimator());
websiteTabHelper = new ExternalWebPageHelper();
forumTabHelper = new ExternalWebPageHelper();
websiteUri = Uri.parse(getString(R.string.app_url));
forumUri = Uri.parse(getString(R.string.forum_url));
}
Aggregations