Skip to content

Multiple items adapter made too easy, including headers and footers.

License

Notifications You must be signed in to change notification settings

DavidPacioianu/TheGreatAdapter

Repository files navigation

TheGreatAdapter

Android Arsenal Platform API Download GitHub license

Multiple items adapter made easy, including headers and footers.


Preview in WallSnap


Gradle Dependency

dependencies {
    compile 'com.pacioianu.david:the-great-adapter:0.1.0'
}

Usage

Simple usage:

GreatAdapter adapter = new GreatAdapter.Builder(context).build();

The magic of this adapter is that you can add any item, its class just has to implement the GreatItem interface.

Note:

  • Every class that implements the GreatItem interface must have a no-args constructor.
  • getItemType method must return a unique integer for every class.
  • getItemId method must return a unique id for every instance of the class.
  • getSpanSize method return the span size of every instance of the class, to make them match the full span size of the layout manager, return -1.
  • If you just want to add a one-time-use view to your recyclerview, use the SimpleItemView class. You just pass it the view you want to show, without the need of creating a useless viewholder. adapter.add(new SimpleViewItem(yourView);

Full builder options list:

new GreatAdapter.Builder(context)
        .enableLoadMore(true) // default false
        .loadItemsThreshold(2) // default 0
        .loadListener(yourLoadListener)
        .dividerSizeDp(2) // defaut 0
        .loadMoreView(yourCustomLoadMoreView)
        .loadFailedView(yourCustomLoadFailedView)
        .build();

To add/get/remove any header or footer, use:

adapter.addHeader(yourHeader);
adapter.addFooter(yourFooter);
adapter.getHeader(position);
adapter.getFooter(position);
adapter.removeHeader(yourHeader);
adapter.removeFooter(yourFooter);

Apps using the TheGreatAdapter

(feel free to send me your project)

Icon Application
WallSnap

Community

Looking for contributors, feel free to fork!


License

Copyright 2017 David Păcioianu

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

Multiple items adapter made too easy, including headers and footers.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages