hoanganhx86/FlexibleAdapter


1 Adapter for SelectionMode, ViewHolders, AsyncFilter, FastScroller, Animations, Undo, Sections, Sticky Headers, Scrollable Headers and Footers, EndlessScroll, Expandable, Draggable, Swipeable :-)

Download


Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}
	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.hoanganhx86:flexibleadapter:5.0.0-rc1'
	}
	<dependency>
	    <groupId>com.github.hoanganhx86</groupId>
	    <artifactId>flexibleadapter</artifactId>
	    <version>5.0.0-rc1</version>
	</dependency>

                            
    libraryDependencies += "com.github.hoanganhx86" % "flexibleadapter" % "5.0.0-rc1"
        
        

                            
    :dependencies [[com.github.hoanganhx86/flexibleadapter "5.0.0-rc1"]]
        
        

Readme


Android Arsenal Download API Licence Methods and Size

FlexibleAdapter

####ANNOUNCEMENT: Important and Revolutionary changes are foreseen in v5.0.0. Please see issues and releases.

Fast and versatile Adapter for your RecyclerView
  • NEW! First release candidate: v5.0.0-rc1 built on 2017.01.14
  • If you come from previous versions, update your code following the Wiki page Migrations.

When initially Android team introduced the RecyclerView widget, we had to implement a custom Adapter in several applications, again and again to provide the items for our views.<br/> We didn't know how to add selection and to combine all the use cases in the same Adapter. Since I created this library, it has become easy to configure how views will be displayed in a list, and now, nobody wants to use a ListView anymore.

The idea behind is to regroup multiple features in a unique library, without the need to customize and import several third libraries not compatible among them.

The FlexibleAdapter helps developers to simplify this process without worrying too much about the Adapter anymore. It's easy to extend, it has predefined logic for different situations and prevents common mistakes.<br/> This library is configurable and it guides the developers to create a better user experience and now, even more with the new features.

Main features

  • Simple item selection with ripple effect, Single & Multi selection mode.
  • Restore deleted items, NEW works with Expandable items too!
  • Customizable FastScroller, NEW now in the library supporting all the 3 Layouts.
  • Customizable divider item decoration.
  • Add and Remove items with custom animations.
  • Async SearchFilter with Spannable text, NEW result list is animated. Works with sub items too!
  • NEW! High performance updates and filter on big list.
  • NEW! Auto mapping multi view types with Item interfaces.
  • NEW! Predefined ViewHolders with callbacks.
  • NEW! Headers and Sections with sticky behaviour fully clickable and collapsible, with elevation, transparency and automatic linkage!
  • NEW! Scrollable Headers and Footers items that lay respectively at the top and at the bottom of the main items.
  • NEW! Expandable items with Selection Coherence and multi-level expansion.
  • NEW! Drag&Drop and Swipe-To-Dismiss with Leave-Behind pattern and with Selection Coherence.
  • NEW! Customizable scrolling animations based on adapter position and beyond.
  • NEW! Innovative EndlessScroll (No OnScrollListener).
  • NEW! UndoHelper & ActionModeHelper.
  • NEW! DrawableUtils for dynamic backgrounds with ripple (No XML).
  • NEW! Easy runtime position calculation for adding/moving items in sections.
  • NEW! Wiki pages documentation.

Setup

repositories {
	jcenter()
	maven {url = "https://oss.sonatype.org/content/repositories/snapshots/" } //For Snapshots
}
dependencies {
	// Using JCenter
	compile 'eu.davidea:flexible-adapter:5.0.0-rc1'
	
	// Using MavenSnapshots repository for continuous updates from my development
	compile 'eu.davidea:flexible-adapter:5.0.0-SNAPSHOT'
}

Wiki!

I strongly recommend to read the new Wiki pages, where you can find a comprehensive Tutorial*.<br/> Wiki pages have been completely reviewed to support all the coming features of version 5.0.0.

* = Pages are under heavy revision, working in progress :-)

Pull requests / Issues / Improvement requests

Feel free to contribute and ask!<br/> Active discussions:

Under the hood

Some simple features have been implemented, thanks to some Blogs (see at the bottom of the page), merged and methods have been improved for speed and scalability.

  • At lower level there is SelectableAdapter class. It provides selection features and it's able to maintain the state after the rotation: you just need to call the onSave/onRestore methods from the Activity!
  • At middle level, the AnimatorAdapter class has been added to give some animation at startup and when user scrolls.
  • At front level, the core class FlexibleAdapter. It holds and handles the main list, performs actions on all different types of item paying attention at the adding and removal of the items, as well as the new concept of "selection coherence".
  • New useful extensions and helpers have been added during the time to simplify the development.
  • Item interfaces and predefined ViewHolders complete the whole library giving more actions to the items and configuration options to the developers and the end user.

Showcase of the demo App

You can download the latest demo App from the latest release page OR run it with the emulator.

Drag Grid & Overall Secondary Functionalities StickyHeaders & EndlessScrolling

Multi Selection & SC Undo Drag Linear

Search swipe-to-dismiss1 swipe-to-dismiss2

Adapter Animations Dynamic Sections Staggered Layout

Change Log

Latest release

v5.0.0-rc1 - 2017.01.14

Old releases

v5.0.0-b8 - 2016.09.17 | v5.0.0-b7 - 2016.06.20 | v5.0.0-b6 - 2016.05.01 | v5.0.0-b5 - 2016.04.04<br/> v5.0.0-b4 - 2016.02.21 | v5.0.0-b3 - 2016.02.08 | v5.0.0-b2 - 2016.01.31 | v5.0.0-b1 - 2016.01.03<br/> v4.2.0 - 2015.12.12 | v4.1.0 - 2015.11.29 | v4.0.1 - 2015.11.01 | v4.0.0 - 2015.10.18<br/> v3.1 - 2015.08.18 | v3.0 - 2015.07.29 | v2.2 - 2015.07.20 | v2.1 - 2015.07.03 | v2.0 - 2015.06.19 | v1.0 - 2015.05.03

Limitations

Item half swipe cannot be implemented due to how the android.support.v7.widget.helper.ItemTouchHelper is done, also clicks on rear view are not possible, same reason. Half swipe can be done with others means, please see issues #98 and #100. See also commits of Apr 25, 2016.

Thanks

I've used these blogs as starting point:

  • http://enoent.fr/blog/2015/01/18/recyclerview-basics/
  • https://www.grokkingandroid.com/statelistdrawables-for-recyclerview-selection/

Special thanks goes to Martin Guillon (Akylas) to have contributed at the development of the new technique for the Sticky Header.

Imported libraries

Apps that use this Adapter

It will be a pleasure to add your App here, once it is published.

Module.org | Socio - Shake and Connect! | Shibagram | BNVR Client

License

Copyright 2015-2017 Davide Steduto

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.