Skip to content

Commit

Permalink
Merge branch 'release/v0.1.0-SNAPSHOT'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepenz committed Dec 31, 2015
2 parents eae1f12 + 161f9e1 commit 025472e
Show file tree
Hide file tree
Showing 13 changed files with 289 additions and 153 deletions.
17 changes: 2 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#Include in your project
##Using Maven
```javascript
compile('com.mikepenz:fastadapter:0.0.6-SNAPSHOT@aar') {
compile('com.mikepenz:fastadapter:0.1.0-SNAPSHOT@aar') {
transitive = true
}

Expand All @@ -22,7 +22,7 @@ repositories {
###1. Implement your item (the easy way)
Just create a class which extends the `AbstractItem` as shown below. Implement the methods, and your item is ready.
```java
public class SampleItem extends AbstractItem<SampleItem> {
public class SampleItem extends AbstractItem<SampleItem, SampleItem.ViewHolder> {
public String name;
public String description;

Expand Down Expand Up @@ -67,19 +67,6 @@ public class SampleItem extends AbstractItem<SampleItem> {
this.description = (TextView) view.findViewById(com.mikepenz.materialdrawer.R.id.material_drawer_description);
}
}

//required to generate the ViewHolder for this type of item inside the adapter (just copy and paste this)
@Override
public ViewHolderFactory getFactory() {
return new ItemFactory();
}

//required to generate the ViewHolder for this type of item inside the adapter (just copy and paste this)
public static class ItemFactory implements ViewHolderFactory<ViewHolder> {
public ViewHolder factory(View v) {
return new ViewHolder(v);
}
}
}

```
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
applicationId "com.mikepenz.crossfader.app"
minSdkVersion 11
targetSdkVersion 23
versionCode 6
versionName '0.0.6-SNAPSHOT'
versionCode 10
versionName '0.1.0-SNAPSHOT'

applicationVariants.all { variant ->
variant.outputs.each { output ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

/**
* This sample showcases compatibility the awesome Sticky-Headers library by timehop
Expand Down Expand Up @@ -74,6 +73,12 @@ public boolean onClick(View v, int position, int relativePosition, IItem item) {
if (item instanceof SampleItem) {
if (((SampleItem) item).getSubItems() != null) {
fastAdapter.toggleCollapsible(position);

//if we are in CAB mode and there are no selections afterwards we end the CAB mode
if (actionMode != null && fastAdapter.getSelections().size() == 0) {
actionMode.finish();
}

return true;
}
}
Expand All @@ -84,6 +89,7 @@ public boolean onClick(View v, int position, int relativePosition, IItem item) {
return false;
}
});

fastAdapter.withOnLongClickListener(new FastAdapter.OnLongClickListener() {
@Override
public boolean onLongClick(View v, int position, int relativePosition, IItem item) {
Expand Down Expand Up @@ -114,13 +120,21 @@ public boolean onLongClick(View v, int position, int relativePosition, IItem ite
//fill with some sample data
headerAdapter.add(new SampleItem().withName("Header").withIdentifier(1));
List<IItem> items = new ArrayList<>();
for (int i = 1; i <= 100; i++) {
for (int i = 1; i <= 10; i++) {
SampleItem sampleItem = new SampleItem().withName("Test " + i).withHeader(headers[i / 5]).withIdentifier(100 + i);

if (i % 10 == 0) {
List<IItem> subItems = new LinkedList<>();
for (int ii = 1; ii <= 5; ii++) {
subItems.add(new SampleItem().withName("-- Test " + ii).withHeader(headers[i / 5]).withIdentifier(1000 + ii));
for (int ii = 1; ii <= 3; ii++) {
SampleItem subItem = new SampleItem().withName("-- SubTest " + ii).withHeader(headers[i / 5]).withIdentifier(1000 + ii);

List<IItem> subSubItems = new LinkedList<>();
for (int iii = 1; iii <= 3; iii++) {
subSubItems.add(new SampleItem().withName("---- SubSubTest " + iii).withHeader(headers[i / 5]).withIdentifier(10000 + iii));
}
subItem.withSubItems(subSubItems);

subItems.add(subItem);
}
sampleItem.withSubItems(subItems);
}
Expand Down Expand Up @@ -175,12 +189,7 @@ class ActionBarCallBack implements ActionMode.Callback {

@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
//we have to refetch the selections array again and again as the position will change after one item is deleted
Set<Integer> selections = fastAdapter.getSelections();
while (selections.size() > 0) {
itemAdapter.remove(fastAdapter.getRelativePosition(selections.iterator().next()).relativePosition);
selections = fastAdapter.getSelections();
}
fastAdapter.deleteAllSelectedItems();

//finish the actionMode
mode.finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

public class MultiselectSampleActivity extends AppCompatActivity {
//save our FastAdapter
Expand Down Expand Up @@ -139,12 +138,7 @@ class ActionBarCallBack implements ActionMode.Callback {

@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
//we have to refetch the selections array again and again as the position will change after one item is deleted
Set<Integer> selections = fastAdapter.getSelections();
while (selections.size() > 0) {
itemAdapter.remove(fastAdapter.getRelativePosition(selections.iterator().next()).relativePosition);
selections = fastAdapter.getSelections();
}
fastAdapter.deleteAllSelectedItems();

//finish the actionMode
mode.finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* Created by mikepenz on 28.12.15.
*/
public class SampleItem extends AbstractItem<SampleItem> implements ICollapsible<SampleItem> {
public class SampleItem extends AbstractItem<SampleItem, SampleItem.ViewHolder> implements ICollapsible<SampleItem> {

public String header;
public StringHolder name;
Expand Down Expand Up @@ -110,9 +110,8 @@ public ViewHolderFactory getFactory() {
return new ItemFactory();
}


public static class ItemFactory implements ViewHolderFactory<ViewHolder> {
public ViewHolder factory(View v) {
public ViewHolder create(View v) {
return new ViewHolder(v);
}
}
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.0.6-SNAPSHOT
VERSION_CODE=6
VERSION_NAME=0.1.0-SNAPSHOT
VERSION_CODE=10
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 @@ -7,8 +7,8 @@ android {
defaultConfig {
minSdkVersion 10
targetSdkVersion 23
versionCode 6
versionName '0.0.6-SNAPSHOT'
versionCode 10
versionName '0.1.0-SNAPSHOT'
}
buildTypes {
release {
Expand Down
Loading

0 comments on commit 025472e

Please sign in to comment.