Search in sources :

Example 1 with LibraryItem

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;
}
Also used : LibraryItem(com.mikepenz.aboutlibraries.ui.item.LibraryItem) ArrayList(java.util.ArrayList) Library(com.mikepenz.aboutlibraries.entity.Library) FastAdapter(com.mikepenz.fastadapter.FastAdapter) ItemAdapter(com.mikepenz.fastadapter.adapters.ItemAdapter)

Aggregations

Library (com.mikepenz.aboutlibraries.entity.Library)1 LibraryItem (com.mikepenz.aboutlibraries.ui.item.LibraryItem)1 FastAdapter (com.mikepenz.fastadapter.FastAdapter)1 ItemAdapter (com.mikepenz.fastadapter.adapters.ItemAdapter)1 ArrayList (java.util.ArrayList)1