From 8c85ae1e3db1e2509fa4b6431d75e6d5d6fe2316 Mon Sep 17 00:00:00 2001 From: Razvan Lung Date: Sun, 7 May 2017 13:53:08 +0200 Subject: [PATCH] Resolved #357 - Allow usage of Parcelable for IHeaders and IFlexible If you pass the Items or Headers to an Intent as a Parcelable the headers are recreated as different instances and are shown above each item and not the whole group. The reason for this of the usage of reference equality check. We need to use the equal() to fix this issue. (cherry picked from commit 61a58e0) --- .../java/eu/davidea/flexibleadapter/FlexibleAdapter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/FlexibleAdapter.java b/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/FlexibleAdapter.java index be7bafa0..70fd4635 100644 --- a/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/FlexibleAdapter.java +++ b/flexible-adapter/src/main/java/eu/davidea/flexibleadapter/FlexibleAdapter.java @@ -1628,7 +1628,7 @@ private void showAllHeadersWithReset(boolean init) { T item = mItems.get(position); // Reset hidden status! Necessary after the filter and the update IHeader header = getHeaderOf(item); - if (header != sameHeader && header != null && !isExpandable((T) header)) { + if (!header.equals(sameHeader) && header != null && !isExpandable((T) header)) { sameHeader = header; header.setHidden(true); } @@ -4219,7 +4219,7 @@ private void resetFilterFlags(List items) { // Restore headers visibility if (headersShown) { IHeader header = getHeaderOf(item); - if (header != sameHeader && header != null && !isExpandable((T) header)) { + if (!header.equals(sameHeader) && header != null && !isExpandable((T) header)) { header.setHidden(false); sameHeader = header; items.add(i, (T) header); @@ -5502,7 +5502,7 @@ private void prepareItemsForUpdate(List newItems) { headersShown = true; } IHeader header = getHeaderOf(item); - if (header != sameHeader && header != null && !isExpandable((T) header)) { + if (header.equals(sameHeader) && header != null && !isExpandable((T) header)) { header.setHidden(false); sameHeader = header; newItems.add(position, (T) header);