Search in sources :

Example 1 with AttendeeItemCheckInEvent

use of org.fossasia.openevent.app.core.attendee.list.listeners.AttendeeItemCheckInEvent in project open-event-orga-app by fossasia.

the class AttendeesFragment method setupRecyclerView.

private void setupRecyclerView() {
    if (!initialized) {
        fastItemAdapter = new ItemAdapter<>();
        fastItemAdapter.getItemFilter().withFilterPredicate((attendee, query) -> {
            if (query == null)
                return true;
            if (query.equals(FILTER_SYNC)) {
                return attendee.checking.get();
            }
            return !SearchUtils.filter(query.toString(), attendee.getFirstname(), attendee.getLastname(), attendee.getEmail());
        });
        stickyHeaderAdapter = new StickyHeaderAdapter<>();
        stickyHeaderAdapter.setSortByName(false);
        fastAdapter = FastAdapter.with(Arrays.asList(fastItemAdapter, stickyHeaderAdapter));
        fastAdapter.setHasStableIds(true);
        fastAdapter.withEventHook(new AttendeeItemCheckInEvent(this));
        RecyclerView recyclerView = binding.rvAttendeeList;
        recyclerView.setLayoutManager(new LinearLayoutManager(context));
        recyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
        recyclerView.setItemAnimator(new DefaultItemAnimator());
        recyclerView.setAdapter(fastAdapter);
        final StickyRecyclerHeadersDecoration decoration = new StickyRecyclerHeadersDecoration(stickyHeaderAdapter);
        recyclerView.addItemDecoration(decoration);
        observer = new RecyclerView.AdapterDataObserver() {

            @Override
            public void onChanged() {
                super.onChanged();
                decoration.invalidateHeaders();
            }
        };
        fastAdapter.registerAdapterDataObserver(observer);
        ViewUtils.setRecyclerViewScrollAwareFabBehaviour(recyclerView, binding.fabScanQr);
    }
}
Also used : AttendeeItemCheckInEvent(org.fossasia.openevent.app.core.attendee.list.listeners.AttendeeItemCheckInEvent) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) StickyRecyclerHeadersDecoration(com.timehop.stickyheadersrecyclerview.StickyRecyclerHeadersDecoration) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Aggregations

DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 StickyRecyclerHeadersDecoration (com.timehop.stickyheadersrecyclerview.StickyRecyclerHeadersDecoration)1 AttendeeItemCheckInEvent (org.fossasia.openevent.app.core.attendee.list.listeners.AttendeeItemCheckInEvent)1