EasyHeaderFooterAdapter


Source link: https://github.com/rubengees/EasyHeaderFooterAdapter

easy-header-footer-adapter

Add a header and/or footer to your RecyclerView - the easy way.

You can download the latest sample app here.

Features

  • Completely hassle-free. You don't have to change your existing implementation.
  • Support for LinearLayoutManager, GridLayoutManager and StaggeredGridLayoutManager.
  • LayoutParams of your Views are honoured.
  • The SpanSizeLookup of your GridLayoutManager continues to work without adjustments.
  • Support for stable ids.

Include in your Project

Add this to your root build.gradle (usually in the root of your project):

repositories {

  maven {
 url "https://jitpack.io" 
}
 
}

And this to your module build.gradle (usually in the app directory):

dependencies {

  compile 'com.github.rubengees:easy-header-footer-adapter:3.0.0@aar' 
}

If that doesn't work, look if there is a new version and the Readme was not updated yet.

Usage

There is almost zero configuration if you already have an adapter.
You wrap your adapter in the EasyHeaderFooterAdapter and set it to the RecyclerView like this:

YourAdapter adapter = new YourAdapter();
 EasyHeaderFooterAdapter easyHeaderFooterAdapter =

new EasyHeaderFooterAdapter(adapter);
  //Always set the LayoutManager BEFORE the adapter. recyclerView.setLayoutManager(new SomeLayoutManager());
 recyclerView.setAdapter(easyHeaderFooterAdapter);

You can then set a header or footer through the setHeader and setFooter methods:

headerFooterAdapter.setHeader(anyView);
 headerFooterAdapter.setFooter(anotherView);

Those can be removed by setting null to the aforementioned methods:

headerFooterAdapter.setHeader(null);
 headerFooterAdapter.setFooter(null);

And that's it! Easy right?

There are a view things to look out for though.

Positions

If you are using the positions returned by the ViewHolders getAdapterPosition method, you have to calculate the real position in your adapter. The method getRealPosition does exactly that:

adapter.setCallback(new MainAdapter.MainAdapterCallback() {

  @Override
  public void onItemClick(int position) {

int positionInYourDataSet = headerFooterAdapter.getRealPosition(position);

 // Do whatever you wanted to do with it.
  
}
 
}
);

You can find more info on that in the sample.

ViewTypes and Ids

The following ViewTypes and IDs are used internally, so don't use them yourself:

TYPE_HEADER = Integer.MIN_VALUE; TYPE_FOOTER = Integer.MIN_VALUE + 1; ID_HEADER = Long.MIN_VALUE; ID_FOOTER = Long.MIN_VALUE + 1;
Changing the LayoutManager at runtime

As the EasyHeaderFooterAdapter needs to configure your LayoutManager, you have to reset the adapter to the RecyclerView if you want to change the LayoutManager:

recycler.setLayoutManager(new YourNewLayoutManager());
  // Remember, always set if after the LayoutManager recycler.setAdapter(headerFooterAdapter);

Further reading

The sample features almost all use cases. Have a look here.
You can find the JavaDoc here.

Metrics

Contributions and contributors

A guide for contribution can be found here.

Resources

This library add the ability to listen for drawable click events for TextView, EditText and AutoCompleteTextView normally added in XML with android:drawableStart etc... or in code with setCompoundDrawables(...) and similar.

With this library you can flat a layout used to side any widget with an ImageView or ImageButton added to listen for click on the icon, to one unique custom view.

SwipeableRV is a library that provides a fast and convenient way to implement the 'swipe to dismiss' feature in Recycler View, as seen in apps such as Messenger.

SwipeableRV wraps around ItemTouchHelper from the Android Support Library. Therefore, developers do not need to do any extra work on ItemTouchHelper.Callback themselves. Instead they can just focus on creating a recycler view, adapter, and view holder as normal, plus some minimal work on specifying some details such as supported swipe directions, deletion message or icon.

A custom view that gives the user a look and feel of selecting options with smoother slider animation.

With this SDK you can access the API behind the DRAE (Diccionario de la Real Academia Española, the official spanish dictionary) in order to use it in your own app.

Shortify is used for minimizing your coding effort in your development environment. It has some builtin method and classes which helps you in creating mostly used element and tasks in Android app.

Android library handling flashlight for camera and camera2 api. Added support for handling display/screen light.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes