realm/realm-android-adapters

Data validation check missing from RealmBaseAdapter

Zhuinden opened this issue · 2 comments

https://github.com/realm/realm-android-adapters/blob/master/adapters/src/main/java/io/realm/RealmRecyclerViewAdapter.java#L191-L193

the validation check in RealmRecyclerViewAdapter:

    private boolean isDataValid() {
        return adapterData != null && adapterData.isValid();
    }

This is missing from RealmBaseAdapter:

// RecyclerViewAdapter
    @Override
    public int getItemCount() {
        //noinspection ConstantConditions
        return isDataValid() ? adapterData.size() : 0;
    }

// BaseAdapter
    @Override
    public int getCount() {
        if (adapterData == null) {
            return 0;
        }
        return adapterData.size();
    }

Version of Realm and tooling

Realm version(s): 3.1.4

Android Studio version: -

Which Android version and device: -

@Zhuinden thanks.
I made a PR.

fixed by #117