SimonHalvdansson / Harmonic-HN

Modern Android client for Hacker News
https://play.google.com/store/apps/details?id=com.simon.harmonichackernews
Apache License 2.0
611 stars 40 forks source link

Comment header #156

Closed flofriday closed 6 months ago

flofriday commented 6 months ago

I just read through the complete codebase but what still suprises me is why there seems to be an empty element in the comment array?

Line: https://github.com/SimonHalvdansson/Harmonic-HN/blob/cd8dc297909af84d73282c03c33524d2b40bb186/app/src/main/java/com/simon/harmonichackernews/CommentsFragment.java#L369

This then also forces some for loops to start with index 1 which seems a bit odd. Why is that comment needed?

naitgacem commented 6 months ago

Hello @flofriday, that empty comment/story you see around the codebase is the header. It is then rendered with a different ViewHolder in the RecyclerView. In my fork I have removed that and used a TopAppBar instead.

SimonHalvdansson commented 6 months ago

Yeah what @naitgacem writes is correct, this pattern is used for the headers in SubmissionsActivity and StoriesFragment also. Doing this with TopAppBar is probably nice, right now the logic of handling both the comments and the header is to intertwined to a degree (although not super much, it is slightly ugly) so this would be a nice improvement.