teaching machines

iOrganize – Homework 2 – weeksc

October 20, 2011 by . Filed under cs491 mobile, fall 2011, postmortems.

iOrganize it a simple To-Do sort of app. The basic idea is that you have a list of Tasks you’d like to accomplish. Each task has a progress or percentage complete associated with it. There is a green plus button in the upper left hand corner to add tasks. Tasks can either be deleted either by clicking the red ‘-‘ or long clicking…though it’s not actually a longclick – more on that later.

Basic Idea

 

Ok, I spent 5 minutes trying to add that picture in…don’t judge. Anyway, that’s the basic. It’s not much different from Rttler with the exception of some fun logic updating a progress bar. Boring.

 

 

So the next thing I did was add the functionality to add sub tasks to existing tasks. But I didn’t want the whole list to be shown. I wanted the user to be able to show and hide child task. The only thing that changes logic-wise it that if a task has child task it’s progress can’t be edited by the user. Instead, the progress complete is calculated from the children. Each child is assumed to carry an equal weight. Android has an existing ListView that does pretty much this – ExtendableListView.

 

 

Unfortunately, adapting a flat list implementation to a tiered list was not easy. Looking at my code now it’s seems pretty trivial, but there were gotchas all over the place.Every method that the standard ListView had is split in two separate parts, one for the Group and one for the Child.

For example, here’s the onItemClick method for Rattler:

And here’s the equivalent Click methods for iOrganize:

Fundamentally it’s pretty straightforward and easy to understand. One click method for top level (Group) and one for second leve (Child). However, one of the problems I ran into was getting the onChildClick to fire. No matter what I tried the code just wasn’t being reached and clicking on Child tasks in the UI did nothing.

The problem was in the Adapter. There is a method there that can completely short circuit the click event being sent to the ListView. And for some stupid reason it by default does just that.

Others things kinda neat – the dialogs that pop up when long clicking a task aren’t actually Dialogs. They’re context menus. I had to use context menus because, unlike the click methods, the onItemLongClick method is not broken up into what I would think to be logical onChildLongClick and onGroupLongClick. Unfortunate. onLongClick is simply given the index of the item that was selected in the list. The usefulness of that index goes way down when there are any number of tasks expanded or collapsed. Sure, I could have written some fancy function to iterate over the Tasks and essentially transform the flat index provided into a groupPostion and childPostion (in fact I did most of this function and it’s pretty cool) but it got hairy quick. The ExtendableListView class has a number of methods to alleviate the problem of  no separate onLongItem click by using ContextMenus. I won’t post any code, because most of what I did referenced this blogpost:

http://steveoliverc.wordpress.com/2009/10/16/context-menus-for-expandable-lists/

A couple of other, kinda nifty things I did was remove the “Add” option from the first row in the list and put it as the list header instead. This eliminated the need forall the

if(position == 0)

that we had to do in Rattler.

I also added an option to remember the users preference for deleting task. The user can opt to confirm their wish to delete Tasks every time they go to delete it or select to delete without reminders. Seemed useful.

 

Ok, I think that’s everything. Here’s a screenshot of the finished product!