bishopmatthew / HackerNews

An open source Hacker News client for Android.
230 stars 61 forks source link

Network error when trying to open a poll #11

Open bishopmatthew opened 11 years ago

bishopmatthew commented 11 years ago

For example, the AMA poll thread. At this time, I don't want to write the extra code to support displaying the poll options and actually allow voting (someone else is certainly free to do so). But it should at least display the title, selfText, and comments correctly.

pkillian commented 11 years ago

Will be trying my hand at patching this up when I find the time; will comment here if I stop actively dev'ing on it.

bishopmatthew commented 11 years ago

The first you'd want to do is look at:

https://github.com/bishopmatthew/HackerNews/blob/master/src/com/airlocksoftware/hackernews/parser/CommentsParser.java#L138

That's where the HTML containing the header story is sent to be parsed. You'll want to look at the raw HTML from both a poll and non-poll thread, and see if you can spot any identifying features (a div that only appears on polls, for example). Then you can split that call up into two separate methods like parseStory() and parseStoryWithPolls(). The easiest thing to do is just fix whatever's throwing the exception, and ignore all the poll options. Further extensions might include adding a UI for viewing and voting in polls -- if you try to add that, look at:

https://github.com/bishopmatthew/HackerNews/blob/master/src/com/airlocksoftware/hackernews/fragment/CommentsFragment.java#L407

Like I said, I'm happy to help if you try this out and run into any problems.

pkillian commented 11 years ago

Seems like polls have td.comment elements inside of the same table body as title and subtext elements. Considering a few solutions to detect this.

bishopmatthew commented 11 years ago

Yeah, if you look at the rest of the parsing code, there's a lot of kinda hacky stuff going on because the layout is table-based and doesn't have semantic classes. One idea -- on the top-level tbody that contains the story and poll, select <img> elements and if there's more than one or two, you must be on a poll.

majuscule commented 10 years ago

Hey, just wanted to chime in and mention that this is an issue that has bothered me for a while now. I might take a stab at it myself but don't have too much free time. I'll report back if I do manage to hack anything together. In the meantime, thanks for developing this app @bishopmatthew ! :-)

pkillian commented 10 years ago

Its bothered us too; we seem to have programmed ourselves into a corner here, however. V3 has much more modular calls for getting parsable data, and will certainly have this feature. Sorry for the lack of updates on it! I may take a stab at it tomorrow on my flight, but who knows