GithubHelp home page GithubHelp logo

Comments (3)

TonicArtos avatar TonicArtos commented on June 19, 2024

👍 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 :)

from superslim.

PatrickDattilio avatar PatrickDattilio commented on June 19, 2024

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.

from superslim.

TonicArtos avatar TonicArtos commented on June 19, 2024

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 <[email protected]>
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

from superslim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.