Search in sources :

Example 1 with FixedViewsAdapter

use of org.thoughtcrime.securesms.util.adapter.FixedViewsAdapter in project Signal-Android by WhisperSystems.

the class ContactSelectionListFragment method initializeCursor.

private void initializeCursor() {
    glideRequests = GlideApp.with(this);
    cursorRecyclerViewAdapter = new ContactSelectionListAdapter(requireContext(), glideRequests, null, new ListClickListener(), isMulti, currentSelection);
    RecyclerViewConcatenateAdapterStickyHeader concatenateAdapter = new RecyclerViewConcatenateAdapterStickyHeader();
    if (listCallback != null) {
        headerAdapter = new FixedViewsAdapter(createNewGroupItem(listCallback));
        headerAdapter.hide();
        concatenateAdapter.addAdapter(headerAdapter);
    }
    concatenateAdapter.addAdapter(cursorRecyclerViewAdapter);
    if (listCallback != null) {
        footerAdapter = new FixedViewsAdapter(createInviteActionView(listCallback));
        footerAdapter.hide();
        concatenateAdapter.addAdapter(footerAdapter);
    }
    recyclerView.addItemDecoration(new LetterHeaderDecoration(requireContext(), this::hideLetterHeaders));
    recyclerView.setAdapter(concatenateAdapter);
    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
                if (scrollCallback != null) {
                    scrollCallback.onBeginScroll();
                }
            }
        }
    });
    if (onContactSelectedListener != null) {
        onContactSelectedListener.onSelectionChanged();
    }
}
Also used : FixedViewsAdapter(org.thoughtcrime.securesms.util.adapter.FixedViewsAdapter) LetterHeaderDecoration(org.thoughtcrime.securesms.contacts.LetterHeaderDecoration) ContactSelectionListAdapter(org.thoughtcrime.securesms.contacts.ContactSelectionListAdapter) RecyclerView(androidx.recyclerview.widget.RecyclerView) RecyclerViewConcatenateAdapterStickyHeader(org.thoughtcrime.securesms.util.adapter.RecyclerViewConcatenateAdapterStickyHeader) SuppressLint(android.annotation.SuppressLint)

Example 2 with FixedViewsAdapter

use of org.thoughtcrime.securesms.util.adapter.FixedViewsAdapter in project Signal-Android by signalapp.

the class ContactSelectionListFragment method initializeCursor.

private void initializeCursor() {
    glideRequests = GlideApp.with(this);
    cursorRecyclerViewAdapter = new ContactSelectionListAdapter(requireContext(), glideRequests, null, new ListClickListener(), isMulti, currentSelection);
    RecyclerViewConcatenateAdapterStickyHeader concatenateAdapter = new RecyclerViewConcatenateAdapterStickyHeader();
    if (listCallback != null) {
        headerAdapter = new FixedViewsAdapter(createNewGroupItem(listCallback));
        headerAdapter.hide();
        concatenateAdapter.addAdapter(headerAdapter);
    }
    concatenateAdapter.addAdapter(cursorRecyclerViewAdapter);
    if (listCallback != null) {
        footerAdapter = new FixedViewsAdapter(createInviteActionView(listCallback));
        footerAdapter.hide();
        concatenateAdapter.addAdapter(footerAdapter);
    }
    recyclerView.addItemDecoration(new LetterHeaderDecoration(requireContext(), this::hideLetterHeaders));
    recyclerView.setAdapter(concatenateAdapter);
    recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
                if (scrollCallback != null) {
                    scrollCallback.onBeginScroll();
                }
            }
        }
    });
    if (onContactSelectedListener != null) {
        onContactSelectedListener.onSelectionChanged();
    }
}
Also used : FixedViewsAdapter(org.thoughtcrime.securesms.util.adapter.FixedViewsAdapter) LetterHeaderDecoration(org.thoughtcrime.securesms.contacts.LetterHeaderDecoration) ContactSelectionListAdapter(org.thoughtcrime.securesms.contacts.ContactSelectionListAdapter) RecyclerView(androidx.recyclerview.widget.RecyclerView) RecyclerViewConcatenateAdapterStickyHeader(org.thoughtcrime.securesms.util.adapter.RecyclerViewConcatenateAdapterStickyHeader) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 ContactSelectionListAdapter (org.thoughtcrime.securesms.contacts.ContactSelectionListAdapter)2 LetterHeaderDecoration (org.thoughtcrime.securesms.contacts.LetterHeaderDecoration)2 FixedViewsAdapter (org.thoughtcrime.securesms.util.adapter.FixedViewsAdapter)2 RecyclerViewConcatenateAdapterStickyHeader (org.thoughtcrime.securesms.util.adapter.RecyclerViewConcatenateAdapterStickyHeader)2