luizgrp / SectionedRecyclerViewAdapter

An Adapter that allows a RecyclerView to be split into Sections with headers and/or footers. Each Section can have its state controlled individually.
MIT License
1.68k stars 372 forks source link

Can we have SectionedRecyclerViewAdapter.getSectionItemViewTypeForAdapterViewType as static method? #198

Closed yccheok closed 4 years ago

yccheok commented 4 years ago

Can we have https://github.com/luizgrp/SectionedRecyclerViewAdapter/blob/master/library/src/main/java/io/github/luizgrp/sectionedrecyclerviewadapter/SectionedRecyclerViewAdapter.java#L500

as static method?

public static int getSectionItemViewTypeForAdapterViewType(final int itemViewType) {
    return itemViewType % VIEW_TYPE_QTY;
}

This is especially useful in the following use case (Drag and move)

@Override
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
    if (SectionedRecyclerViewAdapter.VIEW_TYPE_ITEM_LOADED != SectionedRecyclerViewAdapter.getSectionItemViewTypeForAdapterViewType(viewHolder.getItemViewType())) {
        final int dragFlags = 0;
        final int swipeFlags = 0;
        return makeMovementFlags(dragFlags, swipeFlags);
    }

Thanks.

luizgrp commented 4 years ago

sure 👍

yccheok commented 4 years ago

Thank you. Didn't expect such a speedy response.