mikepenz / FastAdapter

The bullet proof, fast and easy to use adapter library, which minimizes developing time to a fraction...
https://mikepenz.dev
Apache License 2.0
3.84k stars 494 forks source link

Trouble initializing SelectExtension #840

Closed RobbWatershed closed 4 years ago

RobbWatershed commented 4 years ago

Hi there,

I'm using FastAdapter v4.1.1 with Java. So far it works super fine for simple use cases.

However, it crashes at creation-time while I want to initialize the select extension.

pagedItemAdapter = new PagedModelAdapter<>(asyncDifferConfig, ContentItem::new);
fastAdapter = FastAdapter.with(pagedItemAdapter);
recyclerView.setAdapter(fastAdapter);
if (library != null) pagedItemAdapter.submitList(library);

selectExtension = fastAdapter.getOrCreateExtension(SelectExtension.class);
selectExtension.setSelectable(true); // <-- fails here because selectExtension is null !

Have I missed something ?


Using Android Studio 3.5.3

My gradle is as follows

implementation "com.mikepenz:fastadapter:4.1.1"
implementation "com.mikepenz:fastadapter-extensions-drag:4.1.1"
implementation "com.mikepenz:fastadapter-extensions-expandable:4.1.1"
implementation "com.mikepenz:fastadapter-extensions-scroll:4.1.1"
implementation "com.mikepenz:fastadapter-extensions-paged:4.1.1"
implementation "com.mikepenz:fastadapter-extensions-utils:4.1.1"
implementation "com.mikepenz:materialize:1.2.0"
RobbWatershed commented 4 years ago

Alright, thanks to Google I just found out about :

ExtensionsFactories.INSTANCE.register(new SelectExtensionFactory());

Seriously, the readme sample could be a little more up to date.

mikepenz commented 4 years ago

@RobbWatershed I am sorry that the README does no longer cover Java. v4 of the lib goes Kotlin first and it is highly suggested to also use it from Kotlin for this matter.