Fast scroll through RecyclerView breaks items placement - android

I'm the developer of Fulguris Web Browser and I'm faced with a weird issue in my tab list which is using a RecyclerView.
When scrolling fast through those tab lists, either horizontal or vertical ones, items get stuck mid-flight as shown on below screenshot:
That's hardly ever an issue when manually scrolling through the list. It mostly triggers when doing Ctrl+Tab which is using smoothScrollToPosition to move to the new current tab. It also seems to be more of an issue when under load like when loading web pages in the background.
Relevant source code can be found on GitHub.

That code base was using some custom ItemAnimator namely HorizontalItemAnimator and VerticalItemAnimator that were causing those issues. My understanding is that those classes were once parts of the AOSP, looks like they are long gone though.
Using DefaultItemAnimator which is obviously set by default on AndroidX RecyclerView fixes those issues.

Related

Nested Recyclerview using TalkBack seems to skip elements and not read things in an order displayed

Summary:
When using talkback with nested recyclerview using the swiping the scrolling seems to hop as in skip complete rows and sometimes not scroll all the way to the right. Keep in mind this only happens when both the width of the nested recyclerview is larger than the screen. I included a video of me just swiping to the right and you can see the issues. Weirdness like this is happening on my work project as well.
Video
https://drive.google.com/file/d/1fUT4F0CaD34lLVdELBoBK3EPZ4PeNmMy/view?usp=sharing
Keep in mind there is 7 in each row and sometimes it skips the 7th. Also sometimes it just skips to a completely new roll or scroll weird. On my work project I have seen it skip rows as well.
Details:
I recreated it on a simple example online of nested recyclerview. I simplified it as much as I could here
https://github.com/DavidCorrado/NestedRecyclerview
I tried what other articles suggested which it seems to me everyone just eventually gave up
nestedScrollingEnabled
descendantFocusability="blocksDescendants"
focusableInTouchMode="true"
descendantFocusability="beforeDescendants"
Question:
Is this just broken or is there any work arounds for nested recyclerview?

Multiple recyclerviews (gridlayout and horizontal linearlayout) inside one view

I am trying to achive this:
First I tried by putting all my recyclerviews (with WRAP_CONTENT) inside a nestedscrollview. That worked, but the performance was awful. Then I tried to set a height for my recyclerviews, that was a lot better (especially the first gridlayout and the horizontal linearlayout loaded very fast), but still had the problem with the dynamic "category" part.
Now I am trying to put all my recyclerviews inside a single recyclerview with different viewtypes. Since that is a pretty big deal (I need to refactor a lot of code because I have diveded every area from the screenshot inside a single fragment and now I need to put all that code inside an adapter) I wanted to ask if I can actually expect any gain from this, because in the end its again a "nestedscrollview" (made by myself, but...). Or if there is some other "best practice" way to achive this layout.
Thank you
Edit:
As expected this didnt do the trick neither. When just the two first recyclerviews are added as viewtype it scrolls and loads smoothly. But as as soon as I try to add the category items (below the category), I notice a lag and especially when selecting multiple categories and scrolling fast up, there is noticable lag. I guess I will have to change my layout and move the category selection part inside a separate view, just need to come up with a user friendly solution. But its acutally quite dissapointing that, in my opinion such trivial task, laying out multiple tables, is such a pain in the ass on android.
I didn't manage to get it working with standard android stuff.
Now I am using epoxy from airbnb ,and I have converted all my views from nestedscrollview to the epoxy recyclerview. Its a great library, and airbnb use it too for all their views.
Nevertheless it's sad that the android dev team doesn't address this problem and provide a solution besides the info "don't nest multiple scrollviews(recyclerviews) that scroll into the same direction".
You can use Recyclerview in recyclerview.
https://irpdevelop.wordpress.com/2016/02/10/horizontal-recyclerview-inside-a-vertical-recyclerview/
And make sure to use multiple view types.

Shouldn't I be using a RecyclerView?

I want to implement a schedule-like overview as List and as Grid View. Currently this works using a RecyclerView and swapping out the LayoutManager at Runtime. This works fine in general, but as soon as I tuned the grid cells to have a fixed height, I realised that the RecyclerView does not respect the wrap_content layout property and instead introduces whitespace between my grid items.
I then stumbled over more or less the same question for the linear LayoutManager and the third-party provided specialisations of the LayoutManager. A quick searched revealed nothing similar for the GridLayoutManager and I am beginning to suspect I am going down the wrong road:
Apart from the easy switching between layouts, there seems to be no reason for me to work with a recycler view:
I dont't require any special animation stuff.
My adapter returns a fixed list without loading more items on demand.
Actual recycling of items doesn't even take place.
So I am currently evaluating to simply switch to separate Fragments using an ordinary ListView and GridView. But this does feel a little like working against the intentions of Android ... After all, they introduced a single view that (in theory) should exactly do what I need.
Am I missing something obvious that could turn out to be painful when using those "legacy" Views to get the job done? Or are there maybe other, more specific Views that allow switching from linear to grid layouts apart from the RecyclerView?
If this should be of importance: I am using Xamarin.Android, not native Java. But I would be willing to port some code from Java to C#.
Follow this ticket:
https://code.google.com/p/android/issues/detail?id=74772
It is not merged yet but soon should be merged and WRAP_CONTENT support should be available in the next version (23.1.1+) or the one after.

Android view with many different layouts

I'm creating a home screen for an Android app. The homescreen will be a vertically scrolling list, containing many different elements.
These elements can be things such as a simple card list, a side scrolling carousel of items (ViewPager?) or just a basic WebView.
Is it possible to use a RecyclerView efficiently with multiple types of content (that can also have their own adapters). Or is there something else available that I may not be aware of?
The BBC news app is similar close to what I am trying to do.
A RecyclerView is actually designed to do such things, I don't think that you have any other choices right here, however this shouldn't cause you any problems I've tried something like this earlier last month and it worked perfectly for me
even tho i added multiple types of content, the only problem that i faced was with the ListView because i added some sort of animation to the content
but after i used a recyclerView everything worked fine but you also have to reconsider using a ViewPager inside a RecyclerView as an Item, it might cause you some problems as it should be used in conjunction with Fragment to allow users to flip left and right through pages of data which in most of the cases are tabs.
checkout the documentation.
And the BBC news app that you refer to in your question is using a RecyclerView inside a tab into a TabHost that uses ViewPager.
More Information About RecyclerView.
Good Example for RecyclerView Sample for RecyclerView

Scroll listview to bottom as fast as possible, but without skipping any items being viewed

I need to make the listview scroll as fast as possible over all of its items, without skipping any of them.
I've found out that the smoothScrollToPositionFromTop(int,int,int) is very good, but it works only on API11+, and i wish to target at least API8.
I've also tried to use setOnScrollListener and similar solutions (setSelection, for example), but they either didn't work or they are too slow and doesn't reflect what an end user can do (fast fling over the listview). How do i achieve this?
Take a look at the ListView source in API11+ and copy/paste it into a class that you extend from ListView.
http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.1_r1/android/widget/AbsListView.java

Categories

Resources