timehop / sticky-headers-recyclerview

[UNMAINTAINED] Sticky Headers decorator for Android's RecyclerView
Apache License 2.0
3.74k stars 755 forks source link

Any way to improve performance? #19

Open emileb opened 9 years ago

emileb commented 9 years ago

Really nice work on this! Can you think of a way to improve performance? Adding the headers makes the list scrolling not very smooth, this is even on a Note 4. The onDraw adds over 70ms per draw, can anything be done you think?

emileb commented 9 years ago

Actually don't worry, the issue is my "getHeaderId" is slow :) It's called every frame so I need to optimise! Thanks.

jacobtabak commented 9 years ago

Thanks for the report - I'll leave this open and try to optimize it.

jamie94bc commented 9 years ago

From a quick look there is an easy gain to be made in HeaderPositionCalculator.hasNewHeader(int position) by not calling mAdapter.getHeaderId(position) twice :smiley:

jacobtabak commented 9 years ago

Nice, thanks, do you want to PR it? On Apr 16, 2015 12:01 PM, "Jamie Clarke" notifications@github.com wrote:

From a quick look there is an easy gain to be made in HeaderPositionCalculator.hasNewHeader(int position) https://github.com/timehop/sticky-headers-recyclerview/blob/master/library/src/main/java/com/timehop/stickyheadersrecyclerview/HeaderPositionCalculator.java#L47 by not calling mAdapter.getHeaderId(position) twice [image: :smiley:]

— Reply to this email directly or view it on GitHub https://github.com/timehop/sticky-headers-recyclerview/issues/19#issuecomment-93785293 .

jamie94bc commented 9 years ago

Went a little further then that :smile: https://github.com/timehop/sticky-headers-recyclerview/pull/42

denisk20 commented 9 years ago

Also there are tons of Rect allocations (tracked for like 5-second scrolling for a list with 100 items and 10 headers): image image image image

I might submit a pull request to make methods that return Rect accept outRect parameter if you don't mind.

jacobtabak commented 9 years ago

That would be much appreciated! On Aug 7, 2015 7:50 AM, "Denis Kniazhev" notifications@github.com wrote:

Also there are tons of Rect allocations (tracked for like 5-second scrolling for a list with 100 items and 10 headers): [image: image] https://cloud.githubusercontent.com/assets/3080318/9135955/3cf94c0c-3d1b-11e5-916a-b50979eb464c.png [image: image] https://cloud.githubusercontent.com/assets/3080318/9135971/65b7f986-3d1b-11e5-8969-e3adc0845956.png [image: image] https://cloud.githubusercontent.com/assets/3080318/9135986/80d0416a-3d1b-11e5-8658-32c425cd793f.png [image: image] https://cloud.githubusercontent.com/assets/3080318/9136002/92f0ab64-3d1b-11e5-86a4-36f75105363c.png

I might submit a pull request to make methods that return Rect accept outRect parameter if you don't mind.

— Reply to this email directly or view it on GitHub https://github.com/timehop/sticky-headers-recyclerview/issues/19#issuecomment-128691963 .

denisk20 commented 9 years ago

@jacobtabak Sorry, just got round to it. I have submitted a pull request, please take a look.