diff --git a/README.md b/README.md index e5d1496e2..62b4922ad 100644 --- a/README.md +++ b/README.md @@ -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 } diff --git a/app/build.gradle b/app/build.gradle index 954ccea5b..8e7a03308 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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 -> diff --git a/app/src/main/java/com/mikepenz/fastadapter/app/SampleActivity.java b/app/src/main/java/com/mikepenz/fastadapter/app/SampleActivity.java index 3ae958951..9489ac266 100755 --- a/app/src/main/java/com/mikepenz/fastadapter/app/SampleActivity.java +++ b/app/src/main/java/com/mikepenz/fastadapter/app/SampleActivity.java @@ -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 removed) { + public void commitRemove(int position, ArrayList removed) { Log.e("UndoHelper", "Pos: " + position + " Removed: " + removed.size()); //remember that the items were removed } diff --git a/app/src/main/java/com/mikepenz/fastadapter/app/adapter/StickyHeaderAdapter.java b/app/src/main/java/com/mikepenz/fastadapter/app/adapter/StickyHeaderAdapter.java index 5d9ba8939..0ecbc59f3 100644 --- a/app/src/main/java/com/mikepenz/fastadapter/app/adapter/StickyHeaderAdapter.java +++ b/app/src/main/java/com/mikepenz/fastadapter/app/adapter/StickyHeaderAdapter.java @@ -93,4 +93,9 @@ public int getAdapterPosition(IItem item) { return -1; } + @Override + public int getGlobalPosition(int position) { + return -1; + } + } diff --git a/gradle.properties b/gradle.properties index 3f2882dba..2a325a1a7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/library/build.gradle b/library/build.gradle index 74d582946..3c00c7ee0 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -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 { diff --git a/library/src/main/java/com/mikepenz/fastadapter/FastAdapter.java b/library/src/main/java/com/mikepenz/fastadapter/FastAdapter.java index b3745de50..b9a789a4b 100644 --- a/library/src/main/java/com/mikepenz/fastadapter/FastAdapter.java +++ b/library/src/main/java/com/mikepenz/fastadapter/FastAdapter.java @@ -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) { @@ -304,11 +307,13 @@ public RelativeInfo getRelativeInfo(int position) { return new RelativeInfo<>(); } - IAdapter adapter = getAdapter(position); - Item item = (Item) adapter.getAdapterItem(position - getItemCount(adapter.getOrder())); RelativeInfo 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; } diff --git a/library/src/main/java/com/mikepenz/fastadapter/helpers/UndoHelper.java b/library/src/main/java/com/mikepenz/fastadapter/helpers/UndoHelper.java index ab371a9cf..d899228d9 100644 --- a/library/src/main/java/com/mikepenz/fastadapter/helpers/UndoHelper.java +++ b/library/src/main/java/com/mikepenz/fastadapter/helpers/UndoHelper.java @@ -11,10 +11,10 @@ /** * Created by mikepenz on 04.01.16. */ -public class UndoHelper { +public class UndoHelper { private static final int ACTION_REMOVE = 2; - private IItemAdapter mItemAdapter; + private IItemAdapter mItemAdapter; private UndoListener mUndoListener; private History mHistory = null; @@ -111,12 +111,12 @@ private void undoChange() { } public interface UndoListener { - void commitRemove(int position, ArrayList removed); + void commitRemove(int position, ArrayList removed); } private class History { public int action; public int position; - public ArrayList items = new ArrayList<>(); + public ArrayList items = new ArrayList<>(); } } diff --git a/library/src/main/java/com/mikepenz/fastadapter/utils/RecyclerViewCacheUtil.java b/library/src/main/java/com/mikepenz/fastadapter/utils/RecyclerViewCacheUtil.java index e9a2ed545..3f17989e5 100644 --- a/library/src/main/java/com/mikepenz/fastadapter/utils/RecyclerViewCacheUtil.java +++ b/library/src/main/java/com/mikepenz/fastadapter/utils/RecyclerViewCacheUtil.java @@ -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 { private int mCacheSize = 2; /** @@ -32,11 +32,11 @@ public RecyclerViewCacheUtil withCacheSize(int cacheSize) { * @param recyclerView * @param items */ - public void apply(RecyclerView recyclerView, Iterable items) { + public void apply(RecyclerView recyclerView, Iterable items) { if (items != null) { //we pre-create the views for our cache HashMap> cache = new HashMap<>(); - for (IItem d : items) { + for (Item d : items) { if (!cache.containsKey(d.getType())) { cache.put(d.getType(), new Stack()); } diff --git a/library/src/main/res/values/library_fastadapter_strings.xml b/library/src/main/res/values/library_fastadapter_strings.xml index 6cc991743..daed3f2ec 100755 --- a/library/src/main/res/values/library_fastadapter_strings.xml +++ b/library/src/main/res/values/library_fastadapter_strings.xml @@ -10,7 +10,7 @@ The FastAdapter 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. ]]> - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT https://github.com/mikepenz/FastAdapter apache_2_0 true