How to Contribute a New Layout Manager: Base Branch, Repo, and Other Advice Appreciated :D

133 views
Skip to first unread message

Beka Westberg

unread,
Nov 1, 2019, 12:26:54 PM11/1/19
to Android Contributors
Hello!

I would like to contribute a new Layout Manager. I noticed that many developers have trouble creating a Recycler View that loops. They tend to want to modify the Adapter, when the functionality can be added to the Layout Manager much more elegantly.

So far I have only contributed to open source projects through github, so I'm having a bit of trouble figuring out AOSP's much more robust contribution process.

Here are my two main questions:

* What branch should I branch off of to contribute a new Layout Manager?
* What is the best way to pull that branch using Repo?

But if anyone else has advice to help me get started, knows something I should be aware of, or has opinions about how the Layout Manager should be created, I'd love to hear that as well!

Thank you for the help! I'm excited to contribute!
--Beka

Adam Powell

unread,
Nov 18, 2019, 6:01:21 PM11/18/19
to android...@googlegroups.com
Hi Beka, apologies for the long delay in response.

At this time we're not looking to accept new RecyclerView LayoutManagers in the core Jetpack libraries, but please do not let that stop you from writing this and publishing it through Github. It looks like people would definitely find it useful.

If you find that you would need RecyclerView to support additional functionality in order to write this as an external module, we would be open to considering contributions to RecyclerView itself that would enable things like this. Contribution guidelines for Jetpack can be found in the readme at https://android.googlesource.com/platform/frameworks/support/+/androidx-master-dev.

--

---
You received this message because you are subscribed to the Google Groups "Android Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-contr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-contrib/16a5c422-f7cf-4d47-8b46-031635dd4bfe%40googlegroups.com.

Beka Westberg

unread,
Nov 19, 2019, 5:24:11 AM11/19/19
to Android Contributors
Hello,

Thank you for the reply and the link! I really appreciate the info!

So far the API has been pretty easy to work with. I think I ran into one issue with grabbing the adapter index of a view? I can't remember; it's been a while since I worked on it hehe

But I was actually just getting this set up on my new computer when I got your reply, so you might be hearing from me soon! :D

Thank you again for the reply, I really appreciate it =)
--Beka
To unsubscribe from this group and stop receiving emails from it, send an email to android...@googlegroups.com.

Ethan Hsu

unread,
Dec 17, 2019, 2:45:52 PM12/17/19
to Android Contributors
Glad you are discussing this issue Beka and Adam:

Currently, RecyclerViews (and Android lists in general) have been a massive pain point for developers. It takes around 100 lines just to define a simple one! Luckily, I am working with the Material Components Android team to develop a Material List component. To summarize, it will make lists easier by pre-defining binding adapters, xml card layouts, and behaviors (like reordering and swiping) for developers.

As the main contributor, I value your interest in wanting to make better Android lists and would like to invite you to check out the starter code I am developing with the Material Design team: https://github.com/material-components/material-components-android/issues/81

In the issue thread, there is discussion about what the component will like and a link to pull request 798 which is my start on the component. Feel free to comment on my code in pull request 798 and give feedback about how I can make the code for Material Lists better. The more perspectives I can get on the project... the better

Unfortunately, the project is in its early stages so I would not advise submitting contributions but you still can suggest possible things for me to consider in my contributions.

Hope I brought back your hopes of contributing to the Android codebase!

--Ethan

Beka Westberg

unread,
Dec 18, 2019, 2:35:03 PM12/18/19
to Android Contributors
Hi Ethan!

Thanks for pointing me to your work, that was really interesting! Thinking about it, it is kind of crazy how much code you have to write to define a simple list, I think your contributions will definitely help with that!

What I'm working on currently is a little bit different from what you're doing. I'm working adding flexibility by creating a custom LayoutManager, while it seems like your goal is to attack code complexity by simplifying ViewHolders/Adapters. But I still really enjoyed looking at your PR, and I would love to help in any way I can!

I started following that issue you linked so I'll be able to keep up on what you're doing (and any opportunities to help that come up) :D

Thank you again for sharing!
--Beka

Beka Westberg

unread,
Jan 30, 2020, 5:05:47 PM1/30/20
to Android Contributors
Hello Adam,

I ran into some issues trying to create a snap helper that works with my looping recycler view.

My first major problem was the SmoothScroller's mTargetIndex property. It is private, so I could not modify it after I passed a value to the setTargetPosition's super function. Because of how I needed to calculate that target position (I needed to "loop" the value based on the number of items in the layout) I needed to acess the LayoutManager before it was normally available. This resulted in some quite messy code.
I believe making the mTargetIndex propery protected, or forcing the SmoothScroller to access it through getTargetPosition would solve my first problem.

My second problem is that the SmoothScroller automatically ends the animation if the view is already in view. This does not work with my LayoutManager because it supports swiping away from a view and looping back around to it.
I believe that setting the mTargetView property to null by default would solve my second problem.

Do you feel like these suggestions are reasonable/might be accepted? If so what should be my next steps?

Also you can view my current work here.

Thank you for your time!
--Beka


On Monday, November 18, 2019 at 3:01:21 PM UTC-8, Adam Powell wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to android...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages