use of com.mikepenz.fastadapter.swipe.SimpleSwipeDrawerCallback in project Hentoid by avluis.
the class ErrorsFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// UI ELEMENTS
View rootView = inflater.inflate(R.layout.fragment_queue_errors, container, false);
mEmptyText = requireViewById(rootView, R.id.errors_empty_txt);
// Book list container
recyclerView = requireViewById(rootView, R.id.queue_list);
fastAdapter = FastAdapter.with(itemAdapter);
ContentItem item = new ContentItem(ContentItem.ViewType.ERRORS);
fastAdapter.registerItemFactory(item.getType(), item);
// Gets (or creates and attaches if not yet existing) the extension from the given `FastAdapter`
selectExtension = fastAdapter.getOrCreateExtension(SelectExtension.class);
if (selectExtension != null) {
selectExtension.setSelectable(true);
selectExtension.setMultiSelect(true);
selectExtension.setSelectOnLongClick(true);
selectExtension.setSelectWithItemUpdate(true);
selectExtension.setSelectionListener((i, b) -> this.onSelectionChanged());
FastAdapterPreClickSelectHelper<ContentItem> helper = new FastAdapterPreClickSelectHelper<>(selectExtension);
fastAdapter.setOnPreClickListener(helper::onPreClickListener);
fastAdapter.setOnPreLongClickListener(helper::onPreLongClickListener);
}
recyclerView.setAdapter(fastAdapter);
recyclerView.setHasFixedSize(true);
llm = (LinearLayoutManager) recyclerView.getLayoutManager();
// Swiping
SimpleSwipeDrawerCallback swipeCallback = new SimpleSwipeDrawerCallback(ItemTouchHelper.LEFT, this).withSwipeLeft(Helper.dimensAsDp(requireContext(), R.dimen.delete_drawer_width_list)).withSensitivity(1.5f).withSurfaceThreshold(0.3f);
touchHelper = new ItemTouchHelper(swipeCallback);
touchHelper.attachToRecyclerView(recyclerView);
// Item click listener
fastAdapter.setOnClickListener((v, a, i, p) -> onItemClick(i));
// Fast scroller
new FastScrollerBuilder(recyclerView).build();
initToolbar();
initSelectionToolbar();
attachButtons(fastAdapter);
addCustomBackControl();
return rootView;
}
Aggregations