use of com.mikepenz.aboutlibraries.ui.item.LibraryItem in project AboutLibraries by mikepenz.
the class LibsBuilder method adapter.
/**
* builder to build an adapter out of the given information ;D
*
* @param context the current context
* @return a LibsRecyclerViewAdapter with the libraries
*/
public AbstractAdapter adapter(Context context) {
Libs libs;
if (fields == null) {
libs = new Libs(context);
} else {
libs = new Libs(context, fields);
}
//apply modifications
libs.modifyLibraries(libraryModification);
//fetch the libraries and sort if a comparator was set
ArrayList<Library> libraries = libs.prepareLibraries(context, internalLibraries, excludeLibraries, autoDetect, sort);
//prepare adapter
ItemAdapter itemAdapter = new ItemAdapter();
List<LibraryItem> libraryItems = new ArrayList<>();
for (Library library : libraries) {
libraryItems.add(new LibraryItem().withLibrary(library).withLibsBuilder(this));
}
//noinspection unchecked
itemAdapter.wrap(new FastAdapter());
itemAdapter.add(libraryItems);
return itemAdapter;
}
Aggregations