-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switching between Linear/Grid LayoutManagers Bug #32
Comments
👍 That's pretty cool. I haven't tested swapping SLMs yet, but any time is a good time. I'll get this fixed as soon as I get some more sleep :) |
It's pretty late on your side of the pond! From playing with the sample, it feels as though it's the switching of the header that breaks it. If you leave the header using the LinearLM and switch the items to the GridLM, they simply stay the same size but headers are removed. It isn't until you switch the header over that the items appear as a grid. This of course gives us the awesome berserk header spam. |
There is a bug in SuperSLiM and a bug in your code. Here is a patch to get your coding working. From 66fb94f1387e0f4e6df49cba494db942239b0cc2 Mon Sep 17 00:00:00 2001
From: Tonic Artos <tonic.artos@gmail.com>
Date: Thu, 19 Feb 2015 13:39:16 +0000
Subject: [PATCH] Fix layout corruption on SLM swap.
- Workaround bug with sections with only headers.
- Correctly notify datachanges on SLM change, requestLayout() is not
enough with RecyclerView.
---
.../java/com/dattilio/patrick/superslimtest/RecyclerAdapter.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/src/main/java/com/dattilio/patrick/superslimtest/RecyclerAdapter.java b/app/src/main/java/com/dattilio/patrick/superslimtest/RecyclerAdapter.java
index 006e119..fb2e13d 100644
--- a/app/src/main/java/com/dattilio/patrick/superslimtest/RecyclerAdapter.java
+++ b/app/src/main/java/com/dattilio/patrick/superslimtest/RecyclerAdapter.java
@@ -87,7 +87,7 @@ public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
break;
case GRID_ITEM:
lp.layoutId = 1;
- lp.setFirstPosition(2);
+ lp.setFirstPosition(1);
holder.itemView.setLayoutParams(lp);
break;
}
@@ -129,7 +129,7 @@ public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
@Override
public void onClick(View v) {
isList = true;
- recyclerView.requestLayout();
+ notifyItemRangeChanged(1, getItemCount() - 1);
}
});
@@ -137,7 +137,7 @@ public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
@Override
public void onClick(View v) {
isList = false;
- recyclerView.requestLayout();
+ notifyItemRangeChanged(1, getItemCount() - 1);
}
});
}
--
2.1.0 |
When switching between a Linear/Grid LayoutManager, SuperSLiM... well it does this.
Source code for the example project here
The text was updated successfully, but these errors were encountered: