Skip to content

Commit

Permalink
Merge branch 'release/v0.4.1-SNAPSHOT'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepenz committed Jan 5, 2016
2 parents 90b6e56 + 0c589bb commit 135846b
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,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.4.0-SNAPSHOT@aar') {
compile('com.mikepenz:fastadapter:0.4.1-SNAPSHOT@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 @@ -13,8 +13,8 @@ android {
applicationId "com.mikepenz.crossfader.app"
minSdkVersion 11
targetSdkVersion 23
versionCode 40
versionName '0.4.0-SNAPSHOT'
versionCode 41
versionName '0.4.1-SNAPSHOT'

applicationVariants.all { variant ->
variant.outputs.each { output ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
//
undoHelper = new UndoHelper(itemAdapter, new UndoHelper.UndoListener() {
@Override
public void commitRemove(int position, ArrayList<IItem> removed) {
public void commitRemove(int position, ArrayList<? extends IItem> removed) {
Log.e("UndoHelper", "Pos: " + position + " Removed: " + removed.size());
//remember that the items were removed
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,9 @@ public int getAdapterPosition(IItem item) {
return -1;
}

@Override
public int getGlobalPosition(int position) {
return -1;
}

}
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.4.0-SNAPSHOT
VERSION_CODE=40
VERSION_NAME=0.4.1-SNAPSHOT
VERSION_CODE=41
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 40
versionName '0.4.0-SNAPSHOT'
versionCode 41
versionName '0.4.1-SNAPSHOT'
}
buildTypes {
release {
Expand Down
13 changes: 9 additions & 4 deletions library/src/main/java/com/mikepenz/fastadapter/FastAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ public FastAdapter withSavedInstanceState(Bundle savedInstanceState) {
*/
public FastAdapter withSavedInstanceState(Bundle savedInstanceState, String prefix) {
if (savedInstanceState != null) {
//make sure already done selections are removed
deselect();

//first restore opened collasable items, as otherwise may not all selections could be restored
int[] collapsibles = savedInstanceState.getIntArray(BUNDLE_COLLAPSIBLE + prefix);
if (collapsibles != null) {
Expand Down Expand Up @@ -304,11 +307,13 @@ public RelativeInfo<Item> getRelativeInfo(int position) {
return new RelativeInfo<>();
}

IAdapter adapter = getAdapter(position);
Item item = (Item) adapter.getAdapterItem(position - getItemCount(adapter.getOrder()));
RelativeInfo<Item> relativeInfo = new RelativeInfo<>();
relativeInfo.item = item;
relativeInfo.adapter = adapter;
IAdapter adapter = getAdapter(position);
if (adapter != null) {
Item item = (Item) adapter.getAdapterItem(position - getItemCount(adapter.getOrder()));
relativeInfo.item = item;
relativeInfo.adapter = adapter;
}
return relativeInfo;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
/**
* Created by mikepenz on 04.01.16.
*/
public class UndoHelper {
public class UndoHelper<Item extends IItem> {
private static final int ACTION_REMOVE = 2;

private IItemAdapter mItemAdapter;
private IItemAdapter<Item> mItemAdapter;
private UndoListener mUndoListener;
private History mHistory = null;

Expand Down Expand Up @@ -111,12 +111,12 @@ private void undoChange() {
}

public interface UndoListener {
void commitRemove(int position, ArrayList<IItem> removed);
void commitRemove(int position, ArrayList<? extends IItem> removed);
}

private class History {
public int action;
public int position;
public ArrayList<IItem> items = new ArrayList<>();
public ArrayList<Item> items = new ArrayList<>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Created by mikepenz on 18.09.15.
* This util prefills the cache of the RecyclerView to allow fast lag-free scrolling with many different views
*/
public class RecyclerViewCacheUtil {
public class RecyclerViewCacheUtil<Item extends IItem> {
private int mCacheSize = 2;

/**
Expand All @@ -32,11 +32,11 @@ public RecyclerViewCacheUtil withCacheSize(int cacheSize) {
* @param recyclerView
* @param items
*/
public void apply(RecyclerView recyclerView, Iterable<IItem> items) {
public void apply(RecyclerView recyclerView, Iterable<Item> items) {
if (items != null) {
//we pre-create the views for our cache
HashMap<Integer, Stack<RecyclerView.ViewHolder>> cache = new HashMap<>();
for (IItem d : items) {
for (Item d : items) {
if (!cache.containsKey(d.getType())) {
cache.put(d.getType(), new Stack<RecyclerView.ViewHolder>());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
The <b>FastAdapter</b> is here to simplify this process. You do not have to worry about the adapter anymore. Just write the logic for how your view 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.
]]>
</string>
<string name="library_fastadapter_libraryVersion">0.4.0-SNAPSHOT</string>
<string name="library_fastadapter_libraryVersion">0.4.1-SNAPSHOT</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 135846b

Please sign in to comment.