Skip to content

Commit

Permalink
Merge branch 'release/v1.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepenz committed Feb 23, 2016
2 parents 4d1e9dd + 27581b0 commit 1d8cc28
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ You can try it out here [Google Play](https://play.google.com/store/apps/details

The library is split up into core, and extensions. The core functions are included in the following dependency.
```gradle
compile('com.mikepenz:fastadapter:1.1.0@aar') {
compile('com.mikepenz:fastadapter:1.1.1@aar') {
transitive = true
}
```
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 110
versionName '1.1.0'
versionCode 111
versionName '1.1.1'

applicationVariants.all { variant ->
variant.outputs.each { output ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public boolean filter(SampleItem item, CharSequence constraint) {
}
});

fastItemAdapter.getItemAdapter().setItemFilterListener(this);
fastItemAdapter.getItemAdapter().withItemFilterListener(this);

//get our recyclerView and do basic setup
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.rv);
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta4'
classpath 'com.android.tools.build:gradle:2.0.0-beta5'
classpath 'com.novoda:bintray-release:0.3.4'
}
}
Expand All @@ -26,5 +26,5 @@ allprojects {
}

task wrapper(type: Wrapper) {
gradleVersion = '2.10'
gradleVersion = '2.11'
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Dec 28 13:17:13 CET 2015
#Tue Feb 23 21:51:53 CET 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-all.zip
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 110
versionName '1.1.0'
versionCode 111
versionName '1.1.1'
}
buildTypes {
release {
Expand Down
4 changes: 2 additions & 2 deletions library/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ POM_NAME=FastAdapter Library
POM_ARTIFACT_ID=fastadapter
POM_PACKAGING=aar

VERSION_NAME=1.1.0
VERSION_CODE=110
VERSION_NAME=1.1.1
VERSION_CODE=111
23 changes: 23 additions & 0 deletions library/src/main/java/com/mikepenz/fastadapter/FastAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,29 @@ public int getPreItemCount(int position) {
return mAdapterSizes.floorKey(position);
}

/**
* calculates the count of expandable items before a given position
*
* @param from the global start position you should pass here the count of items of the previous adapters (or 0 if you want to start from the beginning)
* @param position the global position
* @return the count of expandable items before a given position
*/
public int getExpandedItemsCount(int from, int position) {
int totalAddedItems = 0;
int length = mExpanded.size();
for (int i = 0; i < length; i++) {
//now we count the amount of expanded items within our range we check
if (mExpanded.keyAt(i) >= from && mExpanded.keyAt(i) < position) {
totalAddedItems = totalAddedItems + mExpanded.get(mExpanded.keyAt(i));
} else if (mExpanded.keyAt(i) >= position) {
//we do not care about all expanded items which are outside our range
break;
}
}
return totalAddedItems;
}


/**
* add the values to the bundle for saveInstanceState
*
Expand Down
10 changes: 5 additions & 5 deletions library/src/main/java/com/mikepenz/fastadapter/IItemAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,38 +47,38 @@ public interface IItemAdapter<Item extends IItem> extends IAdapter<Item> {
/**
* add an array of items at the given position within the existing items
*
* @param position the relative position (position of this adapter)
* @param position the global position
* @param items
*/
void add(int position, Item... items);

/**
* add a list of items at the given position within the existing items
*
* @param position the relative position (position of this adapter)
* @param position the global position
* @param items
*/
void add(int position, List<Item> items);

/**
* sets an item at the given position, overwriting the previous item
*
* @param position the relative position (position of this adapter)
* @param position the global position
* @param item
*/
void set(int position, Item item);

/**
* removes an item at the given position within the existing icons
*
* @param position the relative position (position of this adapter)
* @param position the global position
*/
void remove(int position);

/**
* removes a range of items starting with the given position within the existing icons
*
* @param position the relative position (position of this adapter)
* @param position the global position
* @param itemCount
*/
void removeRange(int position, int itemCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import com.mikepenz.fastadapter.utils.IdDistributor;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import static java.util.Arrays.asList;
Expand Down Expand Up @@ -69,14 +71,40 @@ public void filter(CharSequence constraint) {
mItemFilter.filter(constraint);
}

public void setItemFilterListener(ItemFilterListener listener) {
/**
* @param listener which will be called after the items were filtered
* @return this
*/
public ItemAdapter<Item> withItemFilterListener(ItemFilterListener listener) {
mItemFilterListener = listener;
return this;
}

//the listener which will be called after the items were filtered
protected ItemFilterListener mItemFilterListener;

/**
* interface for the ItemFilterListener
*/
public interface ItemFilterListener {
void itemsFiltered();
}

//
public Comparator<Item> mComparator;

/**
* define a comparator which will be used to sort the list "everytime" it is altered
* NOTE this will only sort if you "set" a new list or "add" new items (not if you provide a position for the add function)
*
* @param comparator used to sort the list
* @return this
*/
public ItemAdapter<Item> withComparator(Comparator<Item> comparator) {
this.mComparator = comparator;
return this;
}

/**
* @return the order of the items within the FastAdapter
*/
Expand Down Expand Up @@ -153,7 +181,8 @@ public <T> T setSubItems(IExpandable<T, Item> collapsible, List<Item> subItems)

/**
* set a new list of items and apply it to the existing list (clear - add) for this adapter
* Note may consider using setNewList if the items list is a reference to the list which is used inside the adapter
* NOTE may consider using setNewList if the items list is a reference to the list which is used inside the adapter
* NOTE this will not sort
*
* @param items the items to set
*/
Expand Down Expand Up @@ -211,6 +240,11 @@ public void setNewList(List<Item> items) {
}
mItems = new ArrayList<>(items);
mapPossibleTypes(mItems);

if (mComparator != null) {
Collections.sort(mItems, mComparator);
}

getFastAdapter().notifyAdapterDataSetChanged();
}

Expand All @@ -235,7 +269,13 @@ public void add(List<Item> items) {
}
mItems.addAll(items);
mapPossibleTypes(items);
getFastAdapter().notifyAdapterItemRangeInserted(getFastAdapter().getPreItemCountByOrder(getOrder()), items.size());

if (mComparator == null) {
getFastAdapter().notifyAdapterItemRangeInserted(getFastAdapter().getPreItemCountByOrder(getOrder()), items.size());
} else {
Collections.sort(mItems, mComparator);
getFastAdapter().notifyAdapterDataSetChanged();
}
}

/**
Expand All @@ -262,6 +302,7 @@ public void add(int position, List<Item> items) {
if (items != null) {
mItems.addAll(position - getFastAdapter().getPreItemCount(position), items);
mapPossibleTypes(items);

getFastAdapter().notifyAdapterItemRangeInserted(position, items.size());
}
}
Expand All @@ -278,6 +319,7 @@ public void set(int position, Item item) {
}
mItems.set(position - getFastAdapter().getPreItemCount(position), item);
mapPossibleType(item);

getFastAdapter().notifyAdapterItemChanged(position);
}

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">1.1.0</string>
<string name="library_fastadapter_libraryVersion">1.1.1</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 1d8cc28

Please sign in to comment.