Skip to content
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

Support for 'RecyclerView' #59

Open
ApmeM opened this issue Sep 24, 2015 · 13 comments
Open

Support for 'RecyclerView' #59

ApmeM opened this issue Sep 24, 2015 · 13 comments

Comments

@ApmeM
Copy link
Owner

ApmeM commented Sep 24, 2015

Add support for RecyclerView LayoutManager.

@douglasjunior
Copy link

Continuing the discussion of #39.


The RecyclerView is a component created to replace the "ListView" and "GridLayout". It works with Adapters and also LayoutManagers.

The Adapters is designed to provide the data source, as well as in the ListView.

The LayoutManagers are responsible for organizing the items on the screen. Standards implementations are: LinearLayoutManager, GridLayoutManager, and StaggeredGridLayoutManager.

See examples here: https://guides.codepath.com/android/Using-the-RecyclerView


One problem that has been found to apply the function "FlowLayout", ie making the number of columns is dynamic, according to the screen size.

To solve, I applied this workaround: http://stackoverflow.com/questions/26666143/recyclerview-gridlayoutmanager-how-to-auto-detect-span-count

Then I had the idea of ​​creating a "FlowLayoutManager", so you can use the RecyclerView and all the advantages it provides. So I asked you if you had plans, because I believe that you can leverage the knowledge applied to FlowLayout.

This would also solve the question #14.


If I can help with anything else, I have little free time, but I am available.

@ApmeM
Copy link
Owner Author

ApmeM commented Sep 30, 2015

Hi,

You may try to use recycler view now.
The example is available in FlowLayoutManagerActivity.
Because of code restrucutization there can be some breaking changes (not sure what exactly can be broken, but if you were using layout parameters values - they are no longer available)

It is still not using all power of recycler view like scrolling or actual view recycling, but all original FlowLayuot functionality is there.

Thanks.

@douglasjunior
Copy link

Yes, I did tests with RecyclerView and it worked great!

The next step really is scrolling and recycling of views.

For example, I have cases in my list has 48 items, but only 2 are displayed at a time. When this runs notifyDataChanged it needs to update the 48 items. It is very slow.

Thanks for your time, it's getting very good, I believe that with that the library will cover a lot of users!

@dadino
Copy link

dadino commented Sep 30, 2015

Even with view recycling notifyDataSetChanged() will redraw all 48 items. You should use notifyItemChanged(int position) or similar to update just the needed views.

@douglasjunior
Copy link

In FlowLayoutManager it makes no difference, it will always be updated every item.

In my case, using the FlowLayoutManager is used 40% of CPU to notifyDatasetChanged. Using GridLayoutManager only 10%.

For the GidLayoutManager updates only the items that appear on the screen.

@niqo01
Copy link

niqo01 commented Oct 2, 2015

@ApmeM just tried master FlowLayoutManager and I am getting:

java.lang.IllegalArgumentException: Called attach on a child which is not detached: ViewHolder{10f1f7e9 position=0 id=0, oldPos=-1, pLpos:-1 no parent}
at android.support.v7.widget.RecyclerView$4.attachViewToParent(RecyclerView.java:587)
at android.support.v7.widget.ChildHelper.attachViewToParent(ChildHelper.java:239)
at android.support.v7.widget.RecyclerView$LayoutManager.attachView(RecyclerView.java:6492)
at android.support.v7.widget.RecyclerView$LayoutManager.attachView(RecyclerView.java:6507)
at android.support.v7.widget.RecyclerView$LayoutManager.attachView(RecyclerView.java:6518)
at org.apmem.tools.layouts.FlowLayoutManager.onLayoutChildren(FlowLayoutManager.java:63)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2847)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3145)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
at android.view.View.layout(View.java:15671)
at android.view.ViewGroup.layout(ViewGroup.java:5038)
at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1043)
...

@niqo01
Copy link

niqo01 commented Oct 2, 2015

Rolling back to commit 922fcc9e821d838f219c4a5fe5c11bfa0ce70313 fixes the issue

@niqo01
Copy link

niqo01 commented Oct 2, 2015

Also I am having an issue where all the cells width are correct but for two of them, half of the text is not visible due to the text being moved to a new line (Cell 3 and 4 on the screenshot). The cell width look correct though.
flowlayoutmanager

@eshkoliGilad
Copy link

Any updates on FlowLayoutManager ?

When I use notifyDataSetChanges() or notifyItemChanged() is scrolled back to the top.

@ApmeM

@douglasjunior
Copy link

@eshkoliGilad Please, create a new issue for a new question.

Tip: dont mention a user in your question to get attention.

@eshkoliGilad
Copy link

This is somewhat related to the issue.

onLayoutChildren is called again when updating the data set and I can't for my life seem to be able to get recycling to work with scroll like in other LayoutManagers.

Any solution for this issue ?

@douglasjunior

Edited: Why not mention user if what I'm writing is referring to him ?

@pzhangleo
Copy link

@niqo01 hi, do you find reason for problem with cell3 and cell4?
I find same problem too.

@icodeyou
Copy link

@eshkoliGilad hi. Have you fixed this issue ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants