A quick update on the Android project for the bookstore.
We just hit proof of concept. I'm really pumped for this, to say the least. I finally navigated all the major snags and got it to pull all the XML files from the website, populate the spinners and then take the returned HTML and display it in a WebView. Here's the rundown:
1. Had to refactor a lot of code due to a NumberFormatException that the CourseHandler class was throwing. Turns out, the way we store our course numbers puts a lot of them in the 100k+ range, which is way too big for my shorts I was so fond of using. It was a relatively easy fix, if not a tad tedious. Bottom line, all shorts become ints.
2. My idea of using Vector<?> to stash all of my read-in Departments, Courses and Sections turned up an odd problem when writing out all the Spinner.onItemSelectedListener's. It didn't crop up until the section Spinner, which only had one possible section for the particular path I'd chosen. It wasn't ever getting inside my if-check for a valid position range. When putting in the Spinners, I realized they auto-select the first option upon populating, so I did a quick insert before proper Vector<?>-based population of a "Selection A _____" message. This, however, meant that the Spinner's indexes didn't line up with the Vector<?> indexes anymore. I somehow missed this logic error until it failed to enter the if-check. Fairly easy to fix with a <= and an index - 1 switch for referencing.
3. With a good old-fashioned BufferedReader I managed to snag the HTML bit the AJAX on the site proper was using to display the books. Turns out WebView has the capability to take in a decent amount of HTML coding by String and to apply whatever it knows how to into its view. Ugly, but the job got done.
So! That means that as of 11-ish, I have proven I can snag all the data I need and can effectively show it on screen. It went a lot quicker than I expected and truthfully, the code doesn't even need a whole lot of clean-up. I managed to design decently on the fly, so it's nicely broken up into bite-sized functions and fairly well commented. Some of this last minute stuff needs updating, a few commented out test blocks need to be removed, but overall, I'm happy to call our first milestone obtained.
Next on the docket is, of course, prettying up that HTML it gives me. Not only is it poorly formatted for what I want it to look like, it doesn't have everything I would want to show to the user. Right now, I'm thinking that I may want to simply display a number total with a button to view titles ("Search returned 3 results! [See Available Titles]"). I also want to get an HTML parser in there of some sort so that I can just grab the data I want for easier formatting on the following page. Lastly, there is no thumbnail for the book, and I'd like to snag that (which I know how to do already, quite by accident during an experiment) and have it display next to the title. Within that, I may have it go to a separate page with the full info, but that's further down the road.
Summary: Proof of concept reached, finally have something to write home about.
TODO: Refine, error-check and pretty it up. Also, make sure there are no memory leaks and that Spinners are emptying before repopulating when a Spinner further up the path is changed.
No comments:
Post a Comment