bischetw Top Hacker News
My app doesn’t really do much that looks technically complicated and, as far as I’m concerned, it shouldn’t be technically complicated (but for me it was).
My app connects to news.ycombinator.com (hacker news) and pulls the first 5 pages of top stories.
I thought that this would be very hard and the first thing I did was pull all of the wevents code and try to modify it to what I need. This didn’t work and, after 6 hours I started over completely. This project taught me yet again that building from the top down is not a good approach. It’s one of my bad habits, but everything always looks so simple from the outside.
One of my first main problems was getting the service to be called. Apparently I put my service declaration outside my application declaration in the manifest. That took me a while to see.
Then I had to realize that I need to set the receiver in my activity.
Then I had to figure out how I would parse the data from hacker news — what I ended up doing was looking for id’s and class declarations in the text and using a big stringbuilder to get multiple substrings. I pass around a big string that has all the links concatenated with ~`, which I break apart using the split method.
I didn’t want to use a database because my original goal was to have the upvotes from one time compare to upvotes from a previous time and only display the biggest changers. So, I stored my huge link string in a file, which I thought would be fast, and I build an array adapter using the split method (again). Clicking on items in the adapter (which have the number of up votes and the article name) opens a browser to the article. This was an easy part to implement.
Apparently using files is very very slow in the emulator and after making a file testing became very hard. My file is only about 20000 bytes big, which should not take long at all to load, but this takes about 30 seconds to a minute to load or more.
An interesting part about my project is that I scan the source code for a link to more news stories and I issue another request to open that page too. I all, I swipe the source from 5 hacker news pages.
I would have attached a picture to this but in the last two hours leading up to and a little bit after midnight my emulator and eclipse began acting very buggy and the emulator wouldn’t load and wouldn’t shut down and eclipse wouldn’t really update the code. A computer restart and everything didn’t clear this up so, thankfully my code was pretty well tested but there might be some bugs that the final hours made impossible to fix. I couldn’t test offline mode because, even when offline my emulator would load data from the internet and, when I shut my internet off the emulator wouldn’t load. Also I didn’t get to testing configuration changes and there are a few other areas that I couldn’t test. For some reason my emulator hasn’t been working right at all. I used Android 4.0 on this project and ever since I upgraded everything to the current releases (Tools 15 and such), my emulator and other testing has been a little off. So who knows, I think the concept of the hacker news articles is cool and I think what it does currently is a really cool base but, more can be done and I wish I could have done it.