Skip to content

Commit

Permalink
Merge branch 'release/v0.7.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepenz committed Jan 13, 2016
2 parents c2b242c + 6f08d6c commit d4e4874
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 32 deletions.
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@

> The RecyclerView is one of the most used widgets in the Android world, and with it you have to implement an Adapter which provides the items for the view. Most use cases require the same base logic, but require you to write everything again and again.
The FastAdapter is here to simplify this process. You don't have to worry about the adapter anymore. Just write the logic for how your view should look like, and you are done.
The FastAdapter is here to simplify this process. You don't have to worry about the adapter anymore. Just write the logic for how your view/item should look like, and you are done.
This library has a fast and highly optimized core which provides core functionality, most apps require. It also prevents common mistakes by taking away those steps from the devs.
Beside being blazing fast, minimizing the code you need to write, it is also really easy to extend. Just provide another Adapter implementation, hook into the adapter chain, custom select / deselection behaviors. Everything is possible.

##A quick overview:
- Click / Long-Click listeners
- Selection / Multi-Selection
- Collapsable items
- Expandable items
- Write less code, get better results
- Headers
- Footers
- Highly optimized code
- Includes suggestions from the Android Team
- Easily extensible
- Chain other Adapters
- Comes with useful Helpers
- ActionModeHelper
- More to come...
Expand All @@ -26,7 +27,7 @@ Beside being blazing fast, minimizing the code you need to write, it is also rea
#Include in your project
##Using Maven
```javascript
compile('com.mikepenz:fastadapter:0.7.1@aar') {
compile('com.mikepenz:fastadapter:0.7.2@aar') {
transitive = true
}
```
Expand Down Expand Up @@ -81,7 +82,6 @@ public class SampleItem extends AbstractItem<SampleItem, SampleItem.ViewHolder>
}
}
}

```

###2. Set the Adapter to the RecyclerView
Expand All @@ -105,6 +105,19 @@ rv.setAdapter(itemAdapter.wrap(fastAdapter));
itemAdapter.add(ITEMS);
```

## Libs used in sample app:
Mike Penz:
- AboutLibraries https://github.com/mikepenz/AboutLibraries
- Android-Iconics https://github.com/mikepenz/Android-Iconics
- ItemAnimators https://github.com/mikepenz/ItemAnimators
- MaterialDrawer https://github.com/mikepenz/MaterialDrawer

Other Libs:
- Butterknife https://github.com/JakeWharton/butterknife
- Glide https://github.com/bumptech/glide
- MaterialScrollBar https://github.com/krimin-killr21/MaterialScrollBar
- StickyRecyclerHeadersAdapter https://github.com/timehop/sticky-headers-recyclerview


#Developed By

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
defaultConfig {
minSdkVersion 11
targetSdkVersion 23
versionCode 71
versionName '0.7.1'
versionCode 72
versionName '0.7.2'

applicationVariants.all { variant ->
variant.outputs.each { output ->
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
android:label="@string/app_name"
android:theme="@style/CustomTheme">
<!-- android:supportsRtl="true" -->
<activity
android:name=".IconGridActivity"
android:label="@string/sample_icon_grid">
<activity android:name=".IconGridActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.mikepenz.aboutlibraries.LibsBuilder;
import com.mikepenz.fastadapter.FastAdapter;
import com.mikepenz.fastadapter.IAdapter;
import com.mikepenz.fastadapter.IExpandable;
import com.mikepenz.fastadapter.IItem;
import com.mikepenz.fastadapter.adapters.ItemAdapter;
import com.mikepenz.fastadapter.app.items.IconItem;
Expand All @@ -35,7 +36,7 @@ public class IconGridActivity extends AppCompatActivity {
//save our header or result
private Drawer result = null;
//save our FastAdapter
private FastAdapter<SampleItem> fastAdapter;
private FastAdapter<IItem> fastAdapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -98,11 +99,11 @@ public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
.build();

//create our FastAdapter which will manage everything
fastAdapter = new FastAdapter<>();
fastAdapter.withOnClickListener(new FastAdapter.OnClickListener<SampleItem>() {
fastAdapter = new FastAdapter<IItem>();
fastAdapter.withOnClickListener(new FastAdapter.OnClickListener<IItem>() {
@Override
public boolean onClick(View v, IAdapter<SampleItem> adapter, SampleItem item, int position) {
if (item.getSubItems() != null) {
public boolean onClick(View v, IAdapter<IItem> adapter, IItem item, int position) {
if (item instanceof IExpandable && ((IExpandable) item).getSubItems() != null) {
fastAdapter.toggleExpandable(position);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ public void commitRemove(int position, ArrayList<? extends IItem> removed) {
});

//configure our fastAdapter
//as we provide id's for the items we want the hasStableIds enabled to speed up things
fastAdapter.setHasStableIds(true);
fastAdapter.withOnClickListener(new FastAdapter.OnClickListener<SampleItem>() {
@Override
public boolean onClick(View v, IAdapter<SampleItem> adapter, SampleItem item, int position) {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ org.gradle.daemon=true
org.gradle.parallel=true

# Maven stuff
VERSION_NAME=0.7.1
VERSION_CODE=71
VERSION_NAME=0.7.2
VERSION_CODE=72
GROUP=com.mikepenz

POM_DESCRIPTION=FastAdapter Library
Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
defaultConfig {
minSdkVersion 10
targetSdkVersion 23
versionCode 71
versionName '0.7.1'
versionCode 72
versionName '0.7.2'
}
buildTypes {
release {
Expand Down
30 changes: 19 additions & 11 deletions library/src/main/java/com/mikepenz/fastadapter/FastAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public class FastAdapter<Item extends IItem> extends RecyclerView.Adapter<Recycl
private boolean mMultiSelect = false;
// if we want the multiSelect only on longClick
private boolean mMultiSelectOnLongClick = true;
// if a user can deselect a selection via click. required if there is always one selected item!
private boolean mAllowDeselection = true;

// we need to remember all selections to recreate them after orientation change
private SortedSet<Integer> mSelections = new TreeSet<>();
Expand Down Expand Up @@ -126,6 +128,17 @@ public FastAdapter<Item> withMultiSelectOnLongClick(boolean multiSelectOnLongCli
return this;
}

/**
* If false, a user can't deselect an item via click (you can still do this programmatically)
*
* @param allowDeselection true if a user can deselect an already selected item via click
* @return this
*/
public FastAdapter<Item> withAllowDeselection(boolean allowDeselection) {
this.mAllowDeselection = allowDeselection;
return this;
}

/**
* re-selects all elements stored in the savedInstanceState
* IMPORTANT! Call this method only after all items where added to the adapters again. Otherwise it may select wrong items!
Expand Down Expand Up @@ -173,17 +186,6 @@ public FastAdapter<Item> withSavedInstanceState(Bundle savedInstanceState, Strin
return this;
}

/*
public FastAdapter wrap(AbstractAdapter abstractAdapter) {
if (abstractAdapter != null) {
registerAdapter(abstractAdapter);
abstractAdapter.setFastAdapter(this);
wrap(abstractAdapter.getParentAdapter());
}
return this;
}
*/

/**
* registers an AbstractAdapter which will be hooked into the adapter chain
*
Expand Down Expand Up @@ -522,10 +524,16 @@ public void toggleSelection(int position) {
* @param position the global position
*/
private void handleSelection(View view, Item item, int position) {
//if this item is not selectable don't continue
if (!item.isSelectable()) {
return;
}

//if we have disabled deselection via click don't continue
if (item.isSelected() && !mAllowDeselection) {
return;
}

boolean selected = mSelections.contains(position);
if (mSelectWithItemUpdate || view == null) {
if (!mMultiSelect) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<b>FastAdapter</b>, the bullet proof, fast and easy to use adapter library, which minimizes developing time to a fraction...
]]>
</string>
<string name="library_fastadapter_libraryVersion">0.7.1</string>
<string name="library_fastadapter_libraryVersion">0.7.2</string>
<string name="library_fastadapter_libraryWebsite">https://github.com/mikepenz/FastAdapter</string>
<string name="library_fastadapter_licenseId">apache_2_0</string>
<string name="library_fastadapter_isOpenSource">true</string>
Expand Down

0 comments on commit d4e4874

Please sign in to comment.