Awful / Awful.apk

Native Android client for the Something Awful forums
110 stars 67 forks source link

Transition Forum Display to RecyclerView #421

Open Sereri opened 8 years ago

Sereri commented 8 years ago

ForumDisplay view is the only one that has scroll lag on my old test phone.

Exchanging the ListView with a Recyclerview should speed things up and make things a bit easier.

baka-kaba commented 8 years ago

I really wish we had a different name for these, I always have to think for a second if it's displaying forums or the contents of a forum (same with threads)

What do you think about a similar system to the one I used on the forum index? I sort of had that in mind when I was writing it - have an abstracted component that provides thread data as Thread objects (uh nice name) with information the RecyclerViewAdapter can use. I was thinking stuff like announcements being added under a closed dropdown if you've already viewed them all, or open if there's something new, or being able to hide stickies in the same way...

Yeah I realise this is kind of rewriting the backend here though

Sereri commented 8 years ago

Only good things can come from that though.

And yeah, I was thinking the same thing.

As for announcements, we'll have to parse them first emot-v

baka-kaba commented 8 years ago

Well sure, but it's just another thread in the thread list!

I was also (yes this is snowballing) thinking of having a PrivateMessagesRepo or whatever to abstract away the PMs - so when the threads provider loads and parses a page, if there's an unread message link on there, it can pass it to the PM handler. And that can do whatever - pop up a snackbar with a View button, or ignore it if it already notified about that particular message

I mean you can get pretty silly about this, but having a basic framework with the separate parts handing each other stuff they might be interested in seems like an easier way to build in new features. I'm also just experimenting so maybe this is the path to hell

Also an event bus might be a good idea! Oh god...

baka-kaba commented 8 years ago

Have you done any work on this? I've been poking around at it and honestly I think the whole thread list fragment could do with a rewrite. Feels like the easiest option would be to have some kind of provider component that you set to a particular forum and page, and have a callback where it returns a list of Threads when it gets the data - then you can just pass that to the RecyclerView's adapter whenever you get a callback. That way you can immediately get the current data, and any newer data once the network request finishes, and the fragment doesn't need to worry about the details - just that there's something new to stick in the view

Right now there's this really awkward setup where the forum fragment hits the database multiple times looking to see if anything's changed, calling refreshInfo() all over the place (which reruns the CursorLoaders) often followed by syncForum() (which calls refreshInfo() again). It's pretty spaghetti

Also the thread view fragment is running a ContentObserver on any changes to the thread table, so whenever ForumDisplayFragment does syncForum() they both end up trying to set the toolbar/nav menu titles, and it seems like random luck which one does it last. I think it would be better for each fragment to just tell the activity 'hey this is my current title' and let that decide what to display

Sereri commented 8 years ago

No, haven't started on anything. I created the issue more as a long term goal, like polls or profiles.

The provider approach sounds good and is probably the way to go. Syncing currently really is all over the place.

I don't know if it'll matter but I've seen people write custom RecyclerViewCursorAdapters though I guess that's one of the things we should probably get away from.