use of androidx.recyclerview.widget.DefaultItemAnimator in project CloudReader by youlookwhat.
the class JokeFragment method initRefreshView.
private void initRefreshView() {
RefreshHelper.initLinear(bindingView.xrvWan, true).setItemAnimator(new DefaultItemAnimator());
RefreshHelper.setSwipeRefreshView(bindingView.srlWan);
mAdapter = new JokeAdapter();
bindingView.xrvWan.setAdapter(mAdapter);
bindingView.srlWan.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
bindingView.srlWan.postDelayed(() -> {
viewModel.setRefreshBK(true);
viewModel.setPage(new Random().nextInt(100));
viewModel.showQSBKList();
}, 100);
}
});
bindingView.xrvWan.setOnLoadMoreListener(new ByRecyclerView.OnLoadMoreListener() {
@Override
public void onLoadMore() {
int page = viewModel.getPage();
viewModel.setPage(++page);
viewModel.setRefreshBK(false);
viewModel.showQSBKList();
}
});
bindingView.xrvWan.setOnItemLongClickListener(new ByRecyclerView.OnItemLongClickListener() {
@Override
public boolean onLongClick(View v, int position) {
DialogBuild.showItems(v, mAdapter.getItemData(position).getContent());
return false;
}
});
viewModel.getData().observe(this, new Observer<List<DuanZiBean>>() {
@Override
public void onChanged(@Nullable List<DuanZiBean> duanZiBeans) {
showContentView();
if (bindingView.srlWan.isRefreshing()) {
bindingView.srlWan.setRefreshing(false);
}
if (duanZiBeans != null && duanZiBeans.size() > 0) {
if (viewModel.isRefreshBK()) {
mAdapter.setNewData(duanZiBeans);
} else {
mAdapter.addData(duanZiBeans);
bindingView.xrvWan.loadMoreComplete();
}
} else {
if (!viewModel.isRefreshBK()) {
showError();
} else {
bindingView.xrvWan.loadMoreComplete();
}
}
}
});
}
use of androidx.recyclerview.widget.DefaultItemAnimator in project Signal-Android by signalapp.
the class ContactSelectionListFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.contact_selection_list_fragment, container, false);
emptyText = view.findViewById(android.R.id.empty);
recyclerView = view.findViewById(R.id.recycler_view);
swipeRefresh = view.findViewById(R.id.swipe_refresh);
fastScroller = view.findViewById(R.id.fast_scroller);
showContactsLayout = view.findViewById(R.id.show_contacts_container);
showContactsButton = view.findViewById(R.id.show_contacts_button);
showContactsDescription = view.findViewById(R.id.show_contacts_description);
showContactsProgress = view.findViewById(R.id.progress);
chipGroup = view.findViewById(R.id.chipGroup);
chipGroupScrollContainer = view.findViewById(R.id.chipGroupScrollContainer);
constraintLayout = view.findViewById(R.id.container);
shadowView = view.findViewById(R.id.toolbar_shadow);
toolbarShadowAnimationHelper = new ToolbarShadowAnimationHelper(shadowView);
recyclerView.addOnScrollListener(toolbarShadowAnimationHelper);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.setItemAnimator(new DefaultItemAnimator() {
@Override
public boolean canReuseUpdatedViewHolder(@NonNull RecyclerView.ViewHolder viewHolder) {
return true;
}
});
Intent intent = requireActivity().getIntent();
Bundle arguments = safeArguments();
int recyclerViewPadBottom = arguments.getInt(RV_PADDING_BOTTOM, intent.getIntExtra(RV_PADDING_BOTTOM, -1));
boolean recyclerViewClipping = arguments.getBoolean(RV_CLIP, intent.getBooleanExtra(RV_CLIP, true));
if (recyclerViewPadBottom != -1) {
ViewUtil.setPaddingBottom(recyclerView, recyclerViewPadBottom);
}
recyclerView.setClipToPadding(recyclerViewClipping);
boolean isRefreshable = arguments.getBoolean(REFRESHABLE, intent.getBooleanExtra(REFRESHABLE, true));
swipeRefresh.setNestedScrollingEnabled(isRefreshable);
swipeRefresh.setEnabled(isRefreshable);
hideCount = arguments.getBoolean(HIDE_COUNT, intent.getBooleanExtra(HIDE_COUNT, false));
selectionLimit = arguments.getParcelable(SELECTION_LIMITS);
if (selectionLimit == null) {
selectionLimit = intent.getParcelableExtra(SELECTION_LIMITS);
}
isMulti = selectionLimit != null;
canSelectSelf = arguments.getBoolean(CAN_SELECT_SELF, intent.getBooleanExtra(CAN_SELECT_SELF, !isMulti));
if (!isMulti) {
selectionLimit = SelectionLimits.NO_LIMITS;
}
currentSelection = getCurrentSelection();
return view;
}
use of androidx.recyclerview.widget.DefaultItemAnimator in project AmazeFileManager by TeamAmaze.
the class MainFragment method onViewCreated.
@Override
@SuppressWarnings("PMD.NPathComplexity")
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mainFragmentViewModel = new ViewModelProvider(this).get(MainFragmentViewModel.class);
listView = rootView.findViewById(R.id.listView);
mToolbarContainer = getMainActivity().getAppbar().getAppbarLayout();
fastScroller = rootView.findViewById(R.id.fastscroll);
fastScroller.setPressedHandleColor(mainFragmentViewModel.getAccentColor());
View.OnTouchListener onTouchListener = (view1, motionEvent) -> {
if (adapter != null && mainFragmentViewModel.getStopAnims()) {
stopAnimation();
mainFragmentViewModel.setStopAnims(false);
}
return false;
};
listView.setOnTouchListener(onTouchListener);
// listView.setOnDragListener(new MainFragmentDragListener());
mToolbarContainer.setOnTouchListener(onTouchListener);
mSwipeRefreshLayout = rootView.findViewById(R.id.activity_main_swipe_refresh_layout);
mSwipeRefreshLayout.setOnRefreshListener(() -> loadlist((mainFragmentViewModel.getCurrentPath()), false, mainFragmentViewModel.getOpenMode()));
// String itemsstring = res.getString(R.string.items);// TODO: 23/5/2017 use or delete
mToolbarContainer.setBackgroundColor(MainActivity.currentTab == 1 ? mainFragmentViewModel.getPrimaryTwoColor() : mainFragmentViewModel.getPrimaryColor());
// listView.setPadding(listView.getPaddingLeft(), paddingTop, listView.getPaddingRight(),
// listView.getPaddingBottom());
setHasOptionsMenu(false);
initNoFileLayout();
HybridFile f = new HybridFile(OpenMode.UNKNOWN, mainFragmentViewModel.getCurrentPath());
f.generateMode(getActivity());
getMainActivity().getAppbar().getBottomBar().setClickListener();
if (utilsProvider.getAppTheme().equals(AppTheme.LIGHT) && !mainFragmentViewModel.isList()) {
listView.setBackgroundColor(Utils.getColor(getContext(), R.color.grid_background_light));
} else {
listView.setBackgroundDrawable(null);
}
listView.setHasFixedSize(true);
if (mainFragmentViewModel.isList()) {
mLayoutManager = new CustomScrollLinearLayoutManager(getContext());
listView.setLayoutManager(mLayoutManager);
} else {
if (mainFragmentViewModel.getColumns() == -1 || mainFragmentViewModel.getColumns() == 0)
mLayoutManagerGrid = new CustomScrollGridLayoutManager(getActivity(), 3);
else
mLayoutManagerGrid = new CustomScrollGridLayoutManager(getActivity(), mainFragmentViewModel.getColumns());
setGridLayoutSpanSizeLookup(mLayoutManagerGrid);
listView.setLayoutManager(mLayoutManagerGrid);
}
// use a linear layout manager
// View footerView = getActivity().getLayoutInflater().inflate(R.layout.divider, null);// TODO:
// 23/5/2017 use or delete
dividerItemDecoration = new DividerItemDecoration(getActivity(), false, getBoolean(PREFERENCE_SHOW_DIVIDERS));
listView.addItemDecoration(dividerItemDecoration);
mSwipeRefreshLayout.setColorSchemeColors(mainFragmentViewModel.getAccentColor());
DefaultItemAnimator animator = new DefaultItemAnimator();
listView.setItemAnimator(animator);
mToolbarContainer.getViewTreeObserver().addOnGlobalLayoutListener(this);
loadViews();
}
use of androidx.recyclerview.widget.DefaultItemAnimator in project prebid-mobile-android by prebid.
the class MainActivity method setupSettingsList.
private void setupSettingsList() {
SettingsAdapter adapter = new SettingsAdapter(this);
mListView.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false));
mListView.setItemAnimator(new DefaultItemAnimator());
mListView.setAdapter(adapter);
}
use of androidx.recyclerview.widget.DefaultItemAnimator in project prebid-mobile-android by prebid.
the class TestResultsActivity method setupResultsList.
private void setupResultsList() {
TestResultsAdapter adapter = new TestResultsAdapter();
mListView.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false));
mListView.setItemAnimator(new DefaultItemAnimator());
mListView.setAdapter(adapter);
}
Aggregations