Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addListener has a @NonNull notation, but takes @Nullable listeners from constructor #514

Closed
jlwatkins opened this issue Jan 8, 2018 · 1 comment

Comments

@jlwatkins
Copy link
Contributor

The addListener method says it takes a @nonnull, but handles the Null case. This makes it very hard to override this method when extending FlexibleAdapter.

@rusxakep
Copy link

rusxakep commented Feb 1, 2018

Hi, you need check nullable too:

public FlexibleAdapter(@Nullable List<T> items, @Nullable Object listeners, boolean stableIds) {
        super(stableIds);
        // Copy of the original list
        if (items == null) mItems = new ArrayList<>();
        else mItems = new ArrayList<>(items);
        // Initialize internal lists
        mScrollableHeaders = new ArrayList<>();
        mScrollableFooters = new ArrayList<>();
        mRestoreList = new ArrayList<>();
        mUndoPositions = new ArrayList<>();

        // Create listeners instances
        if (listeners != null) addListener(listeners);

        // Get notified when items are inserted or removed (it adjusts selected positions)
        registerAdapterDataObserver(new AdapterDataObserver());
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants