dvdciri / MultiChoiceRecyclerView

Multi choice selection applied on recycler view make life easier

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NullPointerException when setting the title of "selected items" to null

jdamacena opened this issue · comments

Context

When you call .setTitles(toolbarTitle(), "item selected") passing null as the title of selected items like this: .setTitles(toolbarTitle(), null), the library gives an exception and the application breaks.

Steps to reproduce

An example of code that can make the exception to appear

 MultiChoiceToolbar multiChoiceToolbar =
                    new MultiChoiceToolbar.Builder(SampleToolbarActivity.this, toolbar)
                            .setTitles(toolbarTitle(), null)
                            .setMultiChoiceColours(R.color.colorPrimaryMulti, R.color.colorPrimaryDarkMulti)
                            .setDefaultIcon(R.drawable.ic_arrow_back_white_24dp, new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    onBackPressed();
                                }
                            })
                            .build();

        mAdapter.setMultiChoiceToolbar(multiChoiceToolbar);

Current behaviour

The library gives a nullPointerExeception and the application breaks

Expected behaviour

The library treats the null value and sets the title to a default title (i.e. "" (empty string))

Thanks for the issue. Honestly I don't think this is a bug, that method is used to append something to the number of items selected, therefore if you don't want to show anything it's an empty string. There's no point of supporting null string, it shouldn't be null.

I'll leave it open with a low priority. Thanks