Monday 5 March 2012

Using Solution DataSetObserver in Android.

Part of the key functionality of my application was the task sliders, a way of representing progress towards task completion with a highly graphical interface. Allowing the user to look at a progress bar rather than a simple number or text summary. I was having difficulty reflecting the changed progress in the summary
I found the best way to implement this was by registering an observer that would be notified of changes to the items in the List.
1:  final TaskAdapter taskAdapter = new TaskAdapter(this, R.id.list, taskArrayList);  
2:      final DataSetObserver observer = new DataSetObserver() {  
3:        @Override  
4:        public void onChanged() {  
5:          populateOverviewText();  
6:        }  
7:      };  
8:      taskAdapter.registerDataSetObserver(observer);  
Here I'm defining a new DataSetObserver and calling the method to update the textview from inside the onChanged listener. I need to fire this listener when I edit one of the progress bars. Here's the code for notifying the observer of a change.
1:    private void attachProgressUpdatedListener(SeekBar seekBar,  
2:        final int position) {  
3:      seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {  
4:        public void onStopTrackingTouch(SeekBar seekBar) {  
5:          int progress = seekBar.getProgress();  
6:          int task_id = (Integer) seekBar.getTag();  
7:          TaskHandler taskHandler = new TaskHandler(DBAdapter  
8:              .getDBAdapterInstance(getContext()));  
9:          taskHandler.updateTaskProgress(task_id, progress);  
10:          mList.get(position).setProgress(progress);  
11:          //need to fire an update to the activity  
12:          notifyDataSetChanged();  
13:        }  
14:        public void onStartTrackingTouch(SeekBar seekBar) {  
15:          // empty as onStartTrackingTouch listener not being used in  
16:          // current implementation  
17:        }  
18:        public void onProgressChanged(SeekBar seekBar, int progress,  
19:            boolean fromUser) {  
20:          // empty as onProgressChanged listener not being used in  
21:          // current implementation  
22:        }  
23:      });  

Wednesday 4 January 2012

Changes to UI code.

So I've made some change to the basic design of the application. I thought it would be worth justifying the here so when I come to write up why I remember. Originally I had a List item in my activity, I moved beyond this to using ArrayLists With an Adaptor So the new changes I've put in are more in keeping with what seems best - practices. I've got an project_list_layout.xml and a project_list_item.xml These are passed to the constructor of of the UI component which inflates the xml. I then moved beyond this to a ListActivity, which doesn't need a specific list element in the layout as one is provided as part of the subclass.

Monday 28 November 2011

Project Update

SO I've been pretty busy with my TDD courswork so the project has taken a back sit for a week. Arrgh panic!!! it's not going to match my gantt chart. oh wait, I never produced one as I thought knowing how long this was going to take me before starting was a silly idea. I've got 2 week sprints / iterations/ etc.. and I'm adding functionality each time, its till early and I gave myself til christmas to have a working prototype minimium viable product is probably a little bit fair to it, is a wireframe on an SQLite database.

Good news though, I've decided on a UI library... and the winner is greendroid! :) I thought I'd head this way when I first saw cyril demo it at Droidcon but for all intents and purposes I was still open to others, the demo app sold me though - think tour de flex, for a UI library.

So where to begin with my recent progress then.

Well, I have a database which i can edit, insert, remove records from. some basic error handling - still not sure about which route to follow with logging or exception handling yet so not too worried that at this moment in time.

UI - I've installed the GDCatalog and am playing around with that now, I had to learn to start using git, which took me a while. but from the basic functionality I've been exposed to I'm sold, after clonging a repo from the command line i figured I'd try eGit for eclipse, nice... Note to self (change 'HOME' environment variable so it stops cloning repos into muser/luke and starts clonging them into that massive new harddrive you got.)

As an aside to anyone who does install git and uses git-bash, did you find yourself just browing the hello-world folder. I liked that a lot. (as an aside...yeah right, who's actually going to read this.)

I have a meeting with my supervisor tomorrow which I'll use to agree what content to have shown off and working by christmas (next week) - I feel a few more late nights on the cards.

Tuesday 15 November 2011

Meetings and more

Just got out of my 3rd tutor meeting, he seemed confident I'm making progress and was happy to see some code for getting his head around the android paradigm, for want of a better word. I've explained the way id extended the ArrayAdapter to allow me to tie list items to instances of my Business Object though I can't help but think some sort of ORM would be really handy, thankfully I'm not dealing with a more complex set of user stories.  Feedback so far has been mainly positive my next task is to remove the logic to its own classes, i think a simple ProjectManagement interface will be the next step,  i need to start looking at a set of methods I can use across the application.

Friday 4 November 2011

Prime path coverage

Definition : a simple path is one where no node appears more than once with the exception of the first last node.

Prime path
Definition : a prime path from node Ni to Nj is a simple path that doesn't appear as a proper subpath of any other simple path.

N. B proper is used to describe a proper subset. So a subset that is not the entire set itself.