After using my barcode check-in app at the GVCC races on Thursday nights, I noticed that it was still missing a couple of major features. While the main barcode scanning workflow worked correctly I still had problems with:
- Assigning a barcode to a new racer - this was annoying because in the beginning of the season I had to hand out quite a few barcodes to new racers. Unfortunately, I didn't have a good way to track them, so I ended up writing them down on a piece of paper. Of course this meant that I didn't want to send in the barcodes until I also sent in the updates to the new barcodes.
- Manually entering a barcode - There really was no way to manually enter a barcode. I saw that this could become a problem, since many racers have their barcode sticker on their helmet or bike where it's exposed to the elements. As the season goes on, members may have scratches on the barcode that would prevent it from being read.
I was able to make additions to the app to resolve these issues. First, I decided to add some buttons to the main view of the app, but I wanted to make sure that I didn't have to take the user away from the main workflow. This lead me to using a dialog.
A dialog is a panel that is displayed over the top of your current view. You can add just about anything to it, including text, images, radio buttons, etc. For the "assign a new barcode" case, I added a dialog with 3 textboxes and a button at the bottom that allowed me to collect first name, last name, and barcode, and then submit the answers to a separate file. The "manually enter barcode" case was even easier, since it just required a single textbox where I could type in a barcode, and then the button would save it to the same file that the other barcodes were being scanned into.
There were 2 "tricky" parts to creating a dialog. The first was trying to figure out when in the lifecycle to actually create the dialog. Apparently, the recommendation is to create it in the onCreateDialog(id) event, and this is what I used. This event is fired during a call to showDialog(id), where you pass in an integer that identifies which dialog you want to show. From there, I just used a simple switch statement to differentiate between the 2 types of dialogs, used a layoutInflater to set up the layout from an xml file, and finally call the create() method on the AlertDialog.Builder object. The create() method actually creates and shows the dialog on the screen.
The second trick that I ran into is realizing that all of the objects that are on the dialog are really on a separate view. That means that if you want to access the fields on the view, you can't just do something like "this.myTextBox", you need to use "memberDialog.myTextBox". Obviously that meant that I ended up storing the actual dialog object in a member variable, which I'm not too happy with, but it seemed to work ok.
Other features that I'd like to include in this app are:
- Look up member barcode by name
- Look up member eligibility - paperwork turned in, paid - from gvcc racing database
- Check in marshals - so they can be flagged for not showing up!
I think that I've got the most important cases covered though. I'd like to publish this to the Android Market so that other gvcc members can access it quickly if there's a need to do a check-in and I'm not there, so that will probably be my next action with this app.