Skip to content

Search in Library sections#1566

Merged
svillar merged 3 commits intomainfrom
felipeerias/searchLibrary
Oct 25, 2024
Merged

Search in Library sections#1566
svillar merged 3 commits intomainfrom
felipeerias/searchLibrary

Conversation

@felipeerias
Copy link
Copy Markdown
Collaborator

Add a search bar for Bookmarks, History, and Downloads.

Each of these views keeps a cached version of the list of items. When the user enters a search term, we filter this cached list and update the Adapter. This avoids having to query the backend each time.

Currently this implementation updates the search results as the user types each character, but if this does not have good performance we can change it later on.

There is a change to the OnScrollListener to ensure that the RecyclerView only requests the focus when it scrolls as a result of user interaction, which will close the on-screen keyboard.

This PR also contains a couple of related changes to our RecyclerView lists.

First, we set the overScrollMode to never by default and remove those instances where it had been manually set. This removes the bouncing rubber band effect when scrolling the list.

Secondly, we remove CustomLinearLayoutManager, a workaround for an old bug in the RecyclerView library which is no longer necessary.

android:layout_marginEnd="20dp"
android:divider="@android:color/transparent"
android:smoothScrollbar="true"
android:overScrollMode="never"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess the question here is why. There is no explanation why we are doing that.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

overScrollMode is responsible for the "rubber band" effect in the lists. Here is a comparison on Pico (the Meta effect is slightly different).

  • current:
rubberband_high_quality_noaudio.mp4
  • this PR:
thispr_high_quality_noaudio.mp4

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yeah I know what the rubber band effect is, the question is why do we want to remove it, and secondly what's the relationship with adding search in the library?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It introduces an unnatural effect when scrolling long lists that doesn't look good IMHO. On Oculus, it slows down the scroll at the edges, and compresses and expands the items.

com.oculus.vrshell-20241018-115624.trimmed.mp4

For this PR I spent a long time using these lists and looking at their implementation, so I noticed this issue.

This particular change is included as a separate commit.

@felipeerias felipeerias force-pushed the felipeerias/searchLibrary branch from 41064d0 to e47cece Compare October 10, 2024 13:26
@felipeerias felipeerias requested a review from svillar October 10, 2024 13:26
Add a search bar for Bookmarks, History, and Downloads.

Each view keeps a cached version of the list of items. When the
user enters a search term, we filter this cached list and update
the Adapter. This avoids having to query the backend each time.

Currently this implementation updates the search results as the
user types each character, but if this does not have good performance
we can change it later on.

There is a change to the OnScrollListener to ensure that the
RecyclerView only requests the focus when it scrolls as a result
of user interaction, which will close the on-screen keyboard.
Set the "overScrollMode" to "never" by default and remove those instances
where it had been manually set.

The overscroll mode is the responsible for the bouncing and rubber-band
effect that happens when we reach the end of a scrollable list. This
effect makes sense in a touchscreen but it looks jarring on VR.
Remove CustomLinearLayoutManager, a workaround for an old bug
in the RecyclerView library and which is no longer necessary.

This change was added back in 2019:

  MozillaReality/FirefoxReality#1879

A comment in the code explained the issue:

> There seems to be a bug in the RecyclerView adapter that
> makes it crash sometimes when updating the dataset. This
> seems to be the only thing that works until there is
> a new RecyclerView version > 1.0.0 that fixes it.

We are already using version 1.3.2 of the RecyclerView library
and the crash seems to be long gone.
@felipeerias felipeerias force-pushed the felipeerias/searchLibrary branch from e47cece to 5991daf Compare October 23, 2024 10:28
Copy link
Copy Markdown
Member

@svillar svillar left a comment

Choose a reason for hiding this comment

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

OK let's land this

@svillar svillar merged commit 3bec278 into main Oct 25, 2024
@svillar svillar deleted the felipeerias/searchLibrary branch October 25, 2024 08:44
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

Successfully merging this pull request may close these issues.

2 participants