MuntashirAkon / AppManager

A full-featured package manager and viewer for Android
https://muntashirakon.github.io/AppManager/
Other
4.36k stars 259 forks source link

Fast scroll sliders are broken throughout the app #428

Open Cyberavater opened 3 years ago

Cyberavater commented 3 years ago

Try to swipe through the App Ops page using the slider, you'll see what I meant.

MuntashirAkon commented 3 years ago

You mean the scrollbar or the horizontal swiping?

assembleDebug commented 3 years ago

You mean the scrollbar or the horizontal swiping?

Scrollbar ,its glitchy when you drag it up and down.

MuntashirAkon commented 3 years ago

@MrIkso: Please check this.

MrIkso commented 3 years ago

Try to swipe through the App Ops page using the slider, you'll see what I meant.

@Cyberavater Hello, send video, please.

assembleDebug commented 3 years ago

Try to swipe through the App Ops page using the slider, you'll see what I meant.

@Cyberavater Hello, send video, please.

https://user-images.githubusercontent.com/83750299/117310464-ed0d3c00-aea0-11eb-849d-ed4c97145747.mp4

MuntashirAkon commented 2 years ago

@MrIkso, it looks like you haven't followed the guide properly as mentioned in this issue: https://github.com/zhanghai/AndroidFastScroll/issues/34

Since you haven't used custom ViewHelpers required when list items have different heights, the scroll bars aren't working as expected.

Implementing custom ViewHelper for each recycler view is not something I have in mind right now. So, I'll just revert the commit for now (but you can implement it if you have time).

Cyberavater commented 2 years ago

I wouldn't say "throughout the app", as it seems to be working fine on the Onboard page.

MuntashirAkon commented 2 years ago

I wouldn't say "throughout the app", as it seems to be working fine on the Onboard page.

If you backed up a few apps but not all apps, it would create height calculation issues. Height difference is significant in the app ops tab (due to most app ops not having any permissions associated with them) which is why it's broken there more than any other tabs.

AndroidDeveloperLB commented 2 years ago

Is there any way to set it right without knowing the height of all items in the list? Maybe I could provide an estimate average of them? After all, each item might have a different height, and the list can be quite large in number... I don't want to measure them all just for the fast-scroller... Maybe you could have a sample of how to do it during loading time of the list, so that it won't cause much work on the UI thread?

MuntashirAkon commented 2 years ago

Taking average wouldn't do much help in the app ops tab but it might work in others.

What about a scroller based on the number of elements? I've seen it in some apps, the scroller behaves oddly if the number of items are too small. But it always works as expected. It would also be very interesting to know how the RecylcerView itself calculates the scroller heights when fast scroller is enabled.

AndroidDeveloperLB commented 2 years ago

@MuntashirAkon "app ops tab" ? I was talking in general, to ask about possible solutions. It was meant to be read to the main developers of this library.

MuntashirAkon commented 2 years ago

No, I don't think so. RecyclerView items could be very diverse according to their usage.

AndroidDeveloperLB commented 2 years ago

@MuntashirAkon How does the native one do it, then? Granted I saw its size changes, which is weird, but it's better than weird movement. The library could have an average, together with the number of items. The more items there are, the less noticeable the size-changing would be.

MuntashirAkon commented 2 years ago

The library could have an average, together with the number of items. The more items there are, the less noticeable the size-changing would be.

I don't know much about how views are rendered. But I don't think it's possible to measure the heights of a wrapped layout until they are rendered. If that's the case, then it won't be possible to take an average height as you'd be limited to the number of views rendered on the screen.

AndroidDeveloperLB commented 2 years ago

@MuntashirAkon I mean an estimated average. For example it could see what's shown right now, and take an average of that. Or adjust as you scroll. Another solution I've suggested is to show us here a sample of calculating the heights of all the items during a loading-phase, before showing any content of the RecyclerView.

MuntashirAkon commented 2 years ago

I mean an estimated average. For example it could see what's shown right now, and take an average of that.

The default scroller already works perfectly if all items have the same height. The trouble is with the items with different heights and it could always be possible that there's an item with 200dp height which we haven't seen so far.

Or adjust as you scroll.

I think they already do this but in a very bad way which causes the flickering as reported by the author of the issue.

Another solution I've suggested is to show us here a sample of calculating the heights of all the items during a loading-phase, before showing any content of the RecyclerView.

Not possible if the item layouts are wrapped. Heights are calculated only when they're rendered.

AndroidDeveloperLB commented 2 years ago

@MuntashirAkon Height can be measured before being rendered. See here: https://stackoverflow.com/a/28136027/878126

MuntashirAkon commented 2 years ago

Height can be measured before being rendered.

Even then, if you were to measure the heights of all views, you would have to create all views which might take a lot of time and UI would freeze during that moment. To mitigate this issue, you might consider re-calculating the slider position as the user navigates through the list which, again, might cause flickering if you want to change the slider real-time.

I didn't understand how FastScroller is able to calculate size of the slider nor do I know why they are yet to come up with a solution to the problem.

AndroidDeveloperLB commented 2 years ago

@MuntashirAkon I know ,but maybe it's possible outside the UI thread? Or use the UI thread for each View, one after another and yet not in a loop with all of them? This will prevent freezing.

MuntashirAkon commented 2 years ago

maybe it's possible outside the UI thread?

If that's possible, then I think it's okay.

AndroidDeveloperLB commented 2 years ago

@MuntashirAkon Even if it's not, you can have the trick I've mentioned.

MuntashirAkon commented 2 years ago

Height can be measured before being rendered. See here: https://stackoverflow.com/a/28136027/878126

AFAIK, all solutions assumes that the view will be rendered sooner or later which isn't the case here. Here we need to calculate heights of the views which will never be rendered.

AndroidDeveloperLB commented 2 years ago

@MuntashirAkon Depends on the case. In general if the Views are ready, you can measure them. Of course, here in a RecyclerView it's quite tricky.

MuntashirAkon commented 2 years ago

A workaround, it seems, is to wrap the RecyclerView inside a ScrollView and enable fast scrolling in it.