TonicArtos / SuperSLiM

A layout manager for the RecyclerView with interchangeable linear, grid, and staggered displays of views, all with configurable section headers including the sticky variety as specified in the material design docs.
http://tonicartos.nz
2.12k stars 297 forks source link

ViewPager does not display contents when using LinearSLM #153

Closed vicalcazar closed 8 years ago

vicalcazar commented 8 years ago

ViewPager content on a RecyclerView item is not displayed when using the LinearSLM.

Tracked it down to the ViewPager prematurely returning from onMeasure() => populate() method, since the ViewPager is not attached to the window.
https://github.com/android/platform_frameworks_support/blob/master/v4/java/android/support/v4/view/ViewPager.java#L982

Was able to resolve the issue by updating LinearSLM.java and moving the addView() call before the measureChild() call. https://github.com/TonicArtos/SuperSLiM/blob/early_release_4/library/src/main/java/com/tonicartos/superslim/LinearSLM.java#L60

That change didn't appear to have any side effects.

Is there a specific reason addView() is called after measureChild() in LinearSLM? Looking at the default LinearLayoutManager, measureChildWithMargins() is called after addView(). https://github.com/android/platform_frameworks_support/blob/master/v7/recyclerview/src/android/support/v7/widget/LinearLayoutManager.java#L1396

daritz4ever commented 8 years ago

:+1:

TonicArtos commented 8 years ago

This looks reasonable. I seem to remember the layout managers having SuperSLiMs current sequence, obviously that is different now. I am getting a new version of SuperSLiM ready at the moment and I'll make the change there. It'll be up once the house fibre gets connected next week.

vicalcazar commented 8 years ago

Fantastic...thanks very much. Good luck getting the fibre connected.

TonicArtos commented 8 years ago

They still haven't connected the fibre, but they did send, three weeks later, a mobile hotspot to use in the mean time. Anyway, I made sure to follow your recommendation in version 5 so you shouldn't have this problem again when you switch across. Version 5 isn't yet ready for use, but if you'd like to, you can check it out on the version5 branch.

About version 5

Version 5 is a new implementation of SuperSLiM that works using an internal graph of your data set. This solves many problems with the old design. In Milestone 1, version 5 renders your data set as a graph of sections and items. It supports horizontal and vertical configurations, in addition to the other common layout configurations for RecyclerView. Oh yes, it also works with RecyclerView's predictive animations. The design is also simpler to use and easier to extend. However, right now that actual layout is incomplete as it does not scroll.

Milestone 2 is focused on bringing the library up to a usable point. It will add scrolling, a complete linear section layout, a complete set of header layouts, and a few other things. There are a few more planned milestones too. Please see the project plan for more information.