1

Following will be the layout in my app

dummy screen So I am considering of using recycler view. There will be a parent recyclerview, I which I will define different view types for each section e.g, viewpager, horizontal block etc. Depending on view types, different viewholders will be created. Horizontal block will be displayed in horizontal recyclerview. For grid there will be a recycler view in another viewholder. The data for each section will be loaded from a different API. Means the first API will only give metadata, using that metadata, another API will be called whose data will be used to populated in the blocks.

My question is whether is this a good approach to have a parent recycler view, define view types and have other recylerviews inside view olders. As I am nesting recyclerview in other recycler, so should this approach will be fine wrt performance or there is some other way to implement such design.

I am using recycler view as it will be easy to implement pagination.

PS: I am not using linear layout as implementing pagination on linear layout is a bit tricky. I find it more easier in listview/recycler view. Also the sections like list/grid as shown, are dynamic one and there is no fixed number that they will be upto 2 or 5. It can be upto n. So, with linear layout, I have to add all sections in loop which will be overkill if the no. of sections quite large.

Nitish
  • 3,097
  • 13
  • 45
  • 80
  • 1
    If you have only predefined sections, why would you want to wrap it in a recycle view and not a linear layout? – regev avraham May 13 '17 at 07:24
  • @regevavraham Bcoz, data is loaded in two API hits the first API will give the metadata of the section to be created. The second API will populate data to that section. The list/grid that you are seeing in the outline can be upto n and will appear in alternate fashion as it will be managed by backend that how many sections do we want to show. – Nitish May 13 '17 at 10:20
  • @Downvoter It would be great if you explain your reason for downvoting. As I don't see anything silly which I have asked. It is all about deciding an architecture which best suites to this case. – Nitish May 13 '17 at 12:16
  • Well, I have a very similar use case. I'm using nested RecyclerViews. However, if the content is dynamic (for instance, if ViewPager's height is not constant, and may change according to its content), the parent/main RecyclerView's scroll becomes very jerky and jarring. I'm also eager to find solutions to such cases. – ArunL May 30 '17 at 12:55

0 Answers0