« Test ProcessTypes of Testing »

Navigationg BlackBerry Screen Saving flow

04/09/10

Permalink 11:59:24 am, by victor.ewert Email , 393 words   English (CA) latin1
Categories: Articles

Navigationg BlackBerry Screen Saving flow

I have recently been working on a BlackBerry application, and found that I often got lost in the maze of method calls that happen was a close command is initiated for a screen.  To help me keep track of it, I have created a basic flowchart which helps me follow the bouncing ball:

BlackBerry Save Model

  1. The flow starts when the User or application initiates a close screen, i.e. the user clicks on Close.
  2. This triggers the onClose() method to be called.
  3. The onClose() method calls isDirty() to see if there have been any changes on the screen.  If no changes have been made, the close() method is called and the screen is closed.  If changes have been made then the onSavePrompt() method is called.
  4. The onSave() method brings up a Dialog with the following options: "Save", "Discard" and "Cancel".  If the user selectes "Cancel" the Dialog is simple closed and the screen remains open.  If the user selects "Discard", then the close() method is called and the screen is closed.  If the user selects "Save", then the onSave() method is called.
  5. The onSave() method calls the isDataValid() method.  If isDataValid() returns false, then nothing happens and the original screen is still displayed.  If isDataValid() returns true, the the save() method is called.
  6. After the save() method has completed successfull then the close() method is called and the screen is closed.

Typically you will want to override the following:

isDataValid(): You should add you own logic for whether the data is valid or not.  Here you can check that the user entered all the necessary data and data is valid.

save(): You should implement how you want to save the data.

You may also want to override the following:

close(): if you have any special actions you want to happen when the screen closes

onSavePrompt(): if you don't want the prompt just override the method and return true.  You can also override it, if you want to implement your own dialog with different options, e.g. using Dialog.ask().  When implementing your own dialog make sure you get the return type correct, the return type boolean is for whether or not you want to close the original screen.

These methods are all part of net.rim.device.api.ui.contain.MainScreen class.

Hopefully this will be helpful to some of you.

The above Flowchart can be downloaded as a pdf: BlackBerry Save Model

 

invisibleSHIELD for Blackberry Storm

5 comments

Comment from: Stu [Visitor]
*****
StuGreat post! Very helpful.
05/09/10 @ 02:26
Comment from: Sam007 [Visitor]
Sam007Interesting post. Well done and good luck with your very great work. Will pop back soon for more read, thanks. Your website design is superb as well!
01/16/11 @ 03:46
Comment from: Gyubok Baik [Visitor] Email
*****
Gyubok BaikExcellent post. One quick question: when I execute System.exit(0), does it initially go through onClose() method or does it just exits right away discarding everything
02/07/11 @ 16:49
Comment from: victor.ewert [Member] Email
victor.ewertThat's a good question, I don't know for sure (I haven't tried it), but from what I understand, System.exit(0) will exit right away, and bypass onClose(). Others can correct me if I'm wrong.
02/07/11 @ 18:40
Comment from: Angelo fraietta [Visitor] Email
*****
Angelo fraiettaGreat - really helped me understand the logic
04/10/11 @ 22:46

XML Feeds

Kobo Inc.
August 2014
Mon Tue Wed Thu Fri Sat Sun
 << <   > >>
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Tiger Deal Slasher! Savings up to 70% OFF!

Search

Kobo Touch

Blogorama

blogarama - the blog directory
blogtool