Some of the advantages to using this suite:
- Customizable filtering logic
- Active filtering support
- Easily obtain internal data for use with
onSavedInstanceState()
LayoutInflater
passed to all view creation methods.
Currently, this suite supports three different data structures with a filterable and non-filterable (NF) version. Additionally it provides one supporting adapter.
ArrayList Backed
SparseArray Backed
JSONArray Backed
Support Adapters
- Ice Cream Sandwich
- Jelly Bean
- Kit Kat
- Lollipop
There are no plans to support Gingerbread at this time. In fact, I'm purposely attempting to avoid using any android support library if possible.
Of course for those just skimming through, here's a quick example of using the AbsArrayAdapter. Every adapter is just an abstract class that requires subclassing. It's more or less just like using Android's ArrayAdapter.
public class MovieAdapter extends AbsArrayAdapter<MovieItem> {
MovieAdapter(Context activity) {
super(activity);
}
@Override
public View getView(LayoutInflater inflater, int position, View convertView, ViewGroup parent) {
if (convertView == null) {
//Inflate your view
}
//Fill your view with data
return convertView;
}
//Easily customize your filtered results here. Too easy!
@Override
public boolean isFilteredOut(MovieItem movie, CharSequence constraint) {
return !movie.title.toLowerCase(Locale.US).contains(constraint.toString().toLowerCase(Locale.US));
}
}
Thats it!
You can use the following to retrieve the AAR from jCenter.
dependencies {
compile 'com.jaysoyer.lib:advanced-adapters:15.3'
}
Alternatively, all adapters are found within the lib
directory. Once the repo is cloned, you can import the module directly into your app. If using Eclipse, you'll need to manually copy each class file over to your code. For additional help refer to the Getting Started wiki.
Everything found within app
is the source code for the Google Play store demo app. You can also use it for seeing how to use the adapters.
You'll need to add the following proguard rules if using the JSONAdapter:
-keepclassmembers class com.sawyer.advadapters.widget.JSONAdapter {
boolean isFilteredOut(...);
}
-keepclassmembers class * extends com.sawyer.advadapters.widget.JSONAdapter {
boolean isFilteredOut(...);
}
Copyright 2014 Jay Soyer
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.