My first Native Android App (Update #2)

I’m very close to calling this app, version 1.0. 🙂 Since the last update, I’ve tweaked a few things about the Android application. For starters, I stepped back to think about the potential users of my app and streamlined the ‘home’ screen into 2 core functions:

A. Browse restaurant inspection results by county.

  • This defaults to Clarke county but you can select a different county to view
  • After hitting the button, the user will be presented with simple listing of all the restaurants in that county.
  • I added SectionIndexer to this listing to help the user navigate faster. This blog post was very helpful in understanding this feature and getting it to work.


B. Find a specific restaurant’s scores by searching.

  • This is an AutoCompleteTextView which hopefully guides the user in their search
  • The user has to enter a search term with at least 2 characters. I tried searching “a” and it wasn’t pretty. 🙂
  • After hitting the button, the user will be presented with a map with the locations represented by markers and  a ListView of the found restaurants. It also implements the SectionIndexer.
  • A concern I had with this page was the fact that initially, I was calling out to Google Maps API in the same thread as my user interface and Google recommends against doing this. For queries like “uga” or “mc” which return a large number of restaurants, it took the resultant activity a while to load to I investigated AsyncTask. I’m happy to say I got it working and I owe a ton of thanks to without which I would not have come this far in my app. 😀


After performing either A or B, the user can select a restaurant to view health inspection details and the user will see any of the following screens:


Sidebar: I scraped the health inspection data from the Public Health Athens website and I used the wonderful Jsoup library to do it. I’m hoping to clean up my code and publish it on Github for others to check out and maybe use.  <digression>I’m currently using git (Bitbucket) for version control and I love Bitbucket because of their unlimited free private repos! Github does offer 5 free private repos to students but I use version control on my school projects and as you can imagine, I have way more than 5 private repos on Bitbucket.</digression>

Because of the way I scraped/collected the data, my application (should) only display the recent health inspection data, etc. It doesn’t retain any historical information but that is out of my hands due to the limited information available on the website. A case could be made for instances where the site shows 2 different scores but scraping depends on regularity and I found several instances where the site didn’t stick to expected format. I digress;  I’ll deal with that issue later.

From what I was able to glean from the site, here’s how the colors work:

  1. if you have a score of 90 or higher without any critical violations, you are in the green. You could have a few non-critical violations here.
  2. Any critical violations lands you in the red zone even with a score above 90.
  3. If you are above 80 and only have non-critical violations, you get a yellow check mark.

If any violations are present, there’ll be a button for you to click through to see the corresponding violations associated with that restaurant. For instance:

Screenshot_2013-10-29-00-31-27 Screenshot_2013-10-29-00-31-02

So there you have it: my first native Android app in the works. I’m feeling pretty good about my app’s progress and I’m currently seeking a few beta testers. If you live in the Athens, GA area and have an Android phone with version 2.3 or higher, feel free to send me a note about wanting to be a beta tester. My gmail handle is janeullah so shoot me an email if interested. The impetus for getting this app off the ground was the fact that I’m working on another Android app with 3 of my classmates for a class (Human Computer Interaction (HCI) with Dr. Chris Plaue).

Helpful Tools

  1. Stackoverflow is every CS student’s not-so-secret weapon. I’m not ashamed to say this was my first port of call whenever I had problems. Thanks to Stackoverflow, I resolved every issue I had. From how to create the proper calls to the SQLite database, getting the SQLiteDatabase to be copied to the right location using the right conventions, properly setting up my Async Task, to creating custom ListView adapters, et cetera. So, even if the first question doesn’t have an answer, try a different search term and really try to understand the answers that were provided. From now on, I’ll do my part by documenting solutions to issues I’ve faced either here or on Stackoverflow.
  2. On Android, the data’s stored in a SQLiteDatabase which I created by using the script to convert my MySQL database to SQLite. For version 2, I’ll probably make the home screen a little nicer (less bare) and include a “restaurants around me” type of activity.
  3. After converting the MySQL database to a SQLiteDatabase file, I had to edit the SQLiteDatabase directly and I did this with the help of a Firefox addon called SQLite Manager.

Screenshot from 2013-10-29 00:53:30

Course Picker

Here’s an example of what I recently worked (demo below). I’m taking Web Programming and one of the projects was to write a Course Scheduler web application. The web app is written in Java and I am having a blast with it. The courses are ‘drawn’ using HTML5 Canvas and the sections  & meeting times are dynamically loaded using the goodness of JavaScript & jQuery & powered by a MySQL database.

Note: I came up with this first iteration but the final product looks much different from this version mainly UI changes from another student.

A Simple Game (Snake!)

It’s that time of the year: projects/homework/exams. Anyway, I created a ‘demo’ of a class project that’s due next week. I’m still working out subtle bugs with it but I’d like to get a little fancy with it so I’m open to suggestions. Check out the demo on YouTube. For my GUI projects in Java, Eclipse has been invaluable but I’m still using Emacs for my C/C++ coding projects. 

The program requirements specified that the “Snake” be implemented as a queue. Once I got the hang of queues, moving was as simple as repeatedly enqueuing (using queueName.add(item)) and dequeuing (using queueName.remove() to take off the head element). 

Die Rich Craps game in Java

For one of my programming projects last year, our task was to create a version of the Die Rich Craps game. I finally decided to put my code for that project (and others) on Github.

My submitted project looks, in retrospect, a little unreadable but I did try to comment the code appropriately. My Die Rich craps implementation is contains:

  1. 2 while loops
  2. 1 for loop
  3. 4 if/else statements
  4. 2 if statements
  5. 4 if-else-if laddered statements.

So, I am in the process of rewriting it to be a little shorter and slightly more testable. I have a rough & incomplete sketch which goes:

1) Create a Players class which will contain key variables that are unique to each instance of the Players class and a final static class variable which applies to all members of the Players class.

2) Create the DieRich class file (which includes the main method)

That’s as far as I’ve gotten. So far, it’s a good experiment to think about breaking the program/project into tasks and writing code accordingly.

I visited a software product company recently and I learned that tests (regression and unit tests) are exceedingly important & take up just as much time as coding does! The developer I ‘shadowed’ walked me through the process of unit testing which I will try to implement in my projects this semester.

Verifying Input

When creating constructors and adding setters, I’ve been taught to verify all input passed to the method. In working through the ProjectEuler exercises, I’ve made use of helper methods that hadformal parameters but didn’t necessarily verify the input (bad habit). With Problem8, I decided to put this into practice. The problem was: “find the greatest product of five consecutive digits in a 1000-digit number.’ I solved this problem using 2 for loops:

  1. With the first for loop, I created a String object that contained 5 characters at one time. With every iteration of the for loop, the sentinel would be updated by 1 and thus, the String would be updated to contain a new sequence of 5 characters e.g.  startingString.substring(i,i+4).
  2. Rather than perform the required computation in the 1st for loop which would made my program faster, I decided to create a helper method which would accept a String and return the product of all the digits in that String. 
  3. The first iteration of my helper method didn’t include any checks to verify that the String didn’t have any non-word characters which would have caused a NumberFormat exception (I converted the digits in the String object using Integer.parseInt(String name)).

     So, I added some to the helper method I used to make sure that the algorithm would return correct/appropriate output when provided input that fits the formal parameter specifications. 

  4. First, I stripped the String of all non-word characters with this command: digits.replaceAll(“\W”,””); An alternate and informative way to alert the user to the ‘bad’ input is via the try { } catch { } feature of Java.
  5. Another thing to check for is if, after stripping all non-word characters from the String passed to the helper method, the String’s length is 0 i.e. the String is an empty String, I would return 0 as the product of the String in that case instead of the value of Product which was initialized to 1. That was taken care of via a simple conditional statement. Here’s the code for my helper method:

Overall, it’ll be good practice for me to view my code with an eye to splitting off ‘tasks’ into helper methods and making sure that input is verified. 

Happy December break! :)

I’m thankful for family and thankful that my faculties are still sharp. 🙂 Long way of saying my semester ended on a very strong note.

Taking a break from stuffing myself, I thought of a crude solution to Problem 5 from Caution: With the way I solved the problem, I’ll run into an integer oveflow situation for N > 23. Without further ado, here’s the gist of my rough solution:

I’ve started using Github (@janoulle) and I know the basics of creating/cloning a repo, adding, committing and pushing. I may have to pony up for a private repo for placing my class assignments but the cheapskate in me thinks it might be better to move to Bitbucket which has free & unlimited private repos. 

Edit: Problem 6 was relatively straightforward and I solved that quickly. It requires summation formula which, if you’ve taken Calculus I or Discrete Math, should be easy to do. I’ve pushed it to the Github repo which contains  all my solutions.

Edit: Problem 7 is done.