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

Share RecycledViewPool between view pager content fragments #660

Conversation

chibatching
Copy link
Contributor

@chibatching chibatching commented Feb 9, 2018

Issue

  • no issue

Overview (Required)

  • Share RecyclerViewPool between content fragments of Sessions ViewPager
    • It will reduce RecyclerView item inflating count.
    • In my environment view inflate count is reduced to 31 from 95
      • Launch app(room mode - all tab) -> select right each room tab in tab order -> switch mode (Day2 14:00) -> select left each tab to all tab in tab order

Problem

I'm not sure it is appropriate to keep RecyclerViewPool on SessionsViewModel. I think there are three options.

  1. Share through SessionsViewModel (This PR is) or other new ViewModel.
  2. Keep pool on SessionFragment and each content Fragment get from it.
  3. Keep pool on ViewPager and pass pool from ViewPager to content Fragment

Do you have any advice to give to?

Links

Screenshot

Before After

@takahirom
Copy link
Member

🆒

@@ -49,6 +50,9 @@ class SessionsViewModel @Inject constructor(
val isLoading: LiveData<Boolean> by lazy {
tab.map { it.inProgress }
}
val viewPool: RecyclerView.RecycledViewPool by lazy {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the comment here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this
// Share RecyclerViewPool between view pager content fragments

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comment on a1f9bbf !

@chibatching chibatching changed the title Share RecyclerViewPool between view pager content fragments Share RecycledViewPool between view pager content fragments Feb 9, 2018
@takahirom
Copy link
Member

We try this 👍

@takahirom takahirom merged commit 16edc4d into DroidKaigi:master Feb 9, 2018
@chibatching chibatching deleted the improve_view_pager_recycler_view_performance branch February 9, 2018 07:12
@takahirom
Copy link
Member

takahirom commented Feb 9, 2018

@chibatching
This is very useful pull request for all apps 👍
Sorry
When merged I was high.
I think this is leaking.
Because ViewModel can exist across the recreation of Activity.
And probably RecyclerViewPool have views that have activity
SessionFragment or MainActivity should have that.
Probably we should create an interface for that.
image

@chibatching
Copy link
Contributor Author

You may be right.
I''ll check and fix later!
Thanks!

@takahirom
Copy link
Member

@chibatching Thanks🙏

@chibatching
Copy link
Contributor Author

I fixed at #662 🙏

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

Successfully merging this pull request may close these issues.

None yet

2 participants